diff --git a/src/front/Api/LeCoffreApi/SuperAdmin/LiveVotes/LiveVotes.ts b/src/front/Api/LeCoffreApi/SuperAdmin/LiveVotes/LiveVotes.ts index 394e1b93..8a40af7b 100644 --- a/src/front/Api/LeCoffreApi/SuperAdmin/LiveVotes/LiveVotes.ts +++ b/src/front/Api/LeCoffreApi/SuperAdmin/LiveVotes/LiveVotes.ts @@ -1,4 +1,4 @@ -import { Appointment } from "le-coffre-resources/dist/SuperAdmin"; +import { Appointment, Vote } from "le-coffre-resources/dist/SuperAdmin"; import BaseSuperAdmin from "../BaseSuperAdmin"; @@ -18,6 +18,9 @@ export type LiveVote = { appointment: Appointment; }; +export type IDeleteVotesParams = { + uid: Vote["uid"]; +}; export default class LiveVotes extends BaseSuperAdmin { private static instance: LiveVotes; private readonly baseURl = this.namespaceUrl.concat("/live-votes"); @@ -46,4 +49,17 @@ export default class LiveVotes extends BaseSuperAdmin { return Promise.reject(err); } } + + /** + * @description : Delete a vote + */ + public async delete(body: IDeleteVotesParams): Promise { + const url = new URL(`${this.baseURl}/${body.uid}`); + try { + return await this.deleteRequest(url, body); + } catch (err) { + this.onError(err); + return Promise.reject(err); + } + } } diff --git a/src/front/Api/LeCoffreApi/SuperAdmin/Votes/Votes.ts b/src/front/Api/LeCoffreApi/SuperAdmin/Votes/Votes.ts deleted file mode 100644 index 34907702..00000000 --- a/src/front/Api/LeCoffreApi/SuperAdmin/Votes/Votes.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { Vote } from "le-coffre-resources/dist/SuperAdmin"; - -import BaseSuperAdmin from "../BaseSuperAdmin"; - -// TODO Type get query params -> Where + inclue + orderby -export interface IGetVotessparams { - where?: {}; - include?: {}; - select?: {}; -} - -export type IDeleteVotesParams = { - uid: Vote["uid"]; -}; - -export default class Votes extends BaseSuperAdmin { - private static instance: Votes; - private readonly baseURl = this.namespaceUrl.concat("/votes"); - - private constructor() { - super(); - } - - public static getInstance() { - if (!this.instance) { - return new this(); - } else { - return this.instance; - } - } - - /** - * @description : Create a Votes - */ - public async delete(body: IDeleteVotesParams): Promise { - const url = new URL(this.baseURl + "/" + body.uid); - try { - return await this.deleteRequest(url, body); - } catch (err) { - this.onError(err); - return Promise.reject(err); - } - } -} diff --git a/src/front/Components/Layouts/Users/UserInformations/index.tsx b/src/front/Components/Layouts/Users/UserInformations/index.tsx index 990b3de6..17b9e22b 100644 --- a/src/front/Components/Layouts/Users/UserInformations/index.tsx +++ b/src/front/Components/Layouts/Users/UserInformations/index.tsx @@ -3,7 +3,6 @@ import OfficeRoles from "@Front/Api/LeCoffreApi/Admin/OfficeRoles/OfficeRoles"; import Roles from "@Front/Api/LeCoffreApi/Admin/Roles/Roles"; import LiveVotes from "@Front/Api/LeCoffreApi/SuperAdmin/LiveVotes/LiveVotes"; import Users from "@Front/Api/LeCoffreApi/SuperAdmin/Users/Users"; -import Votes from "@Front/Api/LeCoffreApi/SuperAdmin/Votes/Votes"; import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button"; import SelectField, { IOption } from "@Front/Components/DesignSystem/Form/SelectField"; import Confirm from "@Front/Components/DesignSystem/Modal/Confirm"; @@ -222,7 +221,7 @@ export default function UserInformations(props: IProps) { const user = JwtService.getInstance().decodeJwt(); const vote = currentAppointment.votes?.find((vote) => vote.voter?.uid === user?.userId); if (!vote) return; - await Votes.getInstance().delete({ uid: vote.uid }); + await LiveVotes.getInstance().delete({ uid: vote.uid }); await getUser(); }, [currentAppointment, getUser]);