-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(procedures): implement gdpr document upload and confirmation
ref: MANAGER-15368 Signed-off-by: Omar ALKABOUSS MOUSSANA <[email protected]>
- Loading branch information
Omar ALKABOUSS MOUSSANA
committed
Oct 21, 2024
1 parent
94d9618
commit db9e8de
Showing
9 changed files
with
328 additions
and
46 deletions.
There are no files selected for viewing
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
47 changes: 47 additions & 0 deletions
47
packages/manager/apps/procedures/src/data/api/rgdp/rgdpApi.ts
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { FileWithError } from '@/components/FileInput/FileInputContainer'; | ||
import { GDPRFormValues } from '@/types/gdpr.type'; | ||
|
||
export type UploadLink = { | ||
link: string; | ||
method: string; | ||
headers: any; | ||
}; | ||
|
||
export type GetUploadDocumentsLinks = { | ||
numberOfDocuments: number; | ||
formData: Omit< | ||
GDPRFormValues, | ||
'idDocumentFront' | 'idDocumentBack' | 'otherDocuments' | ||
>; | ||
}; | ||
|
||
export type UploadDocuments = { | ||
fileLinks: UploadLink[]; | ||
files: FileWithError[]; | ||
}; | ||
|
||
export const getUploadDocumentsLinks = ({ | ||
formData, | ||
numberOfDocuments, | ||
}: GetUploadDocumentsLinks): Promise<UploadLink[]> => { | ||
return new Promise((res) => { | ||
setTimeout(() => { | ||
res([]); | ||
console.log('value', numberOfDocuments, formData); | ||
}, 500); | ||
}); | ||
}; | ||
|
||
export const uploadDocuments = (documents: UploadDocuments): Promise<void> => | ||
new Promise((res) => { | ||
setTimeout(() => { | ||
res(); | ||
}, 500); | ||
}); | ||
|
||
export const finalize = (): Promise<void> => | ||
new Promise((res) => { | ||
setTimeout(() => { | ||
res(); | ||
}, 500); | ||
}); |
51 changes: 51 additions & 0 deletions
51
packages/manager/apps/procedures/src/data/hooks/rgdp/useRGDP.tsx
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { useMutation } from '@tanstack/react-query'; | ||
import { | ||
UploadLink, | ||
getUploadDocumentsLinks, | ||
GetUploadDocumentsLinks, | ||
UploadDocuments, | ||
uploadDocuments, | ||
finalize, | ||
} from '@/data/api/rgdp/rgdpApi'; | ||
|
||
export const useRGDPSendForm = ({ | ||
onSuccess, | ||
onError, | ||
}: { | ||
onSuccess: (links: UploadLink[]) => void; | ||
onError: () => void; | ||
}) => | ||
useMutation({ | ||
mutationFn: (data: GetUploadDocumentsLinks) => | ||
getUploadDocumentsLinks(data), | ||
onSuccess: (links) => { | ||
onSuccess?.(links); | ||
}, | ||
onError: () => { | ||
onError?.(); | ||
}, | ||
}); | ||
|
||
export const useRGDPUploadDocuments = ({ | ||
onSuccess, | ||
onError, | ||
}: { | ||
onSuccess: () => void; | ||
onError: () => void; | ||
}) => | ||
useMutation({ | ||
mutationFn: async (documents: UploadDocuments) => { | ||
if (documents.fileLinks.length > 0) { | ||
await uploadDocuments(documents); | ||
} | ||
await finalize(); | ||
}, | ||
onSuccess: () => { | ||
onSuccess?.(); | ||
}, | ||
onError: () => { | ||
onError?.(); | ||
}, | ||
retry: 1, | ||
retryDelay: 3000, | ||
}); |
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
1 change: 0 additions & 1 deletion
1
...ges/manager/apps/procedures/src/pages/disableMFA/create/form/constants/form.constants.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.