From 61918e6994e3cb0cbb9abdb96fb3776a40d0dbf1 Mon Sep 17 00:00:00 2001 From: RchtDshr Date: Wed, 9 Oct 2024 02:07:10 +0530 Subject: [PATCH 1/2] registration button disable --- .env.example | 14 -------------- package-lock.json | 22 ++++++++++++++++++++++ src/components/EventPageClient.tsx | 23 +++++++++++++++++++---- 3 files changed, 41 insertions(+), 18 deletions(-) delete mode 100644 .env.example diff --git a/.env.example b/.env.example deleted file mode 100644 index e22972e..0000000 --- a/.env.example +++ /dev/null @@ -1,14 +0,0 @@ -KINDE_CLIENT_ID= -KINDE_CLIENT_SECRET= -KINDE_ISSUER_URL= -KINDE_SITE_URL=http://localhost:3000 -KINDE_POST_LOGOUT_REDIRECT_URL=http://localhost:3000 -KINDE_POST_LOGIN_REDIRECT_URL=http://localhost:3000/dashboard - -NEXT_PUBLIC_SUPABASE_PASSWORD= -NEXT_PUBLIC_SUPABASE_URL= -NEXT_PUBLIC_SUPABASE_ANON_KEY= - -NEXT_PUBLIC_BASE_URL=http://localhost:3000 - -RESEND_API_KEY= \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index a74611b..a3f4895 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,6 +31,7 @@ "mongoose": "^8.5.3", "next": "14.2.5", "next-sitemap": "^4.2.3", + "next-themes": "^0.3.0", "react": "^18", "react-datepicker": "^7.3.0", "react-dom": "^18", @@ -40,6 +41,7 @@ "react-share": "^5.1.0", "recharts": "^2.13.0-alpha.5", "resend": "^4.0.0", + "sonner": "^1.5.0", "tailwind-merge": "^2.5.2", "tailwindcss-animate": "^1.0.7", "uuid": "^10.0.0", @@ -8399,6 +8401,16 @@ "resolved": "https://registry.npmjs.org/@next/env/-/env-13.5.7.tgz", "integrity": "sha512-uVuRqoj28Ys/AI/5gVEgRAISd0KWI0HRjOO1CTpNgmX3ZsHb5mdn14Y59yk0IxizXdo7ZjsI2S7qbWnO+GNBcA==" }, + "node_modules/next-themes": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/next-themes/-/next-themes-0.3.0.tgz", + "integrity": "sha512-/QHIrsYpd6Kfk7xakK4svpDI5mmXP0gfvCoJdGpZQ2TOrQZmsW0QxjaiLn8wbIKjtm4BTSqLoix4lxYYOnLJ/w==", + "license": "MIT", + "peerDependencies": { + "react": "^16.8 || ^17 || ^18", + "react-dom": "^16.8 || ^17 || ^18" + } + }, "node_modules/next/node_modules/postcss": { "version": "8.4.31", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz", @@ -9834,6 +9846,16 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, + "node_modules/sonner": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/sonner/-/sonner-1.5.0.tgz", + "integrity": "sha512-FBjhG/gnnbN6FY0jaNnqZOMmB73R+5IiyYAw8yBj7L54ER7HB3fOSE5OFiQiE2iXWxeXKvg6fIP4LtVppHEdJA==", + "license": "MIT", + "peerDependencies": { + "react": "^18.0.0", + "react-dom": "^18.0.0" + } + }, "node_modules/source-map-js": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", diff --git a/src/components/EventPageClient.tsx b/src/components/EventPageClient.tsx index 58506b7..6babafa 100644 --- a/src/components/EventPageClient.tsx +++ b/src/components/EventPageClient.tsx @@ -25,6 +25,7 @@ const EventPageClient = ({ eventsId }: { eventsId: string }) => { const [eventData, setEventData]: any = useState([]); const [isLoading, setIsLoading] = useState(true); const [userData, setUserData]: any = useState([]); + const [registrationClosed, setRegistrationClosed] = useState(false); // New state useEffect(() => { async function getData() { @@ -38,6 +39,7 @@ const EventPageClient = ({ eventsId }: { eventsId: string }) => { console.error("Error fetching event details:", error); } else { setEventData(data); + checkRegistrationStatus(data); // Check registration dates } setIsLoading(false); } @@ -52,6 +54,17 @@ const EventPageClient = ({ eventsId }: { eventsId: string }) => { }); }, []); + // Function to check if registration period has ended + const checkRegistrationStatus = (data: any) => { + const currentDate = new Date(); + const registrationStartDate = new Date(data[0].event_registration_startdate); + const registrationEndDate = new Date(data[0].event_registration_enddate); + + if (currentDate < registrationStartDate || currentDate > registrationEndDate) { + setRegistrationClosed(true); // Set registration closed if outside the valid period + } + }; + async function isUser() { if (!isAuthenticated) { router.push("/unauthorized"); @@ -83,7 +96,7 @@ const EventPageClient = ({ eventsId }: { eventsId: string }) => { return ( <> -
+
{eventData.map((event: any) => (
{ @@ -190,7 +205,7 @@ const EventPageClient = ({ eventsId }: { eventsId: string }) => { <> From 94a54e788590da16329ac9f8f25d01d019170b52 Mon Sep 17 00:00:00 2001 From: RchtDshr Date: Wed, 9 Oct 2024 02:26:19 +0530 Subject: [PATCH 2/2] add events block past dates --- src/app/(event)/add-event/page.tsx | 105 ++++++++++++++++------------- 1 file changed, 60 insertions(+), 45 deletions(-) diff --git a/src/app/(event)/add-event/page.tsx b/src/app/(event)/add-event/page.tsx index d6867b5..a23d569 100644 --- a/src/app/(event)/add-event/page.tsx +++ b/src/app/(event)/add-event/page.tsx @@ -29,6 +29,15 @@ export default function AddEvent() { formState: { errors }, } = useForm(); + const [minDate, setMinDate] = useState(""); + useEffect(() => { + // Get the current date and time + const now = new Date(); + const isoDate = now.toISOString().slice(0, 16); // Format as 'YYYY-MM-DDTHH:MM' + + setMinDate(isoDate); // Set the minimum date and time to the current time + }, []); + useEffect(() => { userDetails() .then((res: any) => { @@ -198,51 +207,57 @@ export default function AddEvent() { />
-
- - -
- -
- - -
- -
- - -
- -
- - -
+ {/* Event Registration Start Date */} +
+ + +
+ + {/* Event Registration End Date */} +
+ + +
+ + {/* Event Start Date */} +
+ + +
+ + {/* Event End Date */} +
+ + +