Skip to content

Commit

Permalink
fix: 馃悰 Login funkar i iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
JohanObrink committed Mar 11, 2021
1 parent 4f6ab3b commit 1c3d6f5
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 35 deletions.
33 changes: 24 additions & 9 deletions packages/app/components/image.component.js
@@ -1,18 +1,33 @@
import { useApi } from '@skolplattformen/api-hooks'
import React from 'react'
import React, { useEffect, useState } from 'react'
import { Image as ImageBase } from 'react-native'

export const Image = ({ src, style }) => {
const { api } = useApi()
const cookie = api.getSessionCookie()
const [headers, setHeaders] = useState()

const getHeaders = async (url) => {
// eslint-disable-next-line no-shadow
const { headers } = await api.getSession(url)
setHeaders(headers)
}

useEffect(() => {
getHeaders(src)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [src])

return (
<ImageBase
source={{
uri: src,
headers: { cookie },
}}
style={style}
/>
<>
{headers && (
<ImageBase
source={{
uri: src,
headers,
}}
style={style}
/>
)}
</>
)
}
4 changes: 2 additions & 2 deletions packages/app/components/logout.component.js
@@ -1,7 +1,7 @@
import { useApi, useUser } from '@skolplattformen/api-hooks'
import { Button, Text } from '@ui-kitten/components'
import Personnummer from 'personnummer'
import React from 'react'
import React, { useState } from 'react'
import { Image, StyleSheet, View } from 'react-native'
import { CheckIcon, CloseOutlineIcon } from './icon.component'

Expand All @@ -13,7 +13,7 @@ const imageSources = {
export const Logout = ({ navigation }) => {
const { api } = useApi()
const { data } = useUser()
const [gender] = React.useState(() => {
const [gender] = useState(() => {
if (data?.personalNumber && Personnummer.valid(data.personalNumber)) {
return Personnummer.parse(data.personalNumber).isFemale()
? 'female'
Expand Down
24 changes: 17 additions & 7 deletions packages/app/components/modalWebView.component.js
@@ -1,7 +1,7 @@
import { useApi } from '@skolplattformen/api-hooks'
import { Text } from '@ui-kitten/components'
import URI from 'jsuri'
import React from 'react'
import React, { useEffect, useState } from 'react'
import { Modal, StyleSheet, TouchableOpacity, View } from 'react-native'
import { SafeAreaView } from 'react-native-safe-area-context'
import { WebView } from 'react-native-webview'
Expand All @@ -10,7 +10,19 @@ import { CloseIcon } from './icon.component'
export const ModalWebView = ({ url, onClose }) => {
const [modalVisible, setModalVisible] = React.useState(true)
const { api } = useApi()
const cookie = api.getSessionCookie()
const [headers, setHeaders] = useState()

const getHeaders = async (url) => {
// eslint-disable-next-line no-shadow
const { headers } = await api.getSession(url)
setHeaders(headers)
}

useEffect(() => {
getHeaders(url)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [url])

const uri = new URI(url)

const closeModal = () => {
Expand All @@ -34,11 +46,9 @@ export const ModalWebView = ({ url, onClose }) => {
</TouchableOpacity>
</View>
</View>

<WebView
style={styles.webview}
source={{ uri: url, headers: { cookie } }}
/>
{headers && (
<WebView style={styles.webview} source={{ uri: url, headers }} />
)}
</SafeAreaView>
</Modal>
)
Expand Down
24 changes: 12 additions & 12 deletions packages/app/ios/Podfile.lock
Expand Up @@ -238,12 +238,12 @@ PODS:
- React-jsinspector (0.63.4)
- react-native-cookies (5.0.1):
- React-Core
- react-native-safe-area-context (3.1.9):
- react-native-safe-area-context (3.2.0):
- React-Core
- react-native-simple-toast (1.1.3):
- React-Core
- Toast (~> 4.0.0)
- react-native-webview (11.2.3):
- react-native-webview (11.2.4):
- React-Core
- React-RCTActionSheet (0.63.4):
- React-Core/RCTActionSheetHeaders (= 0.63.4)
Expand Down Expand Up @@ -307,17 +307,17 @@ PODS:
- React-jsi (= 0.63.4)
- RNCalendarEvents (2.2.0):
- React
- RNCAsyncStorage (1.13.4):
- RNCAsyncStorage (1.14.1):
- React-Core
- RNCMaskedView (0.1.10):
- React
- RNDateTimePicker (3.0.9):
- RNDateTimePicker (3.2.0):
- React-Core
- RNGestureHandler (1.9.0):
- RNGestureHandler (1.10.3):
- React-Core
- RNReanimated (1.13.2):
- React-Core
- RNScreens (2.17.1):
- RNScreens (2.18.1):
- React-Core
- RNSVG (12.1.0):
- React
Expand Down Expand Up @@ -509,9 +509,9 @@ SPEC CHECKSUMS:
React-jsiexecutor: 93bd528844ad21dc07aab1c67cb10abae6df6949
React-jsinspector: 58aef7155bc9a9683f5b60b35eccea8722a4f53a
react-native-cookies: ce50e42ace7cf0dd47769260ca5bbe8eee607e4e
react-native-safe-area-context: b6e0e284002381d2ff29fa4fff42b4d8282e3c94
react-native-safe-area-context: f0906bf8bc9835ac9a9d3f97e8bde2a997d8da79
react-native-simple-toast: bf002828cf816775a6809f7a9ec3907509bce11f
react-native-webview: 6520e3e7b4933de76b95ef542c8d7115cf45b68e
react-native-webview: d924ebd615d0d0c0e67dcfc3aa982ed313574b8d
React-RCTActionSheet: 89a0ca9f4a06c1f93c26067af074ccdce0f40336
React-RCTAnimation: 1bde3ecc0c104c55df246eda516e0deb03c4e49b
React-RCTBlob: a97d378b527740cc667e03ebfa183a75231ab0f0
Expand All @@ -523,12 +523,12 @@ SPEC CHECKSUMS:
React-RCTVibration: ae4f914cfe8de7d4de95ae1ea6cc8f6315d73d9d
ReactCommon: 73d79c7039f473b76db6ff7c6b159c478acbbb3b
RNCalendarEvents: 7e65eb4a94f53c1744d1e275f7fafcfaa619f7a3
RNCAsyncStorage: 44539979e1f234262d64d3ce86ec21cceb1b2c5e
RNCAsyncStorage: fe58eec522885718d6b297b7b658bf87d7ca557b
RNCMaskedView: 5a8ec07677aa885546a0d98da336457e2bea557f
RNDateTimePicker: 8a51a2216c307769e69ef827293d59549ab1ca23
RNGestureHandler: 9b7e605a741412e20e13c512738a31bd1611759b
RNDateTimePicker: 17593e41b6b1585aeb8ecbe1c1cbc30cba3d0b4b
RNGestureHandler: a479ebd5ed4221a810967000735517df0d2db211
RNReanimated: e03f7425cb7a38dcf1b644d680d1bfc91c3337ad
RNScreens: b6c9607e6fe47c1b6e2f1910d2acd46dd7ecea3a
RNScreens: f7ad633b2e0190b77b6a7aab7f914fad6f198d8d
RNSVG: ce9d996113475209013317e48b05c21ee988d42e
Toast: 91b396c56ee72a5790816f40d3a94dd357abc196
Yoga: 4bd86afe9883422a7c4028c00e34790f560923d6
Expand Down
2 changes: 1 addition & 1 deletion packages/app/package.json
Expand Up @@ -21,7 +21,7 @@
"@react-navigation/native": "5.9.3",
"@react-navigation/stack": "5.14.3",
"@skolplattformen/api-hooks": "2.0.0",
"@skolplattformen/embedded-api": "^2.0.0",
"@skolplattformen/embedded-api": "2.0.1",
"@ui-kitten/components": "5.0.0",
"@ui-kitten/eva-icons": "5.0.0",
"buffer": "6.0.3",
Expand Down
8 changes: 4 additions & 4 deletions packages/app/yarn.lock
Expand Up @@ -1518,10 +1518,10 @@
react-redux "^7.2.2"
redux "^4.0.5"

"@skolplattformen/embedded-api@^2.0.0":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@skolplattformen/embedded-api/-/embedded-api-2.0.0.tgz#45d12a5d844487f03d1dff96a5b9bd9a4752cff2"
integrity sha512-aZaNRCMV+Z6F7jiwY6aREAbhWtyDUIbvMnoqOIGMd1dbLyQZ2hUS75r67IYL4Kj0a1Jov2cdysrAqg6QsYfLXw==
"@skolplattformen/embedded-api@2.0.1":
version "2.0.1"
resolved "https://registry.yarnpkg.com/@skolplattformen/embedded-api/-/embedded-api-2.0.1.tgz#c1af44b59bc3ec7e6837497eac5bae9e82abc0cb"
integrity sha512-sLw9vafFx1sEpfpW0hoGoft1lphSlKhEDygP2DLxjvCKRxHIvbf2spyvEuaALa5mGidDk0xNgEDWoTZM0IQyhg==
dependencies:
"@types/he" "^1.1.1"
camelcase-keys "^6.2.2"
Expand Down

0 comments on commit 1c3d6f5

Please sign in to comment.