-
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 18, 2024
1 parent
94d9618
commit f07ed08
Showing
9 changed files
with
308 additions
and
42 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
34 changes: 34 additions & 0 deletions
34
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,34 @@ | ||
import { FileWithError } from '@/components/FileInput/FileInputContainer'; | ||
import { GDPRFormValues } from '@/types/gdpr.type'; | ||
|
||
export type UploadLink = { | ||
link: string; | ||
method: string; | ||
headers: any; | ||
}; | ||
|
||
export type FormValue = { | ||
fileLinks: UploadLink[]; | ||
formData: Omit< | ||
GDPRFormValues, | ||
'idDocumentFront' | 'idDocumentBack' | 'otherDocuments' | ||
>; | ||
files: FileWithError[]; | ||
}; | ||
export const sendForm = (value: FormValue): Promise<void> => | ||
new Promise((res) => { | ||
setTimeout(() => { | ||
res(); | ||
}, 500); | ||
}); | ||
|
||
export const getUploadDocumentsLinks = ( | ||
numberOfDocuments: number, | ||
): Promise<UploadLink[]> => { | ||
return new Promise((res) => { | ||
setTimeout(() => { | ||
res([]); | ||
console.log('value', numberOfDocuments); | ||
}, 500); | ||
}); | ||
}; |
46 changes: 46 additions & 0 deletions
46
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,46 @@ | ||
import { useMutation } from '@tanstack/react-query'; | ||
import { | ||
sendForm, | ||
UploadLink, | ||
getUploadDocumentsLinks, | ||
FormValue, | ||
} from '@/data/api/rgdp/rgdpApi'; | ||
|
||
export const useRGDPUploadLinks = ({ | ||
onSuccess, | ||
onError, | ||
}: { | ||
onSuccess: (links: UploadLink[]) => void; | ||
onError: () => void; | ||
}) => | ||
useMutation({ | ||
mutationFn: (numberOfDocuments: number) => | ||
getUploadDocumentsLinks(numberOfDocuments), | ||
onSuccess: (links) => { | ||
onSuccess?.(links); | ||
}, | ||
onError: () => { | ||
onError?.(); | ||
}, | ||
}); | ||
|
||
export const useRGDPSendForm = ({ | ||
onSuccess, | ||
onError, | ||
}: { | ||
onSuccess: () => void; | ||
onError: () => void; | ||
}) => | ||
useMutation({ | ||
mutationFn: (value: FormValue) => { | ||
return sendForm(value); | ||
}, | ||
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.