Add an accommodations reservations module (#188)
All checks were successful
continuous-integration/drone/push Build is passing

Add a new module to enable accommodations reservation

![](https://gitea.communiquons.org/attachments/de1f5b12-0a93-40f8-b29d-97665daa6fd5)

Reviewed-on: #188
This commit is contained in:
2024-06-22 21:30:26 +00:00
parent 8ecacbe622
commit 1a890844ef
54 changed files with 4230 additions and 33 deletions

View File

@ -0,0 +1,21 @@
import { LenConstraint } from "../api/ServerApi";
/**
* Check if a constraint was respected or not
*
* @returns An error message appropriate for the constraint
* violation, if any, or undefined otherwise
*/
export function checkConstraint(
constraint: LenConstraint,
value: string | undefined
): string | undefined {
value = value ?? "";
if (value.length < constraint.min)
return `Veuillez indiquer au moins ${constraint.min} caractères !`;
if (value.length > constraint.max)
return `Veuillez indiquer au maximum ${constraint.max} caractères !`;
return undefined;
}

View File

@ -0,0 +1,31 @@
/**
* Get formatted UNIX date
*/
export function fmtUnixDate(time: number): string {
return new Date(time * 1000).toLocaleString("fr-FR");
}
/**
* Get formatted UNIX date for Full Calendar
*/
export function fmtUnixDateFullCalendar(
time: number,
correctEnd: boolean
): string {
let d = new Date(time * 1000);
if (d.getHours() > 0 && correctEnd)
d = new Date(time * 1000 + 3600 * 24 * 1000);
const s = `${d.getFullYear()}-${(d.getMonth() + 1)
.toString(10)
.padStart(2, "0")}-${d.getDate().toString(10).padStart(2, "0")}`; /*T${d
.getHours()
.toString(10)
.padStart(2, "0")}:${d.getMinutes().toString(10).padStart(2, "0")}:${d
.getSeconds()
.toString(10)
.padStart(2, "0")}`*/
return s;
}