Merge branch 'fix/createFolder' into dev
This commit is contained in:
commit
04517187d1
@ -1,5 +1,4 @@
|
|||||||
import { File } from "le-coffre-resources/dist/SuperAdmin";
|
import { File } from "le-coffre-resources/dist/SuperAdmin";
|
||||||
|
|
||||||
import BaseSuperAdmin from "../BaseSuperAdmin";
|
import BaseSuperAdmin from "../BaseSuperAdmin";
|
||||||
|
|
||||||
// TODO Type get query params -> Where + inclue + orderby
|
// TODO Type get query params -> Where + inclue + orderby
|
||||||
|
@ -21,6 +21,7 @@ import { ActionMeta, MultiValue } from "react-select";
|
|||||||
|
|
||||||
import BasePage from "../../Base";
|
import BasePage from "../../Base";
|
||||||
import classes from "./classes.module.scss";
|
import classes from "./classes.module.scss";
|
||||||
|
import JwtService from "@Front/Services/JwtService/JwtService";
|
||||||
|
|
||||||
type IFormValues = {
|
type IFormValues = {
|
||||||
folder_number: string;
|
folder_number: string;
|
||||||
@ -233,16 +234,12 @@ class CreateFolderClass extends BasePage<IPropsClass, IState> {
|
|||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
|
const officeId = (JwtService.getInstance().decodeJwt())?.office_Id;
|
||||||
|
console.log('form initializdd');
|
||||||
const selectedDeedTypeUid: DeedType | undefined = this.state.deedTypes.find(
|
const selectedDeedTypeUid: DeedType | undefined = this.state.deedTypes.find(
|
||||||
(deedType) => deedType.uid === this.state.formValues.act_typ?.value,
|
(deedType) => deedType.uid === this.state.formValues.act_typ?.value,
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
|
||||||
* MOCK DATA
|
|
||||||
*/
|
|
||||||
const usersMock = await Users.getInstance().get({ include: { office_membership: true } });
|
|
||||||
const userMock = usersMock[0];
|
|
||||||
|
|
||||||
let stakeholders = this.state.collaborators;
|
let stakeholders = this.state.collaborators;
|
||||||
if (this.state.folder_access === "select_collaborators") {
|
if (this.state.folder_access === "select_collaborators") {
|
||||||
stakeholders = this.state.collaborators.filter((collaborator) => {
|
stakeholders = this.state.collaborators.filter((collaborator) => {
|
||||||
@ -261,23 +258,27 @@ class CreateFolderClass extends BasePage<IPropsClass, IState> {
|
|||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
office: Office.hydrate<Office>({
|
office: Office.hydrate<Office>({
|
||||||
uid: userMock?.office_membership?.uid,
|
uid: officeId,
|
||||||
}),
|
}),
|
||||||
customers: [],
|
customers: [],
|
||||||
stakeholders
|
stakeholders
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log('form');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await officeFolderForm.validateOrReject?.({ groups: ["createFolder"], forbidUnknownValues: false });
|
await officeFolderForm.validateOrReject?.({ groups: ["createFolder"], forbidUnknownValues: false });
|
||||||
} catch (validationErrors) {
|
} catch (validationErrors) {
|
||||||
this.setState({
|
this.setState({
|
||||||
validationError: validationErrors as ValidationError[],
|
validationError: validationErrors as ValidationError[],
|
||||||
});
|
});
|
||||||
|
console.log('validation errros');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const newOfficeFolder = await Folders.getInstance().post(officeFolderForm);
|
const newOfficeFolder = await Folders.getInstance().post(officeFolderForm);
|
||||||
|
console.log('new office folder: ',newOfficeFolder)
|
||||||
if (!newOfficeFolder) return;
|
if (!newOfficeFolder) return;
|
||||||
this.props.router.push(`/folders/${newOfficeFolder.uid}`);
|
this.props.router.push(`/folders/${newOfficeFolder.uid}`);
|
||||||
} catch (backError: any) {
|
} catch (backError: any) {
|
||||||
|
@ -11,8 +11,6 @@ export class FrontendVariables {
|
|||||||
|
|
||||||
public FRONT_APP_HOST!: string;
|
public FRONT_APP_HOST!: string;
|
||||||
|
|
||||||
public FRONT_APP_PORT!: string;
|
|
||||||
|
|
||||||
public IDNOT_AUTHORIZE_ENDPOINT!: string;
|
public IDNOT_AUTHORIZE_ENDPOINT!: string;
|
||||||
|
|
||||||
public IDNOT_CLIENT_ID!: string;
|
public IDNOT_CLIENT_ID!: string;
|
||||||
|
@ -26,15 +26,19 @@ export default class JwtService {
|
|||||||
return (this.instance ??= new this());
|
return (this.instance ??= new this());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public decodeJwt(): IUserJwtPayload | undefined {
|
||||||
|
const accessToken = CookieService.getInstance().getCookie("leCoffreAccessToken");
|
||||||
|
if (!accessToken) return;
|
||||||
|
return jwt_decode(accessToken);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description : set a cookie with a name and a value that expire in 7 days
|
* @description : set a cookie with a name and a value that expire in 7 days
|
||||||
* @throws {Error} If the name or the value is empty
|
* @throws {Error} If the name or the value is empty
|
||||||
*/
|
*/
|
||||||
public async checkJwt() {
|
public async checkJwt() {
|
||||||
const accessToken = CookieService.getInstance().getCookie("leCoffreAccessToken");
|
const decodedToken = this.decodeJwt();
|
||||||
|
if(!decodedToken) return;
|
||||||
if (!accessToken) return;
|
|
||||||
const decodedToken: IUserJwtPayload = jwt_decode(accessToken);
|
|
||||||
|
|
||||||
const now = Math.floor(Date.now() / 1000);
|
const now = Math.floor(Date.now() / 1000);
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@ type AppPropsWithLayout = AppProps & {
|
|||||||
backApiRootUrl: string;
|
backApiRootUrl: string;
|
||||||
backApiVersion: string;
|
backApiVersion: string;
|
||||||
frontAppHost: string;
|
frontAppHost: string;
|
||||||
frontAppPort: string;
|
|
||||||
idNotAuthorizeEndpoint: string;
|
idNotAuthorizeEndpoint: string;
|
||||||
idNotClientId: string;
|
idNotClientId: string;
|
||||||
fcAuthorizeEndpoint: string;
|
fcAuthorizeEndpoint: string;
|
||||||
@ -32,7 +31,6 @@ const MyApp = (({
|
|||||||
backApiRootUrl,
|
backApiRootUrl,
|
||||||
backApiVersion,
|
backApiVersion,
|
||||||
frontAppHost,
|
frontAppHost,
|
||||||
frontAppPort,
|
|
||||||
idNotAuthorizeEndpoint,
|
idNotAuthorizeEndpoint,
|
||||||
idNotClientId,
|
idNotClientId,
|
||||||
fcAuthorizeEndpoint,
|
fcAuthorizeEndpoint,
|
||||||
@ -46,7 +44,6 @@ const MyApp = (({
|
|||||||
instance.BACK_API_ROOT_URL = backApiRootUrl ?? "/api";
|
instance.BACK_API_ROOT_URL = backApiRootUrl ?? "/api";
|
||||||
instance.BACK_API_VERSION = backApiVersion ?? "/v1";
|
instance.BACK_API_VERSION = backApiVersion ?? "/v1";
|
||||||
instance.FRONT_APP_HOST = frontAppHost ?? "app.stg.lecoffre.smart-chain.fr";
|
instance.FRONT_APP_HOST = frontAppHost ?? "app.stg.lecoffre.smart-chain.fr";
|
||||||
instance.FRONT_APP_PORT = frontAppPort ?? "3000";
|
|
||||||
instance.IDNOT_AUTHORIZE_ENDPOINT = idNotAuthorizeEndpoint ?? "https://qual-connexion.idnot.fr/IdPOAuth2/authorize/idnot_idp_v1";
|
instance.IDNOT_AUTHORIZE_ENDPOINT = idNotAuthorizeEndpoint ?? "https://qual-connexion.idnot.fr/IdPOAuth2/authorize/idnot_idp_v1";
|
||||||
instance.IDNOT_CLIENT_ID = idNotClientId ?? "4501646203F3EF67";
|
instance.IDNOT_CLIENT_ID = idNotClientId ?? "4501646203F3EF67";
|
||||||
instance.FC_AUTHORIZE_ENDPOINT= fcAuthorizeEndpoint ?? "https://fcp.integ01.dev-franceconnect.fr/api/v1/authorize";
|
instance.FC_AUTHORIZE_ENDPOINT= fcAuthorizeEndpoint ?? "https://fcp.integ01.dev-franceconnect.fr/api/v1/authorize";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user