From 1fba7ff18afda4121cb85a22b36573f18fa2e4ad Mon Sep 17 00:00:00 2001 From: RafsanAmin Date: Fri, 11 Oct 2024 16:53:39 +0600 Subject: [PATCH 1/2] up --- package-lock.json | 262 ++---------------- package.json | 2 +- src/app/api/memberdata/route.ts | 2 - src/app/club/(user-handle)/login/page.tsx | 1 - .../club/Components/Admin/AdminEventCard.tsx | 7 +- src/app/club/Components/Admin/EditConfig.tsx | 2 +- src/app/club/Components/Events/EventCard.tsx | 18 +- src/app/club/Components/Home/DamianPopUp.tsx | 2 +- .../club/Components/Participate/Question.tsx | 28 +- .../club/admin/(adminpanel)/users/page.tsx | 1 - .../club/admin/eventEdit/[eventID]/page.tsx | 1 - src/app/club/admin/login/page.tsx | 1 - src/app/club/admin/rankers/[id]/page.tsx | 2 - .../club/eventdetails/[id]/Eligibility.tsx | 8 + src/app/club/eventdetails/[id]/page.tsx | 1 - src/app/club/events/page.tsx | 2 - src/app/globals.css | 25 +- src/util/Time.ts | 16 ++ 18 files changed, 91 insertions(+), 290 deletions(-) create mode 100644 src/util/Time.ts diff --git a/package-lock.json b/package-lock.json index cf14f8b..a30a6d9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28,9 +28,9 @@ "react-firebase-hooks": "^5.1.1", "react-icons": "^5.0.1", "react-markdown": "^9.0.1", - "react-syntax-highlighter": "^15.5.0", "react-toastify": "^10.0.5", "react-zoom-pan-pinch": "^3.4.3", + "rehype-highlight": "^7.0.0", "rehype-katex": "^7.0.1", "remark-gfm": "^4.0.0", "remark-math": "^6.0.0", @@ -8976,18 +8976,6 @@ "reusify": "^1.0.4" } }, - "node_modules/fault": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/fault/-/fault-1.0.4.tgz", - "integrity": "sha512-CJ0HCB5tL5fYTEA7ToAq5+kTwd++Borf1/bifxd9iT70QcXr4MRrO3Llf8Ifs70q+SJcGHFtnIE/Nw6giCtECA==", - "dependencies": { - "format": "^0.2.0" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, "node_modules/faye-websocket": { "version": "0.11.4", "resolved": "https://registry.npmjs.org/faye-websocket/-/faye-websocket-0.11.4.tgz", @@ -9241,14 +9229,6 @@ "node": ">= 0.12" } }, - "node_modules/format": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/format/-/format-0.2.2.tgz", - "integrity": "sha512-wzsgA6WOq+09wrU1tsJ09udeR/YZRaeArL9e1wPbFg3GG2yDnC2ldKpxs4xunpFF9DgqCqOIra3bc1HWrJ37Ww==", - "engines": { - "node": ">=0.4.x" - } - }, "node_modules/forwarded": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", @@ -9915,15 +9895,6 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/hast-util-parse-selector": { - "version": "2.2.5", - "resolved": "https://registry.npmjs.org/hast-util-parse-selector/-/hast-util-parse-selector-2.2.5.tgz", - "integrity": "sha512-7j6mrk/qqkSehsM92wQjdIgWM2/BW61u/53G6xmC8i1OmEdKLHbk419QKQUjz6LglWsfqoiHmyMRkP1BGjecNQ==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, "node_modules/hast-util-to-jsx-runtime": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/hast-util-to-jsx-runtime/-/hast-util-to-jsx-runtime-2.3.0.tgz", @@ -9977,71 +9948,12 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/hastscript": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/hastscript/-/hastscript-6.0.0.tgz", - "integrity": "sha512-nDM6bvd7lIqDUiYEiu5Sl/+6ReP0BMk/2f4U/Rooccxkj0P5nm+acM5PrGJ/t5I8qPGiqZSE6hVAwZEdZIvP4w==", - "dependencies": { - "@types/hast": "^2.0.0", - "comma-separated-tokens": "^1.0.0", - "hast-util-parse-selector": "^2.0.0", - "property-information": "^5.0.0", - "space-separated-tokens": "^1.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" - } - }, - "node_modules/hastscript/node_modules/@types/hast": { - "version": "2.3.10", - "resolved": "https://registry.npmjs.org/@types/hast/-/hast-2.3.10.tgz", - "integrity": "sha512-McWspRw8xx8J9HurkVBfYj0xKoE25tOFlHGdx4MJ5xORQrMGZNqJhVQWaIbm6Oyla5kYOXtDiopzKRJzEOkwJw==", - "dependencies": { - "@types/unist": "^2" - } - }, - "node_modules/hastscript/node_modules/@types/unist": { - "version": "2.0.11", - "resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.11.tgz", - "integrity": "sha512-CmBKiL6NNo/OqgmMn95Fk9Whlp2mtvIv+KNpQKN2F4SjvrEesubTRWGYSg+BnWZOnlCaSTU1sMpsBOzgbYhnsA==" - }, - "node_modules/hastscript/node_modules/comma-separated-tokens": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/comma-separated-tokens/-/comma-separated-tokens-1.0.8.tgz", - "integrity": "sha512-GHuDRO12Sypu2cV70d1dkA2EUmXHgntrzbpvOB+Qy+49ypNfGgFQIC2fhhXbnyrJRynDCAARsT7Ou0M6hirpfw==", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/hastscript/node_modules/property-information": { - "version": "5.6.0", - "resolved": "https://registry.npmjs.org/property-information/-/property-information-5.6.0.tgz", - "integrity": "sha512-YUHSPk+A30YPv+0Qf8i9Mbfe/C0hdPXk1s1jPVToV8pk8BQtpw10ct89Eo7OWkutrwqvT0eicAxlOg3dOAu8JA==", - "dependencies": { - "xtend": "^4.0.0" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/hastscript/node_modules/space-separated-tokens": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/space-separated-tokens/-/space-separated-tokens-1.1.5.tgz", - "integrity": "sha512-q/JSVd1Lptzhf5bkYm4ob4iWPjx0KiRe3sRFBNrVqbJkFaBm5vbbowy1mymoPNLRa52+oadOhJ+K49wsSeSjTA==", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, "node_modules/highlight.js": { - "version": "10.7.3", - "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-10.7.3.tgz", - "integrity": "sha512-tzcUFauisWKNHaRkN4Wjl/ZA07gENAjFl3J/c480dprkGTg5EQstgaNFqBfUqCq54kZRIEcreTsAgF/m2quD7A==", + "version": "11.9.0", + "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-11.9.0.tgz", + "integrity": "sha512-fJ7cW7fQGCYAkgv4CPfwFHrfd/cLS4Hau96JuJ+ZTOWhjnhoeN1ub1tFmALm/+lW5z4WCAuAV9bm05AP0mS6Gw==", "engines": { - "node": "*" + "node": ">=12.0.0" } }, "node_modules/html-entities": { @@ -11266,12 +11178,13 @@ } }, "node_modules/lowlight": { - "version": "1.20.0", - "resolved": "https://registry.npmjs.org/lowlight/-/lowlight-1.20.0.tgz", - "integrity": "sha512-8Ktj+prEb1RoCPkEOrPMYUN/nCggB7qAWe3a7OpMjWQkh3l2RD5wKRQ+o8Q8YuI9RG/xs95waaI/E6ym/7NsTw==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/lowlight/-/lowlight-3.1.0.tgz", + "integrity": "sha512-CEbNVoSikAxwDMDPjXlqlFYiZLkDJHwyGu/MfOsJnF3d7f3tds5J3z8s/l9TMXhzfsJCCJEAsD78842mwmg0PQ==", "dependencies": { - "fault": "^1.0.0", - "highlight.js": "~10.7.0" + "@types/hast": "^3.0.0", + "devlop": "^1.0.0", + "highlight.js": "~11.9.0" }, "funding": { "type": "github", @@ -13273,14 +13186,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/prismjs": { - "version": "1.29.0", - "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.29.0.tgz", - "integrity": "sha512-Kx/1w86q/epKcmte75LNrEoT+lX8pBpavuAbvJWRXar7Hz8jrtF+e3vY751p0R8H9HdArwaCTNDDzHg/ScJK1Q==", - "engines": { - "node": ">=6" - } - }, "node_modules/prop-types": { "version": "15.8.1", "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", @@ -13573,21 +13478,6 @@ } } }, - "node_modules/react-syntax-highlighter": { - "version": "15.5.0", - "resolved": "https://registry.npmjs.org/react-syntax-highlighter/-/react-syntax-highlighter-15.5.0.tgz", - "integrity": "sha512-+zq2myprEnQmH5yw6Gqc8lD55QHnpKaU8TOcFeC/Lg/MQSs8UknEA0JC4nTZGFAXC2J2Hyj/ijJ7NlabyPi2gg==", - "dependencies": { - "@babel/runtime": "^7.3.1", - "highlight.js": "^10.4.1", - "lowlight": "^1.17.0", - "prismjs": "^1.27.0", - "refractor": "^3.6.0" - }, - "peerDependencies": { - "react": ">= 0.14.0" - } - }, "node_modules/react-textarea-autosize": { "version": "8.5.3", "resolved": "https://registry.npmjs.org/react-textarea-autosize/-/react-textarea-autosize-8.5.3.tgz", @@ -13699,112 +13589,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/refractor": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/refractor/-/refractor-3.6.0.tgz", - "integrity": "sha512-MY9W41IOWxxk31o+YvFCNyNzdkc9M20NoZK5vq6jkv4I/uh2zkWcfudj0Q1fovjUQJrNewS9NMzeTtqPf+n5EA==", - "dependencies": { - "hastscript": "^6.0.0", - "parse-entities": "^2.0.0", - "prismjs": "~1.27.0" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/refractor/node_modules/character-entities": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/character-entities/-/character-entities-1.2.4.tgz", - "integrity": "sha512-iBMyeEHxfVnIakwOuDXpVkc54HijNgCyQB2w0VfGQThle6NXn50zU6V/u+LDhxHcDUPojn6Kpga3PTAD8W1bQw==", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/refractor/node_modules/character-entities-legacy": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/character-entities-legacy/-/character-entities-legacy-1.1.4.tgz", - "integrity": "sha512-3Xnr+7ZFS1uxeiUDvV02wQ+QDbc55o97tIV5zHScSPJpcLm/r0DFPcoY3tYRp+VZukxuMeKgXYmsXQHO05zQeA==", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/refractor/node_modules/character-reference-invalid": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/character-reference-invalid/-/character-reference-invalid-1.1.4.tgz", - "integrity": "sha512-mKKUkUbhPpQlCOfIuZkvSEgktjPFIsZKRRbC6KWVEMvlzblj3i3asQv5ODsrwt0N3pHAEvjP8KTQPHkp0+6jOg==", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/refractor/node_modules/is-alphabetical": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/is-alphabetical/-/is-alphabetical-1.0.4.tgz", - "integrity": "sha512-DwzsA04LQ10FHTZuL0/grVDk4rFoVH1pjAToYwBrHSxcrBIGQuXrQMtD5U1b0U2XVgKZCTLLP8u2Qxqhy3l2Vg==", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/refractor/node_modules/is-alphanumerical": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/is-alphanumerical/-/is-alphanumerical-1.0.4.tgz", - "integrity": "sha512-UzoZUr+XfVz3t3v4KyGEniVL9BDRoQtY7tOyrRybkVNjDFWyo1yhXNGrrBTQxp3ib9BLAWs7k2YKBQsFRkZG9A==", - "dependencies": { - "is-alphabetical": "^1.0.0", - "is-decimal": "^1.0.0" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/refractor/node_modules/is-decimal": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/is-decimal/-/is-decimal-1.0.4.tgz", - "integrity": "sha512-RGdriMmQQvZ2aqaQq3awNA6dCGtKpiDFcOzrTWrDAT2MiWrKQVPmxLGHl7Y2nNu6led0kEyoX0enY0qXYsv9zw==", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/refractor/node_modules/is-hexadecimal": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/is-hexadecimal/-/is-hexadecimal-1.0.4.tgz", - "integrity": "sha512-gyPJuv83bHMpocVYoqof5VDiZveEoGoFL8m3BXNb2VW8Xs+rz9kqO8LOQ5DH6EsuvilT1ApazU0pyl+ytbPtlw==", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/refractor/node_modules/parse-entities": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/parse-entities/-/parse-entities-2.0.0.tgz", - "integrity": "sha512-kkywGpCcRYhqQIchaWqZ875wzpS/bMKhz5HnN3p7wveJTkTtyAB/AlnS0f8DFSqYW1T82t6yEAkEcB+A1I3MbQ==", - "dependencies": { - "character-entities": "^1.0.0", - "character-entities-legacy": "^1.0.0", - "character-reference-invalid": "^1.0.0", - "is-alphanumerical": "^1.0.0", - "is-decimal": "^1.0.0", - "is-hexadecimal": "^1.0.0" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/refractor/node_modules/prismjs": { - "version": "1.27.0", - "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.27.0.tgz", - "integrity": "sha512-t13BGPUlFDR7wRB5kQDG4jjl7XeuH6jbJGt11JHPL96qwsEHNX2+68tFXqc1/k+/jALsbSWJKUOT/hcYAZ5LkA==", - "engines": { - "node": ">=6" - } - }, "node_modules/regenerate": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.2.tgz", @@ -13886,6 +13670,22 @@ "jsesc": "bin/jsesc" } }, + "node_modules/rehype-highlight": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/rehype-highlight/-/rehype-highlight-7.0.0.tgz", + "integrity": "sha512-QtobgRgYoQaK6p1eSr2SD1i61f7bjF2kZHAQHxeCHAuJf7ZUDMvQ7owDq9YTkmar5m5TSUol+2D3bp3KfJf/oA==", + "dependencies": { + "@types/hast": "^3.0.0", + "hast-util-to-text": "^4.0.0", + "lowlight": "^3.0.0", + "unist-util-visit": "^5.0.0", + "vfile": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, "node_modules/rehype-katex": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/rehype-katex/-/rehype-katex-7.0.1.tgz", @@ -16473,14 +16273,6 @@ "node": ">=0.8" } }, - "node_modules/xtend": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", - "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", - "engines": { - "node": ">=0.4" - } - }, "node_modules/y18n": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", diff --git a/package.json b/package.json index 1c09bad..6c01786 100644 --- a/package.json +++ b/package.json @@ -37,9 +37,9 @@ "react-firebase-hooks": "^5.1.1", "react-icons": "^5.0.1", "react-markdown": "^9.0.1", - "react-syntax-highlighter": "^15.5.0", "react-toastify": "^10.0.5", "react-zoom-pan-pinch": "^3.4.3", + "rehype-highlight": "^7.0.0", "rehype-katex": "^7.0.1", "remark-gfm": "^4.0.0", "remark-math": "^6.0.0", diff --git a/src/app/api/memberdata/route.ts b/src/app/api/memberdata/route.ts index 6109ca0..ba5e42a 100644 --- a/src/app/api/memberdata/route.ts +++ b/src/app/api/memberdata/route.ts @@ -16,8 +16,6 @@ export async function POST(req: NextRequest) { const member = await memberDOC.json(); - console.log(member); - if (!memberDOC.ok) { return NextResponse.json( { error: "No such Club Member exists" }, diff --git a/src/app/club/(user-handle)/login/page.tsx b/src/app/club/(user-handle)/login/page.tsx index 0811953..9442ad7 100644 --- a/src/app/club/(user-handle)/login/page.tsx +++ b/src/app/club/(user-handle)/login/page.tsx @@ -53,7 +53,6 @@ const Page = () => { }); }; useEffect(() => { - console.log(auth); setAuthLoading(true); if (userAuth) { Router.push("/club/profile"); diff --git a/src/app/club/Components/Admin/AdminEventCard.tsx b/src/app/club/Components/Admin/AdminEventCard.tsx index 8668ec7..1319f35 100644 --- a/src/app/club/Components/Admin/AdminEventCard.tsx +++ b/src/app/club/Components/Admin/AdminEventCard.tsx @@ -4,6 +4,7 @@ import { BsStopwatch } from "react-icons/bs"; import { timeValue } from "../Time"; import { Timestamp } from "firebase/firestore"; import _L0 from "@/util/leadingzero"; +import { RemainingTimeHM } from "@/util/Time"; const AdminEventCard = ({ title, @@ -25,6 +26,7 @@ const AdminEventCard = ({ category: string; }) => { const dateData = timeValue(date); + const remainingTime = RemainingTimeHM(date, endDate); return (
@@ -45,9 +47,8 @@ const AdminEventCard = ({ {title}
- {timeValue(endDate).hour - dateData.hour > 0 && - `${Math.abs(timeValue(endDate).hour - dateData.hour)}H : `} - {Math.abs(timeValue(endDate).minute - dateData.minute)}M + {remainingTime.hours > 0 && `${remainingTime.hours}h `} + {remainingTime.mins}min
{category}
diff --git a/src/app/club/Components/Admin/EditConfig.tsx b/src/app/club/Components/Admin/EditConfig.tsx index 214697c..3f604bd 100644 --- a/src/app/club/Components/Admin/EditConfig.tsx +++ b/src/app/club/Components/Admin/EditConfig.tsx @@ -36,7 +36,7 @@ const EditConfig = () => { } setLoading(false); }; - console.log(configs); + return (
endDate; + const dateData = timeValue(date); + const remainingTime = RemainingTimeHM(date, endDate); + return (
{ongoing && ( -
+
Ongoing
)} @@ -51,6 +56,12 @@ const EventCard = ({
)} + {ended && ( +
+ Ended +
+ )} +
- {timeValue(endDate).hour - dateData.hour > 0 && - `${Math.abs(timeValue(endDate).hour - dateData.hour)}H : `} - {Math.abs(timeValue(endDate).minute - dateData.minute)}M + {remainingTime.hours > 0 && `${remainingTime.hours}h `} + {remainingTime.mins}min

{desc} diff --git a/src/app/club/Components/Home/DamianPopUp.tsx b/src/app/club/Components/Home/DamianPopUp.tsx index b208821..17fc04a 100644 --- a/src/app/club/Components/Home/DamianPopUp.tsx +++ b/src/app/club/Components/Home/DamianPopUp.tsx @@ -30,7 +30,7 @@ const DamianPopUp = () => { const [roll, setRoll] = useState(""); useEffect(() => { - if (!userDataLoading && userData.ndc_roll == "") { + if (!userDataLoading && userData?.ndc_roll) { onOpen(); } }, [userData, userDataLoading]); diff --git a/src/app/club/Components/Participate/Question.tsx b/src/app/club/Components/Participate/Question.tsx index 9811d60..3714a20 100644 --- a/src/app/club/Components/Participate/Question.tsx +++ b/src/app/club/Components/Participate/Question.tsx @@ -1,12 +1,12 @@ import { useEffect, useMemo, useState } from "react"; import Markdown from "react-markdown"; import SyntaxHighlighter from "react-syntax-highlighter"; -import { oneLight } from "react-syntax-highlighter/dist/esm/styles/prism"; import rehypeKatex from "rehype-katex"; import remarkGfm from "remark-gfm"; import remarkMath from "remark-math"; import "katex/dist/katex.min.css"; -import { docco } from "react-syntax-highlighter/dist/esm/styles/hljs"; +import rehypeHighlight from "rehype-highlight"; +import "highlight.js/styles/atom-one-light.css"; interface questionInterface { mcq: boolean; @@ -59,12 +59,9 @@ const Question = ({ if (isListItem || isNextLineListItem) return line; - if (line.trim() === "\\") return line.replace("\\", " \n"); - - return line + " \n"; + return line + "\n"; }) - .join("\n") - .replaceAll("~~", "\n --- \n"); + .join("\n"); }, []); return ( @@ -79,22 +76,7 @@ const Question = ({ - {String(children).replace(/\n$/, "")} - - ) : ( - - {children} - - ); - }, - }} + rehypePlugins={[rehypeKatex, rehypeHighlight]} > {modifiedText} diff --git a/src/app/club/admin/(adminpanel)/users/page.tsx b/src/app/club/admin/(adminpanel)/users/page.tsx index 89778b5..896dcff 100644 --- a/src/app/club/admin/(adminpanel)/users/page.tsx +++ b/src/app/club/admin/(adminpanel)/users/page.tsx @@ -78,7 +78,6 @@ const Page = () => { countSnap.then((r) => r.data()).then((r) => setTotalUsers(r.count)); getDocs(onFilterQuery(false)).then((data) => { - console.log(data.docs[data.docs.length - 1]); setLastUserDoc(data.docs[data.docs.length - 1]); const tempArr: any[] = []; data.docs.forEach((e, i) => { diff --git a/src/app/club/admin/eventEdit/[eventID]/page.tsx b/src/app/club/admin/eventEdit/[eventID]/page.tsx index 2b1e5d8..1752a85 100644 --- a/src/app/club/admin/eventEdit/[eventID]/page.tsx +++ b/src/app/club/admin/eventEdit/[eventID]/page.tsx @@ -105,7 +105,6 @@ const Page = ({ params }: { params: { eventID: string } }) => { }) .then((r) => r.json()) .then((resp) => { - console.log(resp); setAdminAuth(resp.auth || false); setAuthLoading(false); }) diff --git a/src/app/club/admin/login/page.tsx b/src/app/club/admin/login/page.tsx index 83b8453..2a03783 100644 --- a/src/app/club/admin/login/page.tsx +++ b/src/app/club/admin/login/page.tsx @@ -56,7 +56,6 @@ const Page = () => { }) .then((r) => r.json()) .then((resp) => { - console.log(resp); if (resp.auth) { Router.push("/club/admin"); } else { diff --git a/src/app/club/admin/rankers/[id]/page.tsx b/src/app/club/admin/rankers/[id]/page.tsx index c4c0f43..80d457e 100644 --- a/src/app/club/admin/rankers/[id]/page.tsx +++ b/src/app/club/admin/rankers/[id]/page.tsx @@ -671,8 +671,6 @@ const EditEventData = ({ const [error, setError] = useState(""); - console.log(data); - const updateData = async () => { await updateDoc( doc(db, "answers", id, "eventparticipant", uid), diff --git a/src/app/club/eventdetails/[id]/Eligibility.tsx b/src/app/club/eventdetails/[id]/Eligibility.tsx index f3e1791..e23e34f 100644 --- a/src/app/club/eventdetails/[id]/Eligibility.tsx +++ b/src/app/club/eventdetails/[id]/Eligibility.tsx @@ -16,6 +16,14 @@ const Eligibility = ({ if (intra_club && userData && userData.ndc_id != "") return

; if (publicQuiz && userData) return
; + if (!userData) { + return ( +
+ Please login to participate +
+ ); + } + return (
You are not eligible for this exam diff --git a/src/app/club/eventdetails/[id]/page.tsx b/src/app/club/eventdetails/[id]/page.tsx index 85f79ac..036b97a 100644 --- a/src/app/club/eventdetails/[id]/page.tsx +++ b/src/app/club/eventdetails/[id]/page.tsx @@ -57,7 +57,6 @@ const page = async ({ params }: { params: ParamType }) => {

- {"Category>"} {`${data?.category}>`}

diff --git a/src/app/club/events/page.tsx b/src/app/club/events/page.tsx index a9864e4..694f06f 100644 --- a/src/app/club/events/page.tsx +++ b/src/app/club/events/page.tsx @@ -36,8 +36,6 @@ const page = async () => { ...e.data(), })); - console.log(eventList); - return (
diff --git a/src/app/globals.css b/src/app/globals.css index a1f9d69..3a05023 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -354,35 +354,38 @@ p { color: #3b82f6; } .ques h1 { - font-size: 2.25rem; - padding-top: 2.5rem; - padding-bottom: 1rem; - font-weight: 400; + font-size: 1.75rem; + padding-top: 0.5rem; + padding-bottom: 0.25rem; + font-weight: 700; + font-family: "Inter"; } /* .ques h1::first-letter { color: #2f4770; } */ .ques h2 { - font-size: 1.875rem; - padding-top: 2.5rem; - padding-bottom: 0.5rem; - font-weight: 400; + font-size: 1.5rem; + padding-top: 0.5rem; + padding-bottom: 0.25rem; + font-weight: 700; + font-family: "Inter"; } .ques h3, .ques h4, .ques h5, .ques h6 { - font-size: 1.5rem; + font-size: 1.25rem; padding-top: 0.25rem; padding-bottom: 0.25rem; - font-family: Nunito; + font-family: "Inter"; + font-weight: 700; } .ques h4, .ques h5, .ques h6 { - font-size: 1.25rem !important; + font-size: 1.15rem !important; } .ques table { border: 1px solid #e4e4e7; diff --git a/src/util/Time.ts b/src/util/Time.ts new file mode 100644 index 0000000..06abe01 --- /dev/null +++ b/src/util/Time.ts @@ -0,0 +1,16 @@ +import { timeValue } from "@/app/club/Components/Time"; + +export const RemainingTimeHM = (before: any, after: any) => { + let hours = timeValue(after).hour - timeValue(before).hour; + let mins = timeValue(after).minute - timeValue(before).minute; + + if (mins < 0) { + mins = 60 + mins; + hours--; + } + + return { + hours, + mins, + }; +}; From f83564808051cc0939c529bad83557a2c140e029 Mon Sep 17 00:00:00 2001 From: RafsanAmin Date: Fri, 11 Oct 2024 18:16:40 +0600 Subject: [PATCH 2/2] UP --- .../club/Components/Admin/AddQuestions.tsx | 29 ++++-- .../club/admin/eventEdit/[eventID]/page.tsx | 99 +++++++++++++++---- 2 files changed, 99 insertions(+), 29 deletions(-) diff --git a/src/app/club/Components/Admin/AddQuestions.tsx b/src/app/club/Components/Admin/AddQuestions.tsx index a732fd1..433272e 100644 --- a/src/app/club/Components/Admin/AddQuestions.tsx +++ b/src/app/club/Components/Admin/AddQuestions.tsx @@ -40,14 +40,17 @@ const AddQuestions = ({ questionsData, answersData, setData, + setQues, + setAns, }: { questionsData: any[]; answersData: any[]; setData: (questionData: any, answerData: any) => void; + setQues?: (s: any) => void; + setAns?: (s: any) => void; }) => { - const [questions, setQuestions] = - useState(questionsData); - const [answers, setAnswers] = useState(answersData); + const [questions, setQuestions] = useState([]); + const [answers, setAnswers] = useState([]); useEffect(() => { setAnswers(answersData); @@ -68,7 +71,6 @@ const AddQuestions = ({ const [point, setPoint] = useState(1); - const setOption = (i: number, value: string) => { switch (i) { case 0: @@ -94,7 +96,7 @@ const AddQuestions = ({ const addQuestion = () => { setQuestions((oldValue: any) => { - return [ + let sqd = [ ...oldValue, { question: question, @@ -106,10 +108,12 @@ const AddQuestions = ({ option3: option3, }, ]; + setQues && setQues(sqd); + return sqd; }); setAnswers((oldValue: any) => { - return [ + let sad = [ ...oldValue, { mcq: isMCQ, @@ -118,6 +122,10 @@ const AddQuestions = ({ correctAnswers: correctAnswers, }, ]; + + setAns && setAns(sad); + + return sad; }); setQuestion(""); @@ -173,7 +181,12 @@ const AddQuestions = ({ }; useEffect(() => { - setData(questions, answers); + console.log("-------------"); + + console.log("qb", questions); + console.log("ab", answers); + + console.log("-------------"); }, [questions, answers]); return ( @@ -198,7 +211,7 @@ const AddQuestions = ({ correctOption={answers[i].correctOption} correctAnswers={answers[i].correctAnswers} index={i} - key={i} + key={i + Math.random()} onValueChange={onValueChange} deleteQuestion={deleteQuestion} /> diff --git a/src/app/club/admin/eventEdit/[eventID]/page.tsx b/src/app/club/admin/eventEdit/[eventID]/page.tsx index 1752a85..0b00b43 100644 --- a/src/app/club/admin/eventEdit/[eventID]/page.tsx +++ b/src/app/club/admin/eventEdit/[eventID]/page.tsx @@ -117,7 +117,7 @@ const Page = ({ params }: { params: { eventID: string } }) => { setAdminAuth(false); setAuthLoading(false); } - + console.log("loaded"); if (params.eventID != "new") { const event = getDoc(doc(db, "events", params.eventID)).then((event) => { if (event.exists()) { @@ -154,7 +154,7 @@ const Page = ({ params }: { params: { eventID: string } }) => { } else { setNotfound(false); } - }, [user]); + }, [params.eventID, user]); const handleSubmit = async (event: any) => { event.preventDefault(); @@ -288,6 +288,33 @@ const Page = ({ params }: { params: { eventID: string } }) => { }); }; + const savelocal = async (event: any) => { + localStorage.setItem( + `event.${eventUID}`, + JSON.stringify({ + questions, + answers, + }), + ); + toast.info("Saved questions and answers."); + goToAdminPanel(); + }; + + const loadLocal = async () => { + const local = JSON.parse(localStorage.getItem(`event.${eventUID}`) || "{}"); + console.dir(local); + setData(local?.questions, local?.answers); + toast.info("Loaded local questions and answers."); + }; + + useEffect(() => { + console.log("-------------"); + + console.log("q", questions); + console.log("a", answers); + + console.log("-------------"); + }, [questions, answers]); const [notfound, setNotfound] = useState(false); const [changeImage, setChangeImage] = useState(); @@ -595,6 +622,8 @@ const Page = ({ params }: { params: { eventID: string } }) => { questionsData={questions} answersData={answers} setData={setData} + setQues={(s) => setQuestions(s)} + setAns={(s) => setAnswers(s)} /> @@ -651,26 +680,54 @@ const Page = ({ params }: { params: { eventID: string } }) => { )}
-
+
{params.eventID != "new" && ( -
- -
+ <> +
+ +
+
+ +
+
+ +
+ )}