Fixed
This commit is contained in:
parent
f5195f5c0a
commit
aae8463185
36
src/front/Api/LeCoffreApi/Customer/OfficeRib/OfficeRib.ts
Normal file
36
src/front/Api/LeCoffreApi/Customer/OfficeRib/OfficeRib.ts
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import BaseNotary from "../BaseCustomer";
|
||||||
|
|
||||||
|
// TODO Type get query params -> Where + inclue + orderby
|
||||||
|
export interface IGetFilesparams {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Type getbyuid query params
|
||||||
|
|
||||||
|
export type IPutFilesParams = {};
|
||||||
|
|
||||||
|
export interface IPostFilesParams {}
|
||||||
|
|
||||||
|
export default class OfficeRib extends BaseNotary {
|
||||||
|
private static instance: OfficeRib;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/office");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
return (this.instance ??= new this());
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getRibStream(uid: string) {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}/rib`));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<any>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
import BaseNotary from "../../Notary/BaseNotary";
|
import BaseNotary from "../BaseNotary";
|
||||||
|
|
||||||
// TODO Type get query params -> Where + inclue + orderby
|
// TODO Type get query params -> Where + inclue + orderby
|
||||||
export interface IGetFilesparams {
|
export interface IGetFilesparams {
|
||||||
@ -12,9 +12,9 @@ export type IPutFilesParams = {};
|
|||||||
|
|
||||||
export interface IPostFilesParams {}
|
export interface IPostFilesParams {}
|
||||||
|
|
||||||
export default class Bucket extends BaseNotary {
|
export default class OfficeRib extends BaseNotary {
|
||||||
private static instance: Bucket;
|
private static instance: OfficeRib;
|
||||||
private readonly baseURl = this.namespaceUrl.concat("/bucket");
|
private readonly baseURl = this.namespaceUrl.concat("/office/rib");
|
||||||
|
|
||||||
private constructor() {
|
private constructor() {
|
||||||
super();
|
super();
|
||||||
@ -24,8 +24,8 @@ export default class Bucket extends BaseNotary {
|
|||||||
return (this.instance ??= new this());
|
return (this.instance ??= new this());
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getRibStream(uid: string) {
|
public async getRibStream() {
|
||||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
const url = new URL(this.baseURl);
|
||||||
try {
|
try {
|
||||||
return await this.getRequest<any>(url);
|
return await this.getRequest<any>(url);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@ -50,8 +50,8 @@ export default class Bucket extends BaseNotary {
|
|||||||
/**
|
/**
|
||||||
* @description : Delete a File
|
* @description : Delete a File
|
||||||
*/
|
*/
|
||||||
public async delete(uid: string) {
|
public async delete() {
|
||||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
const url = new URL(this.baseURl);
|
||||||
try {
|
try {
|
||||||
return await this.deleteRequest(url);
|
return await this.deleteRequest(url);
|
||||||
} catch (err) {
|
} catch (err) {
|
@ -12,6 +12,7 @@ import { useRouter } from "next/router";
|
|||||||
import JwtService, { ICustomerJwtPayload } from "@Front/Services/JwtService/JwtService";
|
import JwtService, { ICustomerJwtPayload } from "@Front/Services/JwtService/JwtService";
|
||||||
import DepositOtherDocument from "@Front/Components/DesignSystem/DepositOtherDocument";
|
import DepositOtherDocument from "@Front/Components/DesignSystem/DepositOtherDocument";
|
||||||
import Folders from "@Front/Api/LeCoffreApi/Customer/Folders/Folders";
|
import Folders from "@Front/Api/LeCoffreApi/Customer/Folders/Folders";
|
||||||
|
import OfficeRib from "@Front/Api/LeCoffreApi/Customer/OfficeRib/OfficeRib";
|
||||||
|
|
||||||
type IProps = {};
|
type IProps = {};
|
||||||
|
|
||||||
@ -71,6 +72,20 @@ export default function ClientDashboard(props: IProps) {
|
|||||||
setIsAddDocumentModalVisible(true);
|
setIsAddDocumentModalVisible(true);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
async function downloadFile() {
|
||||||
|
if (!folder?.office?.uid) return;
|
||||||
|
const blob = await OfficeRib.getInstance().getRibStream(folder.office.uid);
|
||||||
|
const ribUrl = URL.createObjectURL(blob);
|
||||||
|
|
||||||
|
if (!ribUrl) return;
|
||||||
|
const a = document.createElement("a");
|
||||||
|
a.style.display = "none";
|
||||||
|
a.href = ribUrl;
|
||||||
|
a.download = "";
|
||||||
|
document.body.appendChild(a);
|
||||||
|
a.click();
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getDocuments();
|
getDocuments();
|
||||||
}, [folderUid, getDocuments]);
|
}, [folderUid, getDocuments]);
|
||||||
@ -102,6 +117,8 @@ export default function ClientDashboard(props: IProps) {
|
|||||||
sélectionnez le document correspondant. <br /> En déposant un document, celui-ci est automatiquement enregistré et
|
sélectionnez le document correspondant. <br /> En déposant un document, celui-ci est automatiquement enregistré et
|
||||||
transmis à votre notaire.
|
transmis à votre notaire.
|
||||||
</Typography>
|
</Typography>
|
||||||
|
|
||||||
|
<Button onClick={downloadFile}>Télécharger le Rib</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -5,7 +5,7 @@ import DefaultTemplate from "@Front/Components/LayoutTemplates/DefaultTemplate";
|
|||||||
import FilePreview from "@Front/Components/DesignSystem/FilePreview";
|
import FilePreview from "@Front/Components/DesignSystem/FilePreview";
|
||||||
import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button";
|
import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import Bucket from "@Front/Api/LeCoffreApi/Notary/Bucket/Bucket";
|
import OfficeRib from "@Front/Api/LeCoffreApi/Notary/OfficeRib/OfficeRib";
|
||||||
import DepositRib from "@Front/Components/DesignSystem/DepositRib";
|
import DepositRib from "@Front/Components/DesignSystem/DepositRib";
|
||||||
import Confirm from "@Front/Components/DesignSystem/Modal/Confirm";
|
import Confirm from "@Front/Components/DesignSystem/Modal/Confirm";
|
||||||
|
|
||||||
@ -22,11 +22,8 @@ export default function Rib() {
|
|||||||
//Put fetch data in a useCallback
|
//Put fetch data in a useCallback
|
||||||
|
|
||||||
const fetchData = useCallback(async () => {
|
const fetchData = useCallback(async () => {
|
||||||
console.log("fetchData", officeUid);
|
|
||||||
|
|
||||||
if (!officeUid) return;
|
|
||||||
try {
|
try {
|
||||||
const blob = await Bucket.getInstance().getRibStream(officeUid as string);
|
const blob = await OfficeRib.getInstance().getRibStream();
|
||||||
|
|
||||||
const ribUrl = URL.createObjectURL(blob);
|
const ribUrl = URL.createObjectURL(blob);
|
||||||
|
|
||||||
@ -60,7 +57,7 @@ export default function Rib() {
|
|||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append("file", documentList[0]!, documentList[0]!.name);
|
formData.append("file", documentList[0]!, documentList[0]!.name);
|
||||||
|
|
||||||
await Bucket.getInstance().post(formData);
|
await OfficeRib.getInstance().post(formData);
|
||||||
|
|
||||||
onCloseRibModal();
|
onCloseRibModal();
|
||||||
fetchData();
|
fetchData();
|
||||||
@ -76,9 +73,7 @@ export default function Rib() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function onDeleteModalAccepted() {
|
async function onDeleteModalAccepted() {
|
||||||
if (!officeUid) return;
|
await OfficeRib.getInstance().delete();
|
||||||
const office = await Bucket.getInstance().delete(officeUid as string);
|
|
||||||
console.log(office);
|
|
||||||
|
|
||||||
onCloseDeleteModal();
|
onCloseDeleteModal();
|
||||||
fetchData();
|
fetchData();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user