Skip to content

Commit

Permalink
Merge branch 'main' into stephanie/deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
ronniebeggs committed Aug 2, 2024
2 parents 93cd464 + 8b4416b commit 1bed41c
Show file tree
Hide file tree
Showing 13 changed files with 14,235 additions and 623 deletions.
14,714 changes: 14,172 additions & 542 deletions package-lock.json

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"web": "expo start --web",
"prepare": "husky install",
"lint": "eslint .",
"format": "prettier --check .",
"prettier": "prettier . --check",
"ts:check": "tsc"
},
"dependencies": {
Expand All @@ -23,30 +23,31 @@
"auth": "^1.0.2",
"babel-preset-expo": "~11.0.0",
"cliui": "^7.0.4",
"expo": "~51.0.14",
"expo": "~51.0.24",
"expo-auth-session": "~5.5.2",
"expo-barcode-scanner": "~13.0.1",
"expo-camera": "~15.0.11",
"expo-camera": "~15.0.14",
"expo-checkbox": "~3.0.0",
"expo-constants": "~16.0.2",
"expo-device": "~6.0.2",
"expo-image": "~1.12.12",
"expo-image": "~1.12.13",
"expo-linking": "~6.3.1",
"expo-notifications": "~0.28.9",
"expo-router": "~3.5.16",
"expo-notifications": "~0.28.14",
"expo-router": "~3.5.20",
"expo-status-bar": "~1.12.1",
"linking": "^0.1.0-beta.5",
"lodash": "^4.17.21",
"metro-react-native-babel-transformer": "^0.77.0",
"prettier": "^3.3.3",
"react": "18.2.0",
"react-dom": "^18.2.0",
"react-native": "0.74.2",
"react-native": "0.74.3",
"react-native-dotenv": "^3.4.9",
"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-safe-area-context": "4.10.5",
"react-native-screens": "3.31.1",
"react-native-svg": "15.2.0",
"react-native-toast-message": "^2.2.0",
Expand All @@ -68,12 +69,11 @@
"eslint": "^8.51.0",
"eslint-config-universe": "^12.0.0",
"husky": "^8.0.3",
"prettier": "^3.0.3",
"react-native-svg-transformer": "^1.4.0",
"typescript": "~5.3.3"
},
"overrides": {
"react-native": "0.74.2"
"react-native": "0.74.3"
},
"private": true,
"resolutions": {
Expand Down
6 changes: 5 additions & 1 deletion src/Components/CaseCard/CaseCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ function CaseCard(caseData: Case) {
</Text>

<View style={[styles.statusContainer, statusColor.background]}>
<Text style={[styles.statusText, statusColor.text]}>
<Text
style={[styles.statusText, statusColor.text]}
numberOfLines={1}
ellipsizeMode="tail"
>
{caseData.caseStatus}
</Text>
</View>
Expand Down
4 changes: 2 additions & 2 deletions src/Components/CaseCard/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default StyleSheet.create({
paddingVertical: 20,
},
infoContainer: {
width: '62%',
width: '56%',
flexDirection: 'column',
justifyContent: 'space-between',
paddingVertical: 7,
Expand All @@ -28,7 +28,7 @@ export default StyleSheet.create({
},
statusContainer: {
height: 27,
width: 129,
paddingHorizontal: 3,
borderRadius: 5,
alignItems: 'center',
justifyContent: 'center',
Expand Down
8 changes: 7 additions & 1 deletion src/Components/CaseStatusBar/CaseStatusBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ export default function CaseStatusBar({ status }: CaseStatusBarProps) {
<View style={[styles.container, shawdowStyles.shadowBorder]}>
<Text style={styles.statusText}>Case Status:</Text>
<View style={[styles.statusContainer, statusColor.background]}>
<Text style={[styles.statusTextColor, statusColor.text]}>{status}</Text>
<Text
style={[styles.statusTextColor, statusColor.text]}
numberOfLines={1}
ellipsizeMode="tail"
>
{status}
</Text>
</View>
</View>
);
Expand Down
1 change: 1 addition & 0 deletions src/Components/CaseStatusBar/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default StyleSheet.create({

borderWidth: 0.3,
borderRadius: 5,
paddingHorizontal: 3,
},
statusText: {
fontSize: 18,
Expand Down
2 changes: 1 addition & 1 deletion src/Components/UpdateItem/UpdateItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function UpdateItem(updateData: Update) {
</Text>
</View>
<Text style={styles.bottomText}>
{formatDate(updateData.date)}{updateData.lawFirm}
{formatDate(updateData.date)}{updateData.sender}
</Text>
</View>
</TouchableOpacity>
Expand Down
22 changes: 19 additions & 3 deletions src/app/(Authentication)/SignUp/Password/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useSession } from '../../../../context/AuthContext';
import { fonts } from '../../../../styles/fonts';
import { device } from '../../../../styles/global';
import { input } from '../../../../styles/input';
import { emailExists } from '../../../../supabase/queries/auth';

export default function SignUpScreen() {
const { fullName } = useLocalSearchParams() as unknown as {
Expand Down Expand Up @@ -47,8 +48,9 @@ export default function SignUpScreen() {
setConfirmPassword(text);
};

const validateEmail = (): boolean => {
const validateEmailString = (): boolean => {
try {
// email string validation
const emailSchema = z.string().email();
emailSchema.parse(email);
setErrorExists(false);
Expand All @@ -60,6 +62,16 @@ export default function SignUpScreen() {
}
};

const validateDuplicateEmail = async (): Promise<boolean> => {
if (await emailExists(email)) {
setErrorExists(true);
setErrorMessage('An account with this email already exists!');
return false;
}
setErrorExists(false);
return true;
};

const validatePassword = (): boolean => {
const lengthRegex = /^.{6,}$/;
if (!lengthRegex.test(password)) {
Expand All @@ -83,10 +95,14 @@ export default function SignUpScreen() {

const handleSubmit = async () => {
setQueryLoading(true);
if (validateEmail() && validateConfirmPassword() && validatePassword()) {
if (
validateEmailString() &&
(await validateDuplicateEmail()) &&
validateConfirmPassword() &&
validatePassword()
) {
const error = await sendSignUpOtp(email, {
fullName,
password,
streetAddress,
city,
state,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ export default function UpdateView() {
</View>
<View style={styles.inLineSubInfo}>
<Text style={[styles.subText, styles.lawFirmText]}>
{update.lawFirm}
{update.sender}
</Text>
<Text style={[styles.subText, styles.dateText]}>
{' '}
{formatDate(update.date)}
</Text>
</View>
<Text style={[fonts.body, styles.bodyText]}>
{update.summary}
{update.description}
</Text>
</View>
</ScrollView>
Expand Down
48 changes: 0 additions & 48 deletions src/app/(BottomTabNavigation)/AllCases/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// import * as Linking from 'expo-linking';
import * as Notifications from 'expo-notifications';
import { router } from 'expo-router';
import React, { useEffect, useRef } from 'react';
Expand All @@ -13,11 +12,6 @@ import { device } from '../../../styles/global';

import 'react-native-url-polyfill/auto';

// enum linkingEvents {
// ADD_CASE = 'addCase',
// NOTIFICATION = 'notification',
// }

Notifications.setNotificationHandler({
handleNotification: async () => ({
shouldShowAlert: true,
Expand All @@ -31,41 +25,6 @@ function CasesScreen() {

const { allCases, loading } = useCaseContext();

// const [url, setUrl] = useState<Linking.ParsedURL | null>(null);

// function urlRedirect(parsedUrl: Linking.ParsedURL) {
// if (!parsedUrl) return;
// // parse query params and determine routing
// const { queryParams } = parsedUrl;
// // determine routing from the event variable
// if (queryParams?.event) {
// const event = queryParams.event.toString();
// // TODO: determine a way to validate required parameters
// // TODO: prevent users from routing to a case they're already involved in
// if (event === linkingEvents.ADD_CASE)
// router.push({
// pathname: `/AllCases/AddCase/${queryParams.caseUid}`,
// });
// }
// }

// function handleDeepLink(event: any) {
// const parsedUrl = Linking.parse(event.url);
// if (parsedUrl) {
// setUrl(parsedUrl);
// urlRedirect(parsedUrl);
// }
// }

// async function getInitialUrl() {
// const initialUrl = await Linking.getInitialURL();
// if (initialUrl) {
// const parsed = Linking.parse(initialUrl);
// setUrl(parsed);
// urlRedirect(parsed);
// }
// }

function routeUserToUpdate(response: Notifications.NotificationResponse) {
const updateId = response.notification.request.content.data.updateId;
const caseId = response.notification.request.content.data.caseId;
Expand All @@ -75,13 +34,6 @@ function CasesScreen() {
}

useEffect(() => {
// // will detect any incoming link requests, assuming the app is already open
// Linking.addEventListener('url', handleDeepLink);
// if (!url) {
// // if the link opened the app, must route to the initial incoming route
// getInitialUrl();
// }

// triggered when a user presses on the notification
responseListener.current =
Notifications.addNotificationResponseReceivedListener(response =>
Expand Down
13 changes: 7 additions & 6 deletions src/supabase/queries/updates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ export async function fetchAllUpdates(caseUid: CaseUid): Promise<Update[]> {
const { data } = await supabase
.from('updates')
.select()
.eq('caseUUID', caseUid);
.eq('caseId', caseUid);

if (!data) {
throw new Error(`no updates found for the given case: ${caseUid}`);
return [];
}
// return a list of properly formatted `Updates`s
const unsortedUpdates = await Promise.all(
Expand All @@ -40,13 +40,14 @@ export async function fetchAllUpdates(caseUid: CaseUid): Promise<Update[]> {
export function formatUpdate(item: any): Update {
const updateData: Update = {
updateUid: item.updateId,
caseUid: item.caseUUID,
caseUid: item.caseId,
title: item.title,
blurb: item.blurb,
category: item.category,
date: item.date,
summary: item.summary,
lawFirm: item.lawFirm,
description: item.description,
notificationTitle: item.notification_title,
notificaitonBody: item.notifcation_body,
sender: item.sender,
};
return updateData;
}
Expand Down
10 changes: 6 additions & 4 deletions src/types/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,13 @@ export const userInstance: User = {
export interface Update {
updateUid: UpdateUid;
caseUid: CaseUid;
date: Date;
title: string;
blurb: string;
category: string;
date: Date;
summary: string;
lawFirm: string;
description: string;
notificationTitle: string;
notificaitonBody: string;
sender: string;
}

export enum GreenStatusOptions {
Expand All @@ -101,6 +102,7 @@ export enum GreenStatusOptions {

export enum YellowStatusOptions {
'Pending',
'Opt-Out Deadline Approaching',
}

export enum RedStatusOptions {
Expand Down
6 changes: 3 additions & 3 deletions supabase/functions/push/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
Deno.serve(async req => {
// fetch the notifcation request from the supabase edge function
const { update, expoPushToken, category, updateId, caseId } =
const { expoPushToken, title, body, updateId, caseId } =
await req.json();

const res = await fetch('https://exp.host/--/api/v2/push/send', {
Expand All @@ -21,8 +21,8 @@ Deno.serve(async req => {
body: JSON.stringify({
to: expoPushToken,
sound: 'default',
title: category,
body: update,
title: title,
body: body,
data: { updateId: updateId, caseId: caseId },
}),
}).then(res => res.json());
Expand Down

0 comments on commit 1bed41c

Please sign in to comment.