Skip to content

Commit

Permalink
fix: no corvee today (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
sverben authored Jun 13, 2024
1 parent 4b72681 commit 38e421c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
4 changes: 2 additions & 2 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"**/*"
],
"ios": {
"buildNumber": "2",
"buildNumber": "3",
"userInterfaceStyle": "automatic",
"supportsTablet": false,
"bundleIdentifier": "nl.djoamersfoort.djo",
Expand Down Expand Up @@ -44,7 +44,7 @@
}
},
"googleServicesFile": "./google-services.json",
"versionCode": 10
"versionCode": 11
},
"web": {
"favicon": "./assets/favicon.png"
Expand Down
21 changes: 17 additions & 4 deletions src/screens/corvee/corvee.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useAtom, useSetAtom } from "jotai";
import { getSlots, membersAtom, slotsAtom } from "../../stores/register";
import AuthContext, { Authed } from "../../auth";
import { RefreshControl, ScrollView, StyleSheet, View } from "react-native";
import { ActivityIndicator, Appbar } from "react-native-paper";
import { ActivityIndicator, Appbar, Icon, Text } from "react-native-paper";
import { CorveeState, getStatus, stateAtom } from "../../stores/corvee";
import Create from "../../components/corvee/Create";
import Selected from "../../components/corvee/Selected";
Expand Down Expand Up @@ -62,14 +62,19 @@ export default function CorveeScreen() {
}
>
<View style={styles.content}>
{state ? (
{state && !("error" in state) && (
<>
{state.current.length === 0 && <Create />}
{state.current.length > 0 && <Selected />}
</>
) : (
<ActivityIndicator animating={true} />
)}
{state && "error" in state && (
<View style={styles.error}>
<Icon size={75} source={"emoticon-happy"} />
<Text variant={"titleMedium"}>{state.error}</Text>
</View>
)}
{!state && <ActivityIndicator animating={true} />}
</View>
</ScrollView>
</>
Expand All @@ -83,4 +88,12 @@ const styles = StyleSheet.create({
padding: 10,
gap: 10,
},
error: {
display: "flex",
alignItems: "center",
justifyContent: "center",
position: "static",
flex: 1,
gap: 20,
},
});
11 changes: 9 additions & 2 deletions src/stores/corvee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ export interface CorveeState {
pod: string;
}

export const stateAtom = atom<CorveeState | null | undefined>(null);
export interface CorveeError {
error: string;
ok: false;
}

export const stateAtom = atom<CorveeState | CorveeError | null | undefined>(
null,
);

export async function getStatus(token: string) {
const res = await fetch(`${CORVEE}/api/v1/status`, {
Expand All @@ -23,5 +30,5 @@ export async function getStatus(token: string) {
},
});

return (await res.json()) as CorveeState;
return (await res.json()) as CorveeState | CorveeError;
}

0 comments on commit 38e421c

Please sign in to comment.