|
|
|
|
@@ -8,6 +8,7 @@ import {RoleList, TextField} from "../../../components/MemberCustomFiels.jsx";
|
|
|
|
|
import {useEffect, useRef, useState} from "react";
|
|
|
|
|
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
|
|
|
|
|
import {faFilePdf} from "@fortawesome/free-solid-svg-icons";
|
|
|
|
|
import {ConfirmDialog} from "../../../components/ConfirmDialog.jsx";
|
|
|
|
|
|
|
|
|
|
const vite_url = import.meta.env.VITE_URL;
|
|
|
|
|
|
|
|
|
|
@@ -16,7 +17,7 @@ export function AffiliationReqPage() {
|
|
|
|
|
const navigate = useNavigate();
|
|
|
|
|
|
|
|
|
|
const setLoading = useLoadingSwitcher()
|
|
|
|
|
const {data, error} = useFetch(`/affiliation/request/${id}`, setLoading, 1)
|
|
|
|
|
const {data, refresh, error} = useFetch(`/affiliation/request/${id}`, setLoading, 1)
|
|
|
|
|
|
|
|
|
|
return <>
|
|
|
|
|
<h2>Demande d'affiliation</h2>
|
|
|
|
|
@@ -26,7 +27,7 @@ export function AffiliationReqPage() {
|
|
|
|
|
<div>
|
|
|
|
|
{data
|
|
|
|
|
? <div className="">
|
|
|
|
|
<Content data={data}/>
|
|
|
|
|
<Content data={data} refresh={refresh}/>
|
|
|
|
|
</div>
|
|
|
|
|
: error && <AxiosError error={error}/>
|
|
|
|
|
}
|
|
|
|
|
@@ -34,14 +35,30 @@ export function AffiliationReqPage() {
|
|
|
|
|
</>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function Content({data}) {
|
|
|
|
|
function Content({data, refresh}) {
|
|
|
|
|
const navigate = useNavigate();
|
|
|
|
|
|
|
|
|
|
const handleRm = (e) => {
|
|
|
|
|
toast.promise(
|
|
|
|
|
apiAxios.delete(`/affiliation/request/${data.id}`),
|
|
|
|
|
{
|
|
|
|
|
pending: "Suppression de la demande d'affiliation en cours",
|
|
|
|
|
success: "Demande d'affiliation supprimée avec succès 🎉",
|
|
|
|
|
error: "Échec de la suppression de la demande d'affiliation 😕"
|
|
|
|
|
}
|
|
|
|
|
).then(_ => {
|
|
|
|
|
navigate("/admin/affiliation")
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleSubmit = (event) => {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
|
|
|
|
|
if (event.nativeEvent.submitter.value === "rm") {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const formData = new FormData();
|
|
|
|
|
|
|
|
|
|
console.log();
|
|
|
|
|
|
|
|
|
|
let err = 0;
|
|
|
|
|
|
|
|
|
|
formData.append('id', data.id);
|
|
|
|
|
@@ -53,7 +70,7 @@ function Content({data}) {
|
|
|
|
|
if (event.target.logo.files[0])
|
|
|
|
|
formData.append('logo', event.target.logo.files[0]);
|
|
|
|
|
if (event.target.status.files[0])
|
|
|
|
|
formData.append('status', event.target.status.files[0]);
|
|
|
|
|
formData.append('status', event.target.status.files[0]);
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < 3; i++) {
|
|
|
|
|
const mode = event.target['mode' + i].value;
|
|
|
|
|
@@ -113,7 +130,9 @@ function Content({data}) {
|
|
|
|
|
success: "Demande d'affiliation enregistrée avec succès 🎉",
|
|
|
|
|
error: "Échec de l'enregistrement de la demande d'affiliation 😕"
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
).then(_ => {
|
|
|
|
|
refresh(`/affiliation/request/${data.id}`)
|
|
|
|
|
})
|
|
|
|
|
} else if (event.nativeEvent.submitter.value === "accept") {
|
|
|
|
|
toast.promise(
|
|
|
|
|
apiAxios.put(`/affiliation/request/apply`, formData),
|
|
|
|
|
@@ -122,7 +141,9 @@ function Content({data}) {
|
|
|
|
|
success: "Affiliation acceptée avec succès 🎉",
|
|
|
|
|
error: "Échec de l'acceptation de l'affiliation 😕"
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
).then(_ => {
|
|
|
|
|
navigate("/admin/affiliation")
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -182,8 +203,11 @@ function Content({data}) {
|
|
|
|
|
</div>
|
|
|
|
|
<div className="row mb-3">
|
|
|
|
|
<div className="d-grid gap-2 d-md-flex justify-content-md-end">
|
|
|
|
|
<button type="submit" name="subbt" value="save" className="btn btn-primary">Enregistrer</button>
|
|
|
|
|
<button type="submit" name="subbt" value="accept" className="btn btn-success">Accepter</button>
|
|
|
|
|
<button type="submit" value="accept" className="btn btn-success">Accepter</button>
|
|
|
|
|
<button type="submit" value="save" className="btn btn-primary">Enregistrer</button>
|
|
|
|
|
<button className="btn btn-danger" value="rm" data-bs-toggle="modal" data-bs-target="#confirm-delete">Refuser</button>
|
|
|
|
|
<ConfirmDialog title="Refuser la demande" message="Êtes-vous sûr de vouloir refuser cette demande ?"
|
|
|
|
|
onConfirm={handleRm}/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|