diff --git a/components/common/EventPopup/AcmEventHeads.tsx b/components/common/EventPopup/AcmEventHeads.tsx index b7499edb..23cd3d9b 100644 --- a/components/common/EventPopup/AcmEventHeads.tsx +++ b/components/common/EventPopup/AcmEventHeads.tsx @@ -21,6 +21,8 @@ export default function AcmEventHeads({ teamTitle, pills, setPills, setEmptyErro const [showSearchResults, setShowSearchResults] = useState(true) const { data: session } = useSession(); const token = getCookieData(session).data.token + const [cursor, setCursor] = useState(-1) + const [mousePointer, setMousePointer] = useState(-1) const searchUsersApi = useCallback((pattern: string) => { getMatchingUsersApi(pattern, token) @@ -66,6 +68,7 @@ export default function AcmEventHeads({ teamTitle, pills, setPills, setEmptyErro setNameSearchValue("") setDebouncedValue("") setSearchResult([]) + setCursor(-1) setEmptyError(false) setPills((prevState) => { return [...prevState, pill]; @@ -89,9 +92,32 @@ export default function AcmEventHeads({ teamTitle, pills, setPills, setEmptyErro const handleBlur = () => { setTimeout ( () => { setShowSearchResults(false) + setCursor(-1) }, 500) } + const keyboardNavigation = (e: React.KeyboardEvent) => { + if (e.key === "Enter") { + if (cursor < searchResult.length && cursor != -1) { + addUserToPills(searchResult[cursor]) + } + } + if (e.key === "ArrowUp") { + if (cursor > 0) { + setCursor( cursor => cursor - 1) + } + } + if (e.key === "ArrowDown") { + if (cursor < searchResult.length - 1) { + setCursor( cursor => cursor + 1) + } + } + if (e.key === "Escape") { + setShowSearchResults(false) + setCursor(-1) + } + } + return (
@@ -103,26 +129,45 @@ export default function AcmEventHeads({ teamTitle, pills, setPills, setEmptyErro className={styles.pillInput} placeholder={`Search ${teamTitle}*`} onBlur={handleBlur} + onKeyDown={keyboardNavigation} />
{ showSearchResults && -
- {searchResult.map((pill: Pill) => -
+ {searchResult.map((pill: Pill) => { + const idxOfPill = searchResult.indexOf(pill) + return
addUserToPills(pill)} key={pill.email} - className={styles['pill']} + style={{ + backgroundColor: cursor === idxOfPill || mousePointer === idxOfPill ? "#0a69da" : "white", + color: cursor === idxOfPill || mousePointer === idxOfPill ? "white" : "black", + padding: '10px', + margin: 0, + cursor: 'pointer' + }} + onMouseEnter={() => setCursor(searchResult.indexOf(pill))} + onMouseLeave={() => setCursor(-1)} > {pill.name} -

+

{pill.email}

+ } + )} -
+ }
diff --git a/components/common/EventPopup/EventPopup.tsx b/components/common/EventPopup/EventPopup.tsx index 8a6d5790..36da6f6c 100644 --- a/components/common/EventPopup/EventPopup.tsx +++ b/components/common/EventPopup/EventPopup.tsx @@ -1,11 +1,11 @@ import React, { ChangeEvent, useState } from 'react' import { Alert, Dialog, Snackbar, TextField } from '@mui/material'; import styles from "../../../styles/components/EventPopup.module.scss"; +import LoaderStyles from "../../../styles/components/Loader.module.scss"; import { Event } from "react-big-calendar"; import Image from 'next/image'; import { RxCross2 } from 'react-icons/rx'; import { Common } from '../../../constants/common'; -import { Button } from '@mui/material' import AcmEventHeads from "./AcmEventHeads"; import { Pill } from "./Pill"; import { endEventApi } from "../../../repository/endEvent/endEventApi"; @@ -133,172 +133,225 @@ function DialogPopup({ } return ( - !showModal ? - - -
-
-

{title}

-
- + <> + { + loading && + +
+
+
+ + + +
+

+ Persisting your transaction +

+
+ } -
- {`${title} -
-
-
- {finalDateString( - getDateString( - startDate.getDate(), - startDate.getMonth(), - startDate.getFullYear() - ), - getDateString( - endDate.getDate(), - endDate.getMonth(), - endDate.getFullYear() - ), - startDate.toLocaleTimeString("en-US", { - hour: "2-digit", - minute: "2-digit", - timeZone: "Asia/Kolkata", - }) - )} + {!loading && ( + !showModal ? + + +
+
+

{title}

+
+
-

{venue}

-

{description}

-
-
-
- { - (designation === 'Admin' || - designation === 'Core') && token && !ended ? - : <> - } -
-
-
: - -
-
-

{title}

-
- +
+ {`${title} +
+
+
+ {finalDateString( + getDateString( + startDate.getDate(), + startDate.getMonth(), + startDate.getFullYear() + ), + getDateString( + endDate.getDate(), + endDate.getMonth(), + endDate.getFullYear() + ), + startDate.toLocaleTimeString("en-US", { + hour: "2-digit", + minute: "2-digit", + timeZone: "Asia/Kolkata", + }) + )} +
+
+

{venue}

+

{description}

+
+
+
+ { + (designation === 'Admin' || + designation === 'Core') && token && !ended ? + : <> + } +
-
+
: -
-
- {`${title} -
-
-
- - + +
+
+

{title}

+
+ +
-
-
-
-
- - -
+
+
+ {`${title} +
+
+
+ + +
+
- { - setParticipantsList([]) - setReadCsvError(""); - }} - /> + +
+
+ + +
+ + { + setParticipantsList([]) + setReadCsvError(""); + }} + /> +
+ + +
+
+ +
- - + { + participantsEmptyError && +

- Please upload a csv containing participants emails. + Make sure there is at least 1 participant and the column name for email addresses contains "mail" as a substring

+ } + { + publicityEmptyError && +

- Please add at least 1 Publicity Head

+ } + { + contributorsEmptyError && +

- Please add at least 1 Contributor Head

+ } + { + readCsvError.length > 0 &&

- {readCsvError}

+ } +
-
- - +
+
- { - participantsEmptyError &&

- Please upload a csv containing participants emails. Make sure there is at least 1 participant and the column name for email addresses contains "mail" as a substring

- } - { - publicityEmptyError &&

- Please add at least 1 Publicity Head

- } - { - contributorsEmptyError &&

- Please add at least 1 Contributor Head

- } - { - readCsvError.length > 0 &&

- {readCsvError}

- }
-
-
- -
-
- + )} + + - - {snackBarError.length ? snackBarError : "Event ended successfully"} - - -
+ {snackBarError.length ? snackBarError : "Event ended successfully"} + + + + ) } diff --git a/styles/components/AcmEventHeads.module.scss b/styles/components/AcmEventHeads.module.scss index 8eb1a615..e0462c43 100644 --- a/styles/components/AcmEventHeads.module.scss +++ b/styles/components/AcmEventHeads.module.scss @@ -39,22 +39,3 @@ border: none; outline:none; } -.pill { - background-color: #f6fafd; - padding: 10px; - margin: 0; - cursor: pointer; - p { - color: grey; - font-size: small; - overflow: clip; - margin: 0; - } -} -.pill:Hover{ - background-color: #0a69da; - color: white; - p { - color: white - } -} \ No newline at end of file diff --git a/styles/components/EventPopup.module.scss b/styles/components/EventPopup.module.scss index 5b5b5e5c..726f72e4 100644 --- a/styles/components/EventPopup.module.scss +++ b/styles/components/EventPopup.module.scss @@ -5,6 +5,7 @@ padding: 10px; border-radius: 1rem; font-family: 'Josefin_Sans'; + min-height: 350px; .content { word-wrap: break-word; @@ -124,6 +125,12 @@ transition: all 0.5s; } } + button:disabled, + button[disabled]{ + border: 1px solid #999999; + background-color: #cccccc; + color: #666666; + } } @media screen and (max-width: $tablet-breakpoint) { diff --git a/styles/components/Loader.module.scss b/styles/components/Loader.module.scss new file mode 100644 index 00000000..aaa91c97 --- /dev/null +++ b/styles/components/Loader.module.scss @@ -0,0 +1,113 @@ +.profile-main-loader{ + left: 50% !important; + margin-left:-100px; + position: fixed !important; + top: 50% !important; + margin-top: -100px; + width: 35px; + z-index: 9000 !important; +} + +.loader { + position: relative; + margin: 0px auto; + width: 600%; + height: 600%; +} +.profile-main-loader .loader:before { + content: ''; + display: block; + padding-top: 100%; +} + +.circular-loader { + -webkit-animation: rotate 2s linear infinite; + animation: rotate 2s linear infinite; + height: 100%; + -webkit-transform-origin: center center; + -ms-transform-origin: center center; + transform-origin: center center; + width: 100%; + position: absolute; + top: 0; + left: 0; + margin: auto; +} + +.loader-path { + stroke-dasharray: 150,200; + stroke-dashoffset: -10; + -webkit-animation: dash 1.5s ease-in-out infinite, color 6s ease-in-out infinite; + animation: dash 1.5s ease-in-out infinite, color 6s ease-in-out infinite; + stroke-linecap: round; +} + +@-webkit-keyframes rotate { + 100% { + -webkit-transform: rotate(360deg); + transform: rotate(360deg); + } +} + +@keyframes rotate { + 100% { + -webkit-transform: rotate(360deg); + transform: rotate(360deg); + } +} +@-webkit-keyframes dash { + 0% { + stroke-dasharray: 1,200; + stroke-dashoffset: 0; + } + 50% { + stroke-dasharray: 89,200; + stroke-dashoffset: -35; + } + 100% { + stroke-dasharray: 89,200; + stroke-dashoffset: -124; + } +} +@keyframes dash { + 0% { + stroke-dasharray: 1,200; + stroke-dashoffset: 0; + } + 50% { + stroke-dasharray: 89,200; + stroke-dashoffset: -35; + } + 100% { + stroke-dasharray: 89,200; + stroke-dashoffset: -124; + } +} +@-webkit-keyframes color { + 0% { + stroke: #0075FF; + } + 40% { + stroke: #0075FF; + } + 66% { + stroke: #0075FF; + } + 80%, 90% { + stroke: #0075FF; + } +} +@keyframes color { + 0% { + stroke: #0075FF; + } + 40% { + stroke: #0075FF; + } + 66% { + stroke: #0075FF; + } + 80%, 90% { + stroke: #0075FF; + } +}