From 3154f46fff16197794adc316b2c53eac6271d96c Mon Sep 17 00:00:00 2001 From: Ronnie Beggs <66931067+ronniebeggs@users.noreply.github.com> Date: Tue, 18 Jun 2024 22:06:54 -0700 Subject: [PATCH] [cases] error handling and feedback improvements (#91) * [feat] add loading feedback to qr code scanner button. * [feat] add loading feedback to AddCase screen button. * [feat] add loading feedback to confirm eligibility button. * [feat] loading feedback for ineligibility and opt out actions. * [feat] add loading feedback to file claim action. * [fix] restructure CaseScreen and CaseContext to prevent unnecessary reloads. * [refactor] integrate getCaseStatus with case context. * [refactor] case status -> claim status. * [feat] create basic loading spinner component. * [feat] replace loading text with spinner on all screens. * [feat] add light grey background as image placeholder. * [refactor] loading screen component. * [refactor] move add/remove case to case context. * [cleanup] add ios/ to gitignore. * [cleanup] use case context function for fetching context data. * [cleanup] remove unused import. * [wip][feat] configure timeout behavior for poor network connection settings. * [refactor] move resetAndPushToRoute to auth queries; cleanup. * [feat] create resetAndPushToHome that navigates to the home screen (relative to whether they're logged in or not). * [feat] create wip full stop error function; refactor screen loading component. * [cleanup] misc cleanup; update screen loading text for clarity. * [cleanup] update doc strings. * [feat] begin integrating error handler for case fetching functions. * [wip] continue adding error handling to case related screens. * [feat] add error handler to all case related screens. * [fix] case context code performance and clarity improvements. * [cleanup] misc refactoring and adding comments. * [fix] resolve missing caseData on FileClaim screen. --- .gitignore | 1 + package-lock.json | 83 +++++++++++ package.json | 1 + src/Components/CaseSummaryCard/styles.ts | 1 + src/Components/CaseSummaryContent/styles.ts | 1 + src/Components/FormsCard/FormsCard.tsx | 10 +- .../ScreenLoadingComponent.tsx | 42 ++++++ .../ScreenLoadingComponent/styles.ts | 10 ++ .../AllCases/CaseScreen/[caseUid].tsx | 59 ++++---- .../AllCases/CaseSummaryScreen/[caseUid].tsx | 13 +- .../ConfirmIneligibility/[caseUid].tsx | 33 +++-- .../AllCases/EligibilityForm/[caseUid].tsx | 59 +++++--- .../AllCases/EligibilityForm/styles.ts | 1 + .../AllCases/FileClaim/[caseUid].tsx | 52 ++++--- .../AllCases/Forms/[caseUid].tsx | 36 +++-- .../OptOut/ConfirmOptOut/[caseUid].tsx | 33 +++-- .../AllCases/OptOut/[caseUid].tsx | 17 ++- .../Updates/UpdateView/[updateUid].tsx | 9 +- .../AllCases/Updates/[caseUid].tsx | 15 +- .../(BottomTabNavigation)/AllCases/index.tsx | 9 +- .../QRCodeScanner/AddCase/[caseUid].tsx | 33 +++-- .../QRCodeScanner/index.tsx | 25 +++- src/app/index.tsx | 13 +- src/context/CaseContext.tsx | 137 +++++++++++++----- src/supabase/queries/auth.ts | 55 +++++++ src/supabase/queries/cases.ts | 112 ++------------ src/supabase/queries/forms.ts | 2 +- src/types/types.tsx | 12 +- 28 files changed, 567 insertions(+), 307 deletions(-) create mode 100644 src/Components/ScreenLoadingComponent/ScreenLoadingComponent.tsx create mode 100644 src/Components/ScreenLoadingComponent/styles.ts diff --git a/.gitignore b/.gitignore index f8532194..95316b4b 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ node_modules/ .expo/ dist/ web-build/ +ios/ # Native *.orig.* diff --git a/package-lock.json b/package-lock.json index 96bcbf48..c65001f2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -41,6 +41,7 @@ "react-native-elements": "^3.4.3", "react-native-gesture-handler": "~2.16.1", "react-native-otp-textinput": "^1.1.5", + "react-native-paper": "^5.12.3", "react-native-safe-area-context": "4.10.1", "react-native-screens": "3.31.1", "react-native-svg": "15.2.0", @@ -2104,6 +2105,26 @@ "node": ">=6.9.0" } }, + "node_modules/@callstack/react-theme-provider": { + "version": "3.0.9", + "resolved": "https://registry.npmjs.org/@callstack/react-theme-provider/-/react-theme-provider-3.0.9.tgz", + "integrity": "sha512-tTQ0uDSCL0ypeMa8T/E9wAZRGKWj8kXP7+6RYgPTfOPs9N07C9xM8P02GJ3feETap4Ux5S69D9nteq9mEj86NA==", + "dependencies": { + "deepmerge": "^3.2.0", + "hoist-non-react-statics": "^3.3.0" + }, + "peerDependencies": { + "react": ">=16.3.0" + } + }, + "node_modules/@callstack/react-theme-provider/node_modules/deepmerge": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-3.3.0.tgz", + "integrity": "sha512-GRQOafGHwMHpjPx9iCvTgpu9NojZ49q794EEL94JVEw6VaeA8XTUyBKvAkOOjBX9oJNiV6G3P+T+tihFjo2TqA==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/@colors/colors": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.5.0.tgz", @@ -20850,6 +20871,31 @@ "react-native": "^0.72.4" } }, + "node_modules/react-native-paper": { + "version": "5.12.3", + "resolved": "https://registry.npmjs.org/react-native-paper/-/react-native-paper-5.12.3.tgz", + "integrity": "sha512-nH1e1pGPE/aOE5YR2GRX7CfMHFA9cAfrAfgCtwL4amJPDZCoVjc5yt2VDiUE1rT+JUfk0qdICMP3UggxvjMgug==", + "dependencies": { + "@callstack/react-theme-provider": "^3.0.9", + "color": "^3.1.2", + "use-latest-callback": "^0.1.5" + }, + "peerDependencies": { + "react": "*", + "react-native": "*", + "react-native-safe-area-context": "*", + "react-native-vector-icons": "*" + } + }, + "node_modules/react-native-paper/node_modules/color": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/color/-/color-3.2.1.tgz", + "integrity": "sha512-aBl7dZI9ENN6fUGC7mWpMTPNHmWUSNan9tuWN6ahh5ZLNk9baLJOnSMlrQkHcrfFgz2/RigjUVAjdx36VcemKA==", + "dependencies": { + "color-convert": "^1.9.3", + "color-string": "^1.6.0" + } + }, "node_modules/react-native-ratings": { "version": "8.0.4", "resolved": "https://registry.npmjs.org/react-native-ratings/-/react-native-ratings-8.0.4.tgz", @@ -27621,6 +27667,22 @@ "to-fast-properties": "^2.0.0" } }, + "@callstack/react-theme-provider": { + "version": "3.0.9", + "resolved": "https://registry.npmjs.org/@callstack/react-theme-provider/-/react-theme-provider-3.0.9.tgz", + "integrity": "sha512-tTQ0uDSCL0ypeMa8T/E9wAZRGKWj8kXP7+6RYgPTfOPs9N07C9xM8P02GJ3feETap4Ux5S69D9nteq9mEj86NA==", + "requires": { + "deepmerge": "^3.2.0", + "hoist-non-react-statics": "^3.3.0" + }, + "dependencies": { + "deepmerge": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-3.3.0.tgz", + "integrity": "sha512-GRQOafGHwMHpjPx9iCvTgpu9NojZ49q794EEL94JVEw6VaeA8XTUyBKvAkOOjBX9oJNiV6G3P+T+tihFjo2TqA==" + } + } + }, "@colors/colors": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.5.0.tgz", @@ -41602,6 +41664,27 @@ "react": "^18.2.0" } }, + "react-native-paper": { + "version": "5.12.3", + "resolved": "https://registry.npmjs.org/react-native-paper/-/react-native-paper-5.12.3.tgz", + "integrity": "sha512-nH1e1pGPE/aOE5YR2GRX7CfMHFA9cAfrAfgCtwL4amJPDZCoVjc5yt2VDiUE1rT+JUfk0qdICMP3UggxvjMgug==", + "requires": { + "@callstack/react-theme-provider": "^3.0.9", + "color": "^3.1.2", + "use-latest-callback": "^0.1.5" + }, + "dependencies": { + "color": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/color/-/color-3.2.1.tgz", + "integrity": "sha512-aBl7dZI9ENN6fUGC7mWpMTPNHmWUSNan9tuWN6ahh5ZLNk9baLJOnSMlrQkHcrfFgz2/RigjUVAjdx36VcemKA==", + "requires": { + "color-convert": "^1.9.3", + "color-string": "^1.6.0" + } + } + } + }, "react-native-ratings": { "version": "8.0.4", "resolved": "https://registry.npmjs.org/react-native-ratings/-/react-native-ratings-8.0.4.tgz", diff --git a/package.json b/package.json index e3b88a35..bb81779d 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "react-native-elements": "^3.4.3", "react-native-gesture-handler": "~2.16.1", "react-native-otp-textinput": "^1.1.5", + "react-native-paper": "^5.12.3", "react-native-safe-area-context": "4.10.1", "react-native-screens": "3.31.1", "react-native-svg": "15.2.0", diff --git a/src/Components/CaseSummaryCard/styles.ts b/src/Components/CaseSummaryCard/styles.ts index 55d0a162..ecb8b9a2 100644 --- a/src/Components/CaseSummaryCard/styles.ts +++ b/src/Components/CaseSummaryCard/styles.ts @@ -14,6 +14,7 @@ export default StyleSheet.create({ justifyContent: 'space-between', borderTopRightRadius: 4, borderTopLeftRadius: 4, + backgroundColor: colors.lightGrey, }, infoContainer: { flexDirection: 'column', diff --git a/src/Components/CaseSummaryContent/styles.ts b/src/Components/CaseSummaryContent/styles.ts index a157d5dc..97c5278a 100644 --- a/src/Components/CaseSummaryContent/styles.ts +++ b/src/Components/CaseSummaryContent/styles.ts @@ -18,6 +18,7 @@ export default StyleSheet.create({ borderRadius: 5, marginTop: 30, marginBottom: 20, + backgroundColor: colors.lightGrey, }, summaryContainer: { width: '100%', diff --git a/src/Components/FormsCard/FormsCard.tsx b/src/Components/FormsCard/FormsCard.tsx index 9289189e..7d4b6687 100644 --- a/src/Components/FormsCard/FormsCard.tsx +++ b/src/Components/FormsCard/FormsCard.tsx @@ -14,13 +14,9 @@ export default function FormsCard(caseData: Case) { const [featuredForm, setFeaturedForm] = useState