-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feat] complete form fetching from supabase with hardcoded caseUid.
- Loading branch information
1 parent
c50a6bd
commit 554ca2c
Showing
8 changed files
with
87 additions
and
139 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,28 @@ | ||
import { | ||
getFormObjects, | ||
getFormUrl, | ||
// getFormsByCaseUid, | ||
getPartialForms, | ||
getPublicFormUrl, | ||
} from '../../../../supabase/queries/cases'; | ||
import { CaseUid, Form } from '../../../../types/types'; | ||
|
||
/** WIP: fetch and return a list of pdf links associated with a specific case */ | ||
/** | ||
* Fetch an array of `Form` objects associated with a given `caseUid`. | ||
* | ||
* @param caseUid uid for the target Case | ||
* @returns array of `Form` objects | ||
*/ | ||
export async function fetchFormObjects(caseUid: CaseUid): Promise<Form[]> { | ||
const formMetaDataList = await getFormObjects(caseUid); | ||
const partialFormsList = await getPartialForms(caseUid); | ||
|
||
// console.log(formMetaDataList); | ||
|
||
const forms: Form[] = []; | ||
|
||
formMetaDataList.map(async item => { | ||
const formUrl = await getFormUrl(item.filename); | ||
const form: Form = { | ||
...item, | ||
formUrl, | ||
}; | ||
console.log(form); | ||
forms.push(form); | ||
}); | ||
|
||
Promise.all(forms).then(forms => console.log(forms)); | ||
// console.log('formsPromise: ' + formsPromise); | ||
|
||
return forms; | ||
return await Promise.all( | ||
partialFormsList.map(async partialForm => { | ||
const formUrl = await getPublicFormUrl( | ||
`${caseUid}/${partialForm.filename}`, | ||
); | ||
const form: Form = { | ||
...partialForm, | ||
formUrl, | ||
}; | ||
return form; | ||
}), | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters