feat: deadline component verbeterd

This commit is contained in:
Joyelle Ndagijimana 2025-03-29 21:56:36 +01:00
parent 3e00f0eb1f
commit 36f7cfa4bd
3 changed files with 17 additions and 7 deletions

View file

@ -81,12 +81,14 @@ export const classesRules = [
*/
export const deadlineRules = [
(value: string) => {
if (!value) return 'You must set a deadline.';
if (!value) return "You must set a deadline.";
const selectedDate = new Date(value);
const selectedDateTime = new Date(value);
const now = new Date();
if (selectedDate <= now) return 'The deadline must be in the future.';
if (isNaN(selectedDateTime.getTime())) return "Invalid date or time.";
if (selectedDateTime <= now) return "The deadline must be in the future.";
return true;
},