feat: change certif type
This commit is contained in:
parent
47daa459e2
commit
3ccf880057
@ -24,7 +24,7 @@ public class LicenceModel {
|
|||||||
|
|
||||||
int saison;
|
int saison;
|
||||||
|
|
||||||
boolean certificate;
|
String certificate;
|
||||||
|
|
||||||
boolean validate;
|
boolean validate;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -54,7 +54,7 @@ public class LicenceService {
|
|||||||
LicenceModel model = new LicenceModel();
|
LicenceModel model = new LicenceModel();
|
||||||
model.setMembre(membreModel);
|
model.setMembre(membreModel);
|
||||||
model.setSaison(form.getSaison());
|
model.setSaison(form.getSaison());
|
||||||
model.setCertificate(form.isCertificate());
|
model.setCertificate(form.getCertificate());
|
||||||
model.setValidate(form.isValidate());
|
model.setValidate(form.isValidate());
|
||||||
return Panache.withTransaction(() -> repository.persist(model)
|
return Panache.withTransaction(() -> repository.persist(model)
|
||||||
.call(m -> (m.isValidate() && membreModel.getLicence() <= 0) ?
|
.call(m -> (m.isValidate() && membreModel.getLicence() <= 0) ?
|
||||||
@ -66,7 +66,7 @@ public class LicenceService {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
return repository.findById(form.getId()).chain(model -> {
|
return repository.findById(form.getId()).chain(model -> {
|
||||||
model.setCertificate(form.isCertificate());
|
model.setCertificate(form.getCertificate());
|
||||||
model.setValidate(form.isValidate());
|
model.setValidate(form.isValidate());
|
||||||
return Panache.withTransaction(() -> repository.persist(model)
|
return Panache.withTransaction(() -> repository.persist(model)
|
||||||
.call(m -> m.isValidate() ? Mutiny.fetch(m.getMembre())
|
.call(m -> m.isValidate() ? Mutiny.fetch(m.getMembre())
|
||||||
@ -96,13 +96,13 @@ public class LicenceService {
|
|||||||
LicenceModel model = new LicenceModel();
|
LicenceModel model = new LicenceModel();
|
||||||
model.setMembre(combRepository);
|
model.setMembre(combRepository);
|
||||||
model.setSaison(Utils.getSaison());
|
model.setSaison(Utils.getSaison());
|
||||||
model.setCertificate(form.isCertificate());
|
model.setCertificate(form.getCertificate());
|
||||||
model.setValidate(false);
|
model.setValidate(false);
|
||||||
return Panache.withTransaction(() -> repository.persist(model));
|
return Panache.withTransaction(() -> repository.persist(model));
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
return repository.findById(form.getId()).chain(model -> {
|
return repository.findById(form.getId()).chain(model -> {
|
||||||
model.setCertificate(form.isCertificate());
|
model.setCertificate(form.getCertificate());
|
||||||
return Panache.withTransaction(() -> repository.persist(model));
|
return Panache.withTransaction(() -> repository.persist(model));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,7 +14,7 @@ public class SimpleLicence {
|
|||||||
Long id;
|
Long id;
|
||||||
Long membre;
|
Long membre;
|
||||||
int saison;
|
int saison;
|
||||||
boolean certificate;
|
String certificate;
|
||||||
boolean validate;
|
boolean validate;
|
||||||
|
|
||||||
public static SimpleLicence fromModel(LicenceModel model) {
|
public static SimpleLicence fromModel(LicenceModel model) {
|
||||||
@ -25,7 +25,7 @@ public class SimpleLicence {
|
|||||||
.id(model.getId())
|
.id(model.getId())
|
||||||
.membre(model.getMembre().getId())
|
.membre(model.getMembre().getId())
|
||||||
.saison(model.getSaison())
|
.saison(model.getSaison())
|
||||||
.certificate(model.isCertificate())
|
.certificate(model.getCertificate())
|
||||||
.validate(model.isValidate())
|
.validate(model.isValidate())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,7 +17,7 @@ public class LicenceForm {
|
|||||||
private int saison;
|
private int saison;
|
||||||
|
|
||||||
@FormParam("certificate")
|
@FormParam("certificate")
|
||||||
private boolean certificate;
|
private String certificate = null;
|
||||||
|
|
||||||
@FormParam("validate")
|
@FormParam("validate")
|
||||||
private boolean validate;
|
private boolean validate;
|
||||||
|
|||||||
@ -95,7 +95,7 @@ function Root() {
|
|||||||
<div className="container my-4">
|
<div className="container my-4">
|
||||||
<Outlet/>
|
<Outlet/>
|
||||||
<ToastContainer
|
<ToastContainer
|
||||||
position="top-center"
|
position="bottom-right"
|
||||||
autoClose={5000}
|
autoClose={5000}
|
||||||
hideProgressBar={false}
|
hideProgressBar={false}
|
||||||
newestOnTop={false}
|
newestOnTop={false}
|
||||||
|
|||||||
@ -67,7 +67,7 @@ export function LicenceCard({userData}) {
|
|||||||
{licences.map((licence, index) => {
|
{licences.map((licence, index) => {
|
||||||
return <div key={index}
|
return <div key={index}
|
||||||
className={"list-group-item d-flex justify-content-between align-items-start list-group-item-" +
|
className={"list-group-item d-flex justify-content-between align-items-start list-group-item-" +
|
||||||
(licence.validate ? "success" : (licence.certificate ? "warning" : "danger"))}>
|
(licence.validate ? "success" : (licence.certificate?.length > 0 ? "warning" : "danger"))}>
|
||||||
<div className="me-auto">{licence?.saison}-{licence?.saison + 1}</div>
|
<div className="me-auto">{licence?.saison}-{licence?.saison + 1}</div>
|
||||||
<button className="badge btn btn-primary rounded-pill" data-bs-toggle="modal"
|
<button className="badge btn btn-primary rounded-pill" data-bs-toggle="modal"
|
||||||
data-bs-target="#LicenceModal" onClick={_ => setModal(licence)}>
|
data-bs-target="#LicenceModal" onClick={_ => setModal(licence)}>
|
||||||
@ -93,6 +93,8 @@ function sendLicence(event, dispatch) {
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
const formData = new FormData(event.target);
|
const formData = new FormData(event.target);
|
||||||
|
formData.set('licence', event.target.licence?.value?.length > 0 ? event.target.licence?.value : null)
|
||||||
|
|
||||||
toast.promise(
|
toast.promise(
|
||||||
apiAxios.post(`/licence/${formData.get('membre')}`, formData),
|
apiAxios.post(`/licence/${formData.get('membre')}`, formData),
|
||||||
{
|
{
|
||||||
@ -130,14 +132,14 @@ function removeLicence(id, dispatch) {
|
|||||||
|
|
||||||
function ModalContent({licence, dispatch}) {
|
function ModalContent({licence, dispatch}) {
|
||||||
const [saison, setSaison] = useState(0)
|
const [saison, setSaison] = useState(0)
|
||||||
const [certificate, setCertificate] = useState(false)
|
const [certificate, setCertificate] = useState("")
|
||||||
const [validate, setValidate] = useState(false)
|
const [validate, setValidate] = useState(false)
|
||||||
const [isNew, setNew] = useState(true)
|
const [isNew, setNew] = useState(true)
|
||||||
const setSeason = (event) => {
|
const setSeason = (event) => {
|
||||||
setSaison(Number(event.target.value))
|
setSaison(Number(event.target.value))
|
||||||
}
|
}
|
||||||
const handleCertificateChange = (event) => {
|
const handleCertificateChange = (event) => {
|
||||||
setCertificate(event.target.value === 'true');
|
setCertificate(event.target.value);
|
||||||
}
|
}
|
||||||
const handleValidateChange = (event) => {
|
const handleValidateChange = (event) => {
|
||||||
setValidate(event.target.value === 'true');
|
setValidate(event.target.value === 'true');
|
||||||
@ -152,7 +154,7 @@ function ModalContent({licence, dispatch}) {
|
|||||||
} else {
|
} else {
|
||||||
setNew(true)
|
setNew(true)
|
||||||
setSaison(getSaison())
|
setSaison(getSaison())
|
||||||
setCertificate(false)
|
setCertificate("")
|
||||||
setValidate(false)
|
setValidate(false)
|
||||||
}
|
}
|
||||||
}, [licence]);
|
}, [licence]);
|
||||||
@ -175,8 +177,10 @@ function ModalContent({licence, dispatch}) {
|
|||||||
<span className="input-group-text" id="basic-addon2">-</span>
|
<span className="input-group-text" id="basic-addon2">-</span>
|
||||||
<span className="input-group-text" id="basic-addon2">{saison + 1}</span>
|
<span className="input-group-text" id="basic-addon2">{saison + 1}</span>
|
||||||
</div>
|
</div>
|
||||||
<RadioGroupeOnOff name="certificate" text="Certificat médical valide" value={certificate}
|
|
||||||
onChange={handleCertificateChange}/>
|
<span>Médecin figurant sur le certificat médical</span>
|
||||||
|
<TextField name="certificate" text="Nom" value={certificate}
|
||||||
|
onChange={handleCertificateChange} required={false}/>
|
||||||
<RadioGroupeOnOff name="validate" text="Validation de la licence" value={validate}
|
<RadioGroupeOnOff name="validate" text="Validation de la licence" value={validate}
|
||||||
onChange={handleValidateChange}/>
|
onChange={handleValidateChange}/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import {AxiosError} from "../../../components/AxiosError.jsx";
|
|||||||
import {apiAxios, errFormater, getSaison} from "../../../utils/Tools.js";
|
import {apiAxios, errFormater, getSaison} from "../../../utils/Tools.js";
|
||||||
import {toast} from "react-toastify";
|
import {toast} from "react-toastify";
|
||||||
import {ColoredText} from "../../../components/ColoredCircle.jsx";
|
import {ColoredText} from "../../../components/ColoredCircle.jsx";
|
||||||
|
import {TextField} from "../../../components/MemberCustomFiels.jsx";
|
||||||
|
|
||||||
function licenceReducer(licences, action) {
|
function licenceReducer(licences, action) {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
@ -63,11 +64,11 @@ export function LicenceCard({userData}) {
|
|||||||
{licences.map((licence, index) => {
|
{licences.map((licence, index) => {
|
||||||
return <div key={index}
|
return <div key={index}
|
||||||
className={"list-group-item d-flex justify-content-between align-items-start list-group-item-" +
|
className={"list-group-item d-flex justify-content-between align-items-start list-group-item-" +
|
||||||
(licence.validate ? "success" : (licence.certificate ? "warning" : "danger"))}>
|
(licence.validate ? "success" : (licence.certificate?.length > 0 ? "warning" : "danger"))}>
|
||||||
<div className="me-auto">{licence?.saison}-{licence?.saison + 1}</div>
|
<div className="me-auto">{licence?.saison}-{licence?.saison + 1}</div>
|
||||||
<button className="badge btn btn-primary rounded-pill" data-bs-toggle="modal"
|
<button className="badge btn btn-primary rounded-pill" data-bs-toggle="modal"
|
||||||
data-bs-target="#LicenceModal" onClick={_ => setModal(licence)}>
|
data-bs-target="#LicenceModal" onClick={_ => setModal(licence)}>
|
||||||
{licence.saison === getSaison() ? <FontAwesomeIcon icon={faPen}/> :
|
{licence.saison === getSaison() && !licence.validate ? <FontAwesomeIcon icon={faPen}/> :
|
||||||
<FontAwesomeIcon icon={faInfo}/>}</button>
|
<FontAwesomeIcon icon={faInfo}/>}</button>
|
||||||
</div>
|
</div>
|
||||||
})}
|
})}
|
||||||
@ -126,11 +127,11 @@ function removeLicence(id, dispatch) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function ModalContent({licence, dispatch}) {
|
function ModalContent({licence, dispatch}) {
|
||||||
const [certificate, setCertificate] = useState(false)
|
const [certificate, setCertificate] = useState("")
|
||||||
const [isNew, setNew] = useState(true)
|
const [isNew, setNew] = useState(true)
|
||||||
|
|
||||||
const handleCertificateChange = (event) => {
|
const handleCertificateChange = (event) => {
|
||||||
setCertificate(event.target.value === 'true');
|
setCertificate(event.target.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -139,7 +140,7 @@ function ModalContent({licence, dispatch}) {
|
|||||||
setCertificate(licence.certificate)
|
setCertificate(licence.certificate)
|
||||||
} else {
|
} else {
|
||||||
setNew(true)
|
setNew(true)
|
||||||
setCertificate(false)
|
setCertificate("")
|
||||||
}
|
}
|
||||||
}, [licence]);
|
}, [licence]);
|
||||||
|
|
||||||
@ -156,27 +157,19 @@ function ModalContent({licence, dispatch}) {
|
|||||||
aria-label="Close"></button>
|
aria-label="Close"></button>
|
||||||
</div>
|
</div>
|
||||||
<div className="modal-body">
|
<div className="modal-body">
|
||||||
<div className="btn-group input-group mb-3 justify-content-md-center" role="group"
|
<span>Médecin figurant sur le certificat médical</span>
|
||||||
aria-label="Basic radio toggle button group">
|
<TextField name="certificate" text="Nom" value={certificate}
|
||||||
<span className="input-group-text">Certificat médical</span>
|
onChange={handleCertificateChange} required={false} disabled={!currentSaison || licence.validate}/>
|
||||||
<input type="radio" className="btn-check" id="btnradio1" autoComplete="off" value="false"
|
|
||||||
checked={certificate === false} onChange={handleCertificateChange} disabled={!currentSaison}/>
|
|
||||||
<label className="btn btn-outline-primary" htmlFor="btnradio1">Non</label>
|
|
||||||
<input type="radio" className="btn-check" name="certificate" id="btnradio2" autoComplete="off"
|
|
||||||
value="true" checked={certificate === true} onChange={handleCertificateChange}
|
|
||||||
disabled={!currentSaison}/>
|
|
||||||
<label className="btn btn-outline-primary" htmlFor="btnradio2">Oui</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="input-group mb-3 justify-content-md-center">
|
<div className="input-group mb-3 justify-content-md-center">
|
||||||
<div>Validation de la licence: <ColoredText boolean={licence.validate}/></div>
|
<div>Validation de la licence: <ColoredText boolean={licence.validate}/></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="modal-footer">
|
<div className="modal-footer">
|
||||||
{currentSaison &&
|
{currentSaison && !licence.validate &&
|
||||||
<button type="submit" className="btn btn-primary" data-bs-dismiss="modal">Enregistrer</button>}
|
<button type="submit" className="btn btn-primary" data-bs-dismiss="modal">Enregistrer</button>}
|
||||||
<button type="button" className="btn btn-secondary" data-bs-dismiss="modal">Fermer</button>
|
<button type="button" className="btn btn-secondary" data-bs-dismiss="modal">Fermer</button>
|
||||||
{currentSaison && licence.validate === false &&
|
{currentSaison && !licence.validate &&
|
||||||
<button type="button" className="btn btn-danger" data-bs-dismiss="modal"
|
<button type="button" className="btn btn-danger" data-bs-dismiss="modal"
|
||||||
onClick={() => removeLicence(licence.id, dispatch)}>Annuler</button>}
|
onClick={() => removeLicence(licence.id, dispatch)}>Annuler</button>}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user