-
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.
fix(procedures): gdpr fix wording & api call with mock
ref: MANAGER-15368 Signed-off-by: Omar ALKABOUSS MOUSSANA <[email protected]>
- Loading branch information
Omar ALKABOUSS MOUSSANA
committed
Oct 28, 2024
1 parent
98fb4e6
commit 63dde5e
Showing
6 changed files
with
97 additions
and
65 deletions.
There are no files selected for viewing
56 changes: 40 additions & 16 deletions
56
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 |
---|---|---|
@@ -1,47 +1,71 @@ | ||
import { v6 } from '@ovh-ux/manager-core-api'; | ||
import axios from 'axios'; | ||
import { FileWithError } from '@/components/FileInput/FileInputContainer'; | ||
import { GDPRFormValues } from '@/types/gdpr.type'; | ||
import { GDPRValues } from '@/types/gdpr.type'; | ||
|
||
export type UploadLink = { | ||
link: string; | ||
method: string; | ||
headers: any; | ||
}; | ||
|
||
export type GetUploadDocumentsLinks = { | ||
numberOfDocuments: number; | ||
formData: Omit< | ||
GDPRFormValues, | ||
'idDocumentFront' | 'idDocumentBack' | 'otherDocuments' | ||
>; | ||
type TicketUploadInfo = { | ||
ticketId: string; | ||
uploadLinks: UploadLink[]; | ||
}; | ||
|
||
export type UploadDocuments = { | ||
fileLinks: UploadLink[]; | ||
files: FileWithError[]; | ||
}; | ||
|
||
export const getUploadDocumentsLinks = ({ | ||
formData, | ||
numberOfDocuments, | ||
}: GetUploadDocumentsLinks): Promise<UploadLink[]> => { | ||
const s3AxiosInstance = axios.create({}); | ||
|
||
export const getUploadDocumentsLinks = ( | ||
data: GDPRValues, | ||
): Promise<UploadLink[]> => { | ||
// TODO: remove the mock in the ticket MANAGER-15473 | ||
// return v6.post<TicketUploadInfo>('/me/procedure/GDPR', data).then(({ data }) => data.uploadLinks); | ||
return new Promise((res) => { | ||
setTimeout(() => { | ||
res([]); | ||
console.log('value', numberOfDocuments, formData); | ||
console.log('value', data); | ||
}, 500); | ||
}); | ||
}; | ||
|
||
export const uploadDocuments = (documents: UploadDocuments): Promise<void> => | ||
new Promise((res) => { | ||
const uploadDocument: ( | ||
link: UploadLink, | ||
file: FileWithError, | ||
) => Promise<void> = (link, file) => { | ||
// TODO: remove the mock in the ticket MANAGER-15473 | ||
// return s3AxiosInstance.put(link.link, file, { | ||
// headers: { | ||
// ...link.headers, | ||
// }, | ||
// }); | ||
return new Promise((res) => { | ||
setTimeout(() => { | ||
res(); | ||
}, 500); | ||
}); | ||
}; | ||
|
||
export const finalize = (): Promise<void> => | ||
new Promise((res) => { | ||
export const uploadDocuments = ({ | ||
fileLinks, | ||
files, | ||
}: UploadDocuments): Promise<void[]> => { | ||
return Promise.all( | ||
fileLinks.map((link, index) => uploadDocument(link, files[index])), | ||
); | ||
}; | ||
|
||
export const finalize = (): Promise<void> => { | ||
// TODO: remove the mock in the ticket MANAGER-15473 | ||
// return v6.post('/me/procedure/GDPR/finalize').then(({ data }) => data); | ||
return new Promise((res) => { | ||
setTimeout(() => { | ||
res(); | ||
}, 500); | ||
}); | ||
}; |
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