Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.
TypeScript i18nextnext-authnextjspostgresqlprismareact-emailt3-stacktailwindcsstrpcturborepotypescriptzod
Clean up poll props
Luke Vella79b724e8d5b3
diff --git a/components/poll/mobile-poll/mobile-poll.tsx b/components/poll/mobile-poll.tsxsimilarity index 91%rename from components/poll/mobile-poll/mobile-poll.tsxrename to components/poll/mobile-poll.tsxindex 1678ff0c1..079a407b4 100644--- a/components/poll/mobile-poll/mobile-poll.tsx+++ b/components/poll/mobile-poll.tsx@@ -6,41 +6,41 @@ import { useTranslation } from "next-i18next";import * as React from "react";import { Controller, useForm } from "react-hook-form";+import ChevronDown from "@/components/icons/chevron-down.svg";+import Pencil from "@/components/icons/pencil.svg";+import PlusCircle from "@/components/icons/plus-circle.svg";+import Trash from "@/components/icons/trash.svg";import { usePoll } from "@/components/use-poll";-import { decodeDateOption } from "../../../utils/date-time-utils";-import { requiredString } from "../../../utils/form-validation";-import Button from "../../button";-import DateCard from "../../date-card";-import CheckCircle from "../../icons/check-circle.svg";-import ChevronDown from "../../icons/chevron-down.svg";-import Pencil from "../../icons/pencil.svg";-import PlusCircle from "../../icons/plus-circle.svg";-import Trash from "../../icons/trash.svg";-import { styleMenuItem } from "../../menu-styles";-import NameInput from "../../name-input";-import TimeZonePicker from "../../time-zone-picker";-import { useUserName } from "../../user-name-context";+import { decodeDateOption } from "../../utils/date-time-utils";+import { requiredString } from "../../utils/form-validation";+import Button from "../button";+import DateCard from "../date-card";+import CheckCircle from "../icons/check-circle.svg";+import { styleMenuItem } from "../menu-styles";+import NameInput from "../name-input";+import TimeZonePicker from "../time-zone-picker";+import { useUserName } from "../user-name-context";import {useAddParticipantMutation,useUpdateParticipantMutation,-} from "../mutations";-import TimeRange from "../time-range";-import { ParticipantForm, PollProps } from "../types";-import { useDeleteParticipantModal } from "../use-delete-participant-modal";-import UserAvater from "../user-avatar";-import VoteIcon from "../vote-icon";+} from "./mutations";+import TimeRange from "./time-range";+import { ParticipantForm, PollProps } from "./types";+import { useDeleteParticipantModal } from "./use-delete-participant-modal";+import UserAvater from "./user-avatar";+import VoteIcon from "./vote-icon";const MobilePoll: React.VoidFunctionComponent<PollProps> = ({pollId,- timeZone,- options,- participants,highScore,targetTimeZone,onChangeTargetTimeZone,- role,}) => {+ const poll = usePoll();++ const { timeZone, options, participants, role } = poll;+const [, setUserName] = useUserName();const participantById = participants.reduce<@@ -88,8 +88,6 @@ const MobilePoll: React.VoidFunctionComponent<PollProps> = ({<input type="checkbox" className="hidden" {...register("votes")} />);- const poll = usePoll();-return (<formclassName="border-t border-b bg-white shadow-sm"diff --git a/components/poll/mobile-poll/index.ts b/components/poll/mobile-poll/index.tsdeleted file mode 100644index c393edb7a..000000000--- a/components/poll/mobile-poll/index.ts+++ /dev/null@@ -1 +0,0 @@-export { default } from "./mobile-poll";diff --git a/components/poll/poll.tsx b/components/poll/poll.tsxindex e4592754c..54364d9cd 100644--- a/components/poll/poll.tsx+++ b/components/poll/poll.tsx@@ -60,16 +60,16 @@ const minSidebarWidth = 180;const Poll: React.VoidFunctionComponent<PollProps> = ({pollId,- role,- timeZone,- options,- participants,highScore,targetTimeZone,onChangeTargetTimeZone,}) => {const { t } = useTranslation("app");+ const poll = usePoll();++ const { timeZone, options, participants, role } = poll;+const [ref, { width }] = useMeasure<HTMLDivElement>();const [editingParticipantId, setEditingParticipantId] =React.useState<string | null>(null);@@ -131,8 +131,6 @@ const Poll: React.VoidFunctionComponent<PollProps> = ({);};- const poll = usePoll();-return (<PollContext.Providervalue={{@@ -156,35 +154,33 @@ const Poll: React.VoidFunctionComponent<PollProps> = ({><div className=" border-t border-b bg-white shadow-sm md:rounded-lg md:border"><div className="sticky top-0 z-10 rounded-t-lg border-b border-gray-200 bg-white/80 shadow-sm shadow-slate-50 backdrop-blur-md">- {role !== "readOnly" ? (- <div className="flex h-14 items-center justify-end space-x-4 rounded-t-lg border-b bg-gray-50 px-4">- {timeZone ? (- <div className="flex grow items-center">- <div className="mr-2 text-sm font-medium text-slate-500">- {t("timeZone")}- </div>- <TimeZonePicker- value={targetTimeZone}- onChange={onChangeTargetTimeZone}- className="grow"- />+ <div className="flex h-14 items-center justify-end space-x-4 rounded-t-lg border-b bg-gray-50 px-4">+ {timeZone ? (+ <div className="flex grow items-center">+ <div className="mr-2 text-sm font-medium text-slate-500">+ {t("timeZone")}</div>- ) : null}- <div className="flex shrink-0">- {!shouldShowNewParticipantForm && !poll.closed ? (- <Button- type="primary"- icon={<PlusCircle />}- onClick={() => {- setShouldShowNewParticipantForm(true);- }}- >- New Participant- </Button>- ) : null}+ <TimeZonePicker+ value={targetTimeZone}+ onChange={onChangeTargetTimeZone}+ className="grow"+ /></div>+ ) : null}+ <div className="flex shrink-0">+ {!shouldShowNewParticipantForm && !poll.closed ? (+ <Button+ type="primary"+ icon={<PlusCircle />}+ onClick={() => {+ setShouldShowNewParticipantForm(true);+ }}+ >+ New Participant+ </Button>+ ) : null}</div>- ) : null}+ </div><div className="flex"><divclassName="flex shrink-0 items-center py-4 pl-4 pr-2 font-medium"diff --git a/components/poll/types.ts b/components/poll/types.tsindex 93fc117eb..dac4b6f35 100644--- a/components/poll/types.ts+++ b/components/poll/types.ts@@ -1,17 +1,10 @@-import { Option, Participant, Role, Vote } from "@prisma/client";-export interface ParticipantForm {name: string;votes: string[];}export interface PollProps {pollId: string;- role: Role | "readOnly";- timeZone: string | null;- options: Array<Option & { votes: Vote[] }>;- participants: Array<Participant & { votes: Vote[] }>;highScore: number;- initialName?: string;onChangeTargetTimeZone: (timeZone: string) => void;targetTimeZone: string;}diff --git a/pages/poll.tsx b/pages/poll.tsxindex 07333ddb2..3b3826879 100644--- a/pages/poll.tsx+++ b/pages/poll.tsx@@ -292,10 +292,6 @@ const PollPage: NextPage = () => {<div className="mb-4 lg:mb-8"><PollComponentpollId={poll.urlId}- role={poll.role}- timeZone={poll.timeZone}- options={sortedOptions}- participants={poll.participants}highScore={highScore}targetTimeZone={targetTimeZone}onChangeTargetTimeZone={setTargetTimeZone}