From a91013ab16bd5a1b761beeb4462aaba5eb4f10e1 Mon Sep 17 00:00:00 2001 From: Luke Vella Date: Wed, 27 Apr 2022 17:15:56 +0100 Subject: [PATCH] Legacy polls notice (#141) * Add notice for legacy polls * Update badges --- components/poll/manage-poll.tsx | 32 ++++++---- components/poll/poll-subheader.tsx | 97 +++++++++++++++++------------- components/tooltip.tsx | 3 + 3 files changed, 79 insertions(+), 53 deletions(-) diff --git a/components/poll/manage-poll.tsx b/components/poll/manage-poll.tsx index 388789810..14ab4c96b 100644 --- a/components/poll/manage-poll.tsx +++ b/components/poll/manage-poll.tsx @@ -29,6 +29,20 @@ const ManagePoll: React.VoidFunctionComponent<{ const modalContext = useModalContext(); + const handleChangeOptions = () => { + if (poll.legacy) { + modalContext.render({ + overlayClosable: true, + title: "Sorry!", + description: + "This poll was created with an older version of Rallly and does not support this feature.", + cancelText: "Close", + }); + } else { + openChangeOptionsModal(); + } + }; + const { mutate: updatePollMutation, isLoading: isUpdating } = useUpdatePollMutation(); const [ @@ -61,11 +75,7 @@ const ManagePoll: React.VoidFunctionComponent<{ } : { type: "date", - date: - start.indexOf("T") === -1 - ? start - : // legacy polls - new Date(start).toISOString().substring(0, 10), + date: start, }; }), timeZone: poll.timeZone ?? "", @@ -166,13 +176,11 @@ const ManagePoll: React.VoidFunctionComponent<{ label="Edit details" onClick={openChangePollDetailsModa} /> - {!poll.legacy ? ( - - ) : null} + = () => { }} />   - {poll.role === "admin" ? ( - poll.verified ? ( - - Verified - - ) : ( - - Unverified - - } - > -
-
- - ), - }} - /> + + {poll.role === "admin" ? ( + poll.verified ? ( + + Verified + + ) : ( + + Unverified + + } + > +
+
+ + ), + }} + /> +
+ {didSendVerificationEmail ? ( +
+ Verification email sent. +
+ ) : ( + + )}
- {didSendVerificationEmail ? ( -
Verification email sent.
- ) : ( - - )} -
- - ) - ) : null} + + ) + ) : null} + {poll.legacy && poll.role === "admin" ? ( + + + Legacy + + + ) : null} +
 •  diff --git a/components/tooltip.tsx b/components/tooltip.tsx index fa75cedb9..8dbd6f6aa 100644 --- a/components/tooltip.tsx +++ b/components/tooltip.tsx @@ -21,6 +21,7 @@ export interface TooltipProps { content?: React.ReactNode; disabled?: boolean; className?: string; + width?: number; } const Tooltip: React.VoidFunctionComponent = ({ @@ -29,6 +30,7 @@ const Tooltip: React.VoidFunctionComponent = ({ children, disabled, content, + width, }) => { const arrowRef = React.useRef(null); const [open, setOpen] = React.useState(false); @@ -109,6 +111,7 @@ const Tooltip: React.VoidFunctionComponent = ({ position: strategy, top: y ?? "", left: x ?? "", + maxWidth: width, }, })} >