Skip to content

Commit

Permalink
[cleanup] create parseCase query helper function.
Browse files Browse the repository at this point in the history
  • Loading branch information
ronniebeggs committed Oct 19, 2023
1 parent 54b980a commit 6179b5e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

# dependencies
node_modules/
package-lock.json

# Expo
.expo/
Expand Down
36 changes: 22 additions & 14 deletions src/supabase/queries/cases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,27 +48,35 @@ export async function getCasesByIds(caseIds: CaseUid[]): Promise<Case[]> {
}

// cast raw sql data as CaseCardProps data type
return data.map(item => {
const formattedCase: Case = {
id: item.id,
approved: item.approved,
title: item.title,
summary: item.summary,
image: item.image,
caseSite: item.caseSite,
classClaimLink: item.classClaimLink,
individualClaimLink: item.individualClaimLink,
caseStatus: item.caseStatus,
};
return formattedCase;
});
return data.map(item => parseCase(item));
} catch (error) {
// eslint-disable-next-line no-console
console.warn('(getCasesByIds)', error);
throw error;
}
}

/**
* Parse supabase case query and return Case object.
*
* @param item Case query result
* @returns `Case` object
*/
function parseCase(item: any): Case {
const formattedCase: Case = {
id: item.id,
approved: item.approved,
title: item.title,
summary: item.summary,
image: item.image,
caseSite: item.caseSite,
classClaimLink: item.classClaimLink,
individualClaimLink: item.individualClaimLink,
caseStatus: item.caseStatus,
};
return formattedCase;
}

export async function addCase() {
const dummyCase = {
approved: false,
Expand Down

0 comments on commit 6179b5e

Please sign in to comment.