From 4895a79d68f35cb0c116cccc5f6efb8d510a9698 Mon Sep 17 00:00:00 2001 From: Sulagna Ghosh <62666287+suzy-g38@users.noreply.github.com> Date: Thu, 27 Jul 2023 12:18:14 +0530 Subject: [PATCH] feat: add cfp form (#531) --- src/pages/dashboard/add_cfp.tsx | 413 ++++++++++++++++++++++++++++++++ 1 file changed, 413 insertions(+) create mode 100644 src/pages/dashboard/add_cfp.tsx diff --git a/src/pages/dashboard/add_cfp.tsx b/src/pages/dashboard/add_cfp.tsx new file mode 100644 index 00000000..62fba453 --- /dev/null +++ b/src/pages/dashboard/add_cfp.tsx @@ -0,0 +1,413 @@ +import { Heading } from '@/components'; +import Button from '@/components/Buttons/Button'; + +import { Switch } from '@headlessui/react'; +import { Listbox, Transition } from '@headlessui/react'; +import { Fragment, useRef, useState } from 'react'; +import React from 'react'; + +interface TagType { + id: number; + name: string; +} +const Tags = [ + { id: 1, name: 'JavaScript' }, + { id: 2, name: 'TypeScript' }, + { id: 3, name: 'ReactJs' }, + { id: 4, name: 'NodeJs' }, + { id: 5, name: 'NextJs' }, +]; + +function AddCfp() { + const formRef = useRef(null); + const [selectedTags, setSelectedTags] = useState([]); + const [isOnlineCfp, setIsOnlineCfp] = useState(false); + const [isTicketRequires, setIsTicketRequires] = useState(false); + // const [sponsors, setSponsors] = useState([]) + const [speakerCount, setSpeakerCount] = useState(0); + const [sponsorsCount, setSponsorsCount] = useState(0); + + const handleSubmit = (e: any) => { + e.prCfpDefault(); + // const formData = formRef.current; + }; + + const handleSponsors = (type: string) => { + if (type === 'add') { + setSponsorsCount(sponsorsCount + 1); + // setSponsors((prevSponsors)=>[...prevSponsors,name]) + } + if (type === 'remove') { + setSponsorsCount(sponsorsCount - 1); + // setSponsors((prevSponsors)=>{ + // return prevSponsors.filter((sponsorName: string,currentIndex:number)=>index!==currentIndex) + + // }) + } + }; + // inputs + const inputs = [ + { + element: 'input', + label: 'name', + name: 'name', + type: 'text', + placeholder: 'Cfp Name', + }, + { + element: 'input', + label: 'Organizer', + name: 'name', + type: 'text', + placeholder: 'Cfp Name', + }, + { + element: 'textarea', + label: 'description', + name: 'description', + placeholder: 'Cfp Description', + }, + { + element: 'switch', + label: 'online', + name: 'name', + type: 'switch', + placeholder: 'Cfp Name', + }, + { + element: 'input', + label: 'date', + name: 'date', + type: 'datetime-local', + placeholder: 'Cfp Date', + }, + { + element: 'input', + label: 'duration', + name: 'duration', + type: 'number', + placeholder: 'Cfp Date', + }, + { + element: 'input', + label: 'link', + name: 'link', + type: 'url', + placeholder: 'Cfp Link', + }, + + { + element: 'multi-dropdown', + label: 'tags', + name: 'tags', + type: 'multi-dropdown', + placeholder: 'Cfp Tags', + }, + { + element: 'input', + label: 'linkedin', + name: 'linkedin', + type: 'url', + placeholder: 'Cfp Linkedin url', + }, + { + element: 'input', + label: 'twitter', + name: 'twitter', + type: 'url', + placeholder: 'Cfp twitter url', + }, + { + element: 'input', + label: 'logo', + name: 'logo', + type: 'url', + placeholder: 'Cfp logo', + }, + { + element: 'button', + label: 'speakers', + name: 'speakers', + type: 'input', + placeholder: 'Cfp Speakers', + }, + { + element: 'switch', + label: 'ticket', + name: 'requires ticket', + type: 'switch', + placeholder: 'requires ticket', + }, + { + element: 'sponor-button', + label: 'Sponsors', + name: 'Sponsors', + type: 'button', + placeholder: 'Sponsors', + }, + ]; + + return ( +
+ +
handleSubmit(e)}> +
+ {inputs.map((input, index) => ( + +
+ +
+
+ {input.element === 'textarea' && ( +