From c2caa61f6fb385af9c2830076764a3f2ccc87413 Mon Sep 17 00:00:00 2001 From: Chirag Bhalotia Date: Tue, 26 Dec 2023 18:19:49 +0530 Subject: [PATCH] completed free job --- components/RegisterDialog/index.tsx | 227 ++++++++++++++++++++++++++++ components/ui/Navbar/index.tsx | 226 ++++++++++++++------------- package.json | 3 +- yarn.lock | 65 +++++++- 4 files changed, 411 insertions(+), 110 deletions(-) create mode 100644 components/RegisterDialog/index.tsx diff --git a/components/RegisterDialog/index.tsx b/components/RegisterDialog/index.tsx new file mode 100644 index 0000000..9e59d13 --- /dev/null +++ b/components/RegisterDialog/index.tsx @@ -0,0 +1,227 @@ +'use client' + +import { Fragment } from 'react' +import { Dialog, Transition } from '@headlessui/react' +import { useForm } from 'react-hook-form' +import { + RegisterForm, + registerFormSchema, +} from '@/validators/register.validator' +import { zodResolver } from '@hookform/resolvers/zod' +import toast from 'react-hot-toast' +import axios from 'axios' + +export default function RegisterDialog({ + open, + setOpen, +}: { + open: boolean + setOpen: (val: boolean) => void +}) { + const { + register, + handleSubmit, + formState: { errors }, + reset, + } = useForm({ + resolver: zodResolver(registerFormSchema), + }) + const formSubmit = async (data: RegisterForm) => { + if (data.uni_id === '') data.uni_id = 'N/A' + if (data.uni_name === '') data.uni_name = 'N/A' + + //api call + try { + await axios.post( + 'https://emerald-informed-promoted-dem.trycloudflare.com/interest', + data + ) + toast.success('Successfully Submitted Form') + } catch (err) { + toast.error('Error Submitting Form') + } finally { + setOpen(false) + reset() + } + } + + return ( + + + +
+ + +
+
+ + +
+
+ +
+ +
+ {errors.name && ( +
+ {errors.name.message} +
+ )} +
+
+ +
+ +
+ {errors.email && ( +
+ {errors.email.message} +
+ )} +
+
+ +
+ +
+ {errors.contact_no && ( +
+ {errors.contact_no.message} +
+ )} +
+
+ +
+ +
+ {errors.uni_id && ( +
+ {errors.uni_id.message} +
+ )} +
+
+ +
+ +
+ {errors.uni_name && ( +
+ {errors.uni_name.message} +
+ )} +
+
+ +
+ +
+ {errors.where_you_reside && ( +
+ { + errors.where_you_reside + .message + } +
+ )} +
+ +
+ +
+
+
+
+
+
+
+
+ ) +} diff --git a/components/ui/Navbar/index.tsx b/components/ui/Navbar/index.tsx index 31f7843..bcb5e0e 100644 --- a/components/ui/Navbar/index.tsx +++ b/components/ui/Navbar/index.tsx @@ -1,134 +1,150 @@ 'use client' -import React, { Fragment } from 'react' +import React, { Fragment, useState } from 'react' import { Disclosure, Menu, Transition } from '@headlessui/react' -import { Bars3Icon, BellIcon, XMarkIcon,HomeIcon } from '@heroicons/react/24/outline' +import { + Bars3Icon, + BellIcon, + XMarkIcon, + HomeIcon, +} from '@heroicons/react/24/outline' import { cn } from '@/lib/utils' +import RegisterDialog from '@/components/RegisterDialog' const navigation = [ - { name: 'Join Discord', href: 'https://s.encryptedge.in/discord', current: false }, + { + name: 'Join Discord', + href: 'https://s.encryptedge.in/discord', + current: false, + }, ] const Navbar = () => { + const [registerOpen, setRegisterOpen] = useState(false) return ( - - {({ open }) => ( - <> -
-
-
-
- RCS CTF Logo - {/*

+ <> + + {({ open }) => ( + <> +
+
+
+
+ RCS CTF Logo + {/*

RCS CTF 2024

*/} - -
- -
- {/* Mobile menu button */} - - - Open main menu - - {open ? ( - +
+ {/* Mobile menu button */} + + + Open main menu + + {open ? ( + +
-
- -
- {navigation.map((item) => ( + +
+ {navigation.map((item) => ( + + {item.name} + + ))} setRegisterOpen(true)} > - {item.name} + Register - ))} - - Register - -
-
- - )} - +
+
+ + )} + + + ) } diff --git a/package.json b/package.json index 671bc3f..cc6c6f9 100644 --- a/package.json +++ b/package.json @@ -12,13 +12,14 @@ "dependencies": { "@headlessui/react": "^1.7.15", "@heroicons/react": "^2.0.18", - "@hookform/resolvers": "^3.1.1", + "@hookform/resolvers": "^3.3.3", "@tailwindcss/forms": "^0.5.3", "@types/node": "20.3.3", "@types/react": "18.2.14", "@types/react-dom": "18.2.6", "@vercel/analytics": "^1.1.1", "autoprefixer": "10.4.14", + "axios": "^1.6.2", "class-variance-authority": "^0.6.1", "clsx": "^1.2.1", "eslint": "8.44.0", diff --git a/yarn.lock b/yarn.lock index a334e3b..a36ccea 100644 --- a/yarn.lock +++ b/yarn.lock @@ -63,10 +63,10 @@ resolved "https://registry.yarnpkg.com/@heroicons/react/-/react-2.0.18.tgz#f80301907c243df03c7e9fd76c0286e95361f7c1" integrity sha512-7TyMjRrZZMBPa+/5Y8lN0iyvUU/01PeMGX2+RE7cQWpEUIcb4QotzUObFkJDejj/HUH4qjP/eQ0gzzKs2f+6Yw== -"@hookform/resolvers@^3.1.1": - version "3.3.0" - resolved "https://registry.yarnpkg.com/@hookform/resolvers/-/resolvers-3.3.0.tgz#5e37c2926b827d2577c1bd2676a2a705984b334d" - integrity sha512-tgK3nWlfFLlqhqpXZmFMP3RN5E7mlbGfnM2h2ILVsW1TNGuFSod0ePW0grlIY2GAbL4pJdtmOT4HQSZsTwOiKg== +"@hookform/resolvers@^3.3.3": + version "3.3.3" + resolved "https://registry.yarnpkg.com/@hookform/resolvers/-/resolvers-3.3.3.tgz#a90c786e5564e58a029d157347e1f2965d02e64f" + integrity sha512-bOMxKkSD3zWcS11TKoUQ8O0ZqKslFohvUsPKSrdCHiuEuMjRo/u3cq9YRJD/+xtNGYup++XD2LkjhegP5XENiw== "@humanwhocodes/config-array@^0.11.10": version "0.11.10" @@ -464,6 +464,11 @@ asynciterator.prototype@^1.0.0: dependencies: has-symbols "^1.0.3" +asynckit@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" + integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q== + autoprefixer@10.4.14: version "10.4.14" resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-10.4.14.tgz#e28d49902f8e759dd25b153264e862df2705f79d" @@ -486,6 +491,15 @@ axe-core@^4.6.2: resolved "https://registry.yarnpkg.com/axe-core/-/axe-core-4.7.2.tgz#040a7342b20765cb18bb50b628394c21bccc17a0" integrity sha512-zIURGIS1E1Q4pcrMjp+nnEh+16G56eG/MUllJH8yEvw7asDo7Ac9uhC9KIH5jzpITueEZolfYglnCGIuSBz39g== +axios@^1.6.2: + version "1.6.2" + resolved "https://registry.yarnpkg.com/axios/-/axios-1.6.2.tgz#de67d42c755b571d3e698df1b6504cde9b0ee9f2" + integrity sha512-7i24Ri4pmDRfJTR7LDBhsOTtcm+9kjX5WiY1X3wIisx6G9So3pfMkEiU7emUBe46oceVImccTEM3k6C5dbVW8A== + dependencies: + follow-redirects "^1.15.0" + form-data "^4.0.0" + proxy-from-env "^1.1.0" + axobject-query@^3.1.1: version "3.2.1" resolved "https://registry.yarnpkg.com/axobject-query/-/axobject-query-3.2.1.tgz#39c378a6e3b06ca679f29138151e45b2b32da62a" @@ -610,6 +624,13 @@ color-name@~1.1.4: resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== +combined-stream@^1.0.8: + version "1.0.8" + resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" + integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg== + dependencies: + delayed-stream "~1.0.0" + commander@^4.0.0: version "4.1.1" resolved "https://registry.yarnpkg.com/commander/-/commander-4.1.1.tgz#9fd602bd936294e9e9ef46a3f4d6964044b18068" @@ -671,6 +692,11 @@ define-properties@^1.1.3, define-properties@^1.1.4, define-properties@^1.2.0: has-property-descriptors "^1.0.0" object-keys "^1.1.1" +delayed-stream@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" + integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ== + dequal@^2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/dequal/-/dequal-2.0.3.tgz#2644214f1997d39ed0ee0ece72335490a7ac67be" @@ -1101,6 +1127,11 @@ flatted@^3.2.7: resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.7.tgz#609f39207cb614b89d0765b477cb2d437fbf9787" integrity sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ== +follow-redirects@^1.15.0: + version "1.15.3" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.3.tgz#fe2f3ef2690afce7e82ed0b44db08165b207123a" + integrity sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q== + for-each@^0.3.3: version "0.3.3" resolved "https://registry.yarnpkg.com/for-each/-/for-each-0.3.3.tgz#69b447e88a0a5d32c3e7084f3f1710034b21376e" @@ -1108,6 +1139,15 @@ for-each@^0.3.3: dependencies: is-callable "^1.1.3" +form-data@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452" + integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww== + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.8" + mime-types "^2.1.12" + fraction.js@^4.2.0: version "4.2.1" resolved "https://registry.yarnpkg.com/fraction.js/-/fraction.js-4.2.1.tgz#14b4cc886575a5684f8d5fd5759c5db376bb7bb8" @@ -1669,6 +1709,18 @@ micromatch@^4.0.4, micromatch@^4.0.5: braces "^3.0.2" picomatch "^2.3.1" +mime-db@1.52.0: + version "1.52.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" + integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== + +mime-types@^2.1.12: + version "2.1.35" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a" + integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== + dependencies: + mime-db "1.52.0" + mini-svg-data-uri@^1.2.3: version "1.4.4" resolved "https://registry.yarnpkg.com/mini-svg-data-uri/-/mini-svg-data-uri-1.4.4.tgz#8ab0aabcdf8c29ad5693ca595af19dd2ead09939" @@ -1999,6 +2051,11 @@ prop-types@^15.7.2, prop-types@^15.8.1: object-assign "^4.1.1" react-is "^16.13.1" +proxy-from-env@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2" + integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg== + punycode@^2.1.0: version "2.3.0" resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.0.tgz#f67fa67c94da8f4d0cfff981aee4118064199b8f"