first working version!

This commit is contained in:
Christian Landgren 2020-12-21 19:55:05 +01:00
parent 0e1131c829
commit bc5943417b
3 changed files with 21 additions and 10 deletions

View File

@ -40,12 +40,14 @@ export const Children = ({navigation}) => {
//TODO: lazy load these
const fullChildren = await Promise.all(children.map(async child => ({
...child,
//news: await api.getNews(),
calendar: await api.getCalendar(child.id),
//schedule: await api.getSchedule(),
//menu: await api.getMenu(),
//notifications: await api.getNotifications(),
news: await api.getNews(child).then(({items}) => items),
calendar: await api.getCalendar(child),
classmates: await api.getClassmates(child),
schedule: await api.getSchedule(child, moment().startOf('day'), moment().add(7,'days').endOf('day')),
menu: await api.getMenu(child),
notifications: await api.getNotifications(child),
})))
console.log('full', fullChildren)
setChildren(fullChildren)
setSavedChildren(JSON.stringify(savedChildren))
@ -112,7 +114,7 @@ export const ChildrenView = ({ navigation, children }) => {
status='control'
size='small'
accessoryLeft={CalendarIcon}>
{`${(info.item.notifications || []).filter(c => moment(c.startDate).isSame('day') ).length}`}
{`${(info.item.notifications || []).filter(c => moment(c.startDate).isSame('day') ).length} idag`}
</Button>
<Button
style={styles.iconButton}

View File

@ -18,12 +18,19 @@ export const Login = ({ navigation }) => {
const [error, setError] = React.useState(null)
const [hasBankId, setHasBankId] = React.useState(false)
const [socialSecurityNumber, setSocialSecurityNumber, clearSocialSecurityNumber] = useAsyncStorage('@socialSecurityNumber')
const [cookie, setCookie, clearCookie] = useAsyncStorage('@cookie')
useEffect(() => {
setValid(Personnummer.valid(socialSecurityNumber))
const url = Platform.OS == 'ios' ? 'https://app.bankid.com/' : 'bankid:///'
setHasBankId(Linking.canOpenURL(url))
}, [socialSecurityNumber])
if (cookie) {
console.log('cookie', cookie)
api.setSessionCookie(cookie)
setLoggedIn(true)
navigateToChildren()
}
}, [socialSecurityNumber, cookie])
useEffect(() => {
setArgument(funArguments[Math.floor(Math.random() * funArguments.length)])
@ -81,6 +88,7 @@ export const Login = ({ navigation }) => {
loginStatus.on("OK", async () => {
setLoggedIn(true)
navigateToChildren()
setCookie(api.session.headers.Coookie)
setVisible(false)
})
}
@ -88,6 +96,7 @@ export const Login = ({ navigation }) => {
const logout = async () => {
setVisible(false)
setLoggedIn(false)
clearCookie()
api.logout()
}

View File

@ -291,7 +291,7 @@
TestTargetID = 13B07F861A680F5B00A75B9A;
};
13B07F861A680F5B00A75B9A = {
DevelopmentTeam = 59292HY5Q8;
DevelopmentTeam = BSE2J6442R;
LastSwiftMigration = 1120;
};
2D02E47A1E0B4A5D006451C7 = {
@ -630,7 +630,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 15;
DEVELOPMENT_TEAM = 59292HY5Q8;
DEVELOPMENT_TEAM = BSE2J6442R;
ENABLE_BITCODE = NO;
GCC_PREPROCESSOR_DEFINITIONS = (
"$(inherited)",
@ -659,7 +659,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 15;
DEVELOPMENT_TEAM = 59292HY5Q8;
DEVELOPMENT_TEAM = BSE2J6442R;
INFOPLIST_FILE = Skolplattformen/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 0.0.1;