From 38e421c42ab299b7e4f7ca326ea95b41f7051835 Mon Sep 17 00:00:00 2001
From: Sverre <59171289+sverben@users.noreply.github.com>
Date: Thu, 13 Jun 2024 12:36:59 +0200
Subject: [PATCH] fix: no corvee today (#10)
---
app.json | 4 ++--
src/screens/corvee/corvee.tsx | 21 +++++++++++++++++----
src/stores/corvee.ts | 11 +++++++++--
3 files changed, 28 insertions(+), 8 deletions(-)
diff --git a/app.json b/app.json
index 1f05a5a..750c82d 100644
--- a/app.json
+++ b/app.json
@@ -16,7 +16,7 @@
"**/*"
],
"ios": {
- "buildNumber": "2",
+ "buildNumber": "3",
"userInterfaceStyle": "automatic",
"supportsTablet": false,
"bundleIdentifier": "nl.djoamersfoort.djo",
@@ -44,7 +44,7 @@
}
},
"googleServicesFile": "./google-services.json",
- "versionCode": 10
+ "versionCode": 11
},
"web": {
"favicon": "./assets/favicon.png"
diff --git a/src/screens/corvee/corvee.tsx b/src/screens/corvee/corvee.tsx
index ae6407f..c4738c2 100644
--- a/src/screens/corvee/corvee.tsx
+++ b/src/screens/corvee/corvee.tsx
@@ -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";
@@ -62,14 +62,19 @@ export default function CorveeScreen() {
}
>
- {state ? (
+ {state && !("error" in state) && (
<>
{state.current.length === 0 && }
{state.current.length > 0 && }
>
- ) : (
-
)}
+ {state && "error" in state && (
+
+
+ {state.error}
+
+ )}
+ {!state && }
>
@@ -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,
+ },
});
diff --git a/src/stores/corvee.ts b/src/stores/corvee.ts
index d9271b6..f3d7dcb 100644
--- a/src/stores/corvee.ts
+++ b/src/stores/corvee.ts
@@ -14,7 +14,14 @@ export interface CorveeState {
pod: string;
}
-export const stateAtom = atom(null);
+export interface CorveeError {
+ error: string;
+ ok: false;
+}
+
+export const stateAtom = atom(
+ null,
+);
export async function getStatus(token: string) {
const res = await fetch(`${CORVEE}/api/v1/status`, {
@@ -23,5 +30,5 @@ export async function getStatus(token: string) {
},
});
- return (await res.json()) as CorveeState;
+ return (await res.json()) as CorveeState | CorveeError;
}