From d4156f5dc71cabd9aee2bf071ebd4ec425c54e15 Mon Sep 17 00:00:00 2001 From: Ryukemeister Date: Sat, 28 Oct 2023 00:21:01 +0530 Subject: [PATCH] create separate types for each component prop --- .../atoms/availabilitylist/Availability.tsx | 20 +++++++++------- .../availabilitylist/AvailabilityList.tsx | 18 +++++++------- .../atoms/availabilitylist/EmptyScreen.tsx | 24 ++++++++++--------- .../availabilitylist/NewScheduleButton.tsx | 9 ++++--- 4 files changed, 38 insertions(+), 33 deletions(-) diff --git a/packages/atoms/availabilitylist/Availability.tsx b/packages/atoms/availabilitylist/Availability.tsx index 0bee8d2400..39d71ea874 100644 --- a/packages/atoms/availabilitylist/Availability.tsx +++ b/packages/atoms/availabilitylist/Availability.tsx @@ -14,14 +14,7 @@ import { Fragment } from "react"; import { availabilityAsString } from "@calcom/lib/availability"; -export function Availability({ - schedule, - isDeletable, - displayOptions, - updateDefault, - duplicateFunction, - deleteFunction, -}: { +type AvailabilityProps = { schedule: Schedule; isDeletable: boolean; updateDefault: ({ scheduleId, isDefault }: { scheduleId: number; isDefault: boolean }) => void; @@ -31,7 +24,16 @@ export function Availability({ timeZone?: string; hour12?: boolean; }; -}) { +}; + +export function Availability({ + schedule, + isDeletable, + displayOptions, + updateDefault, + duplicateFunction, + deleteFunction, +}: AvailabilityProps) { const { toast } = useToast(); return ( diff --git a/packages/atoms/availabilitylist/AvailabilityList.tsx b/packages/atoms/availabilitylist/AvailabilityList.tsx index feb03c985f..6b9cb9fcd4 100644 --- a/packages/atoms/availabilitylist/AvailabilityList.tsx +++ b/packages/atoms/availabilitylist/AvailabilityList.tsx @@ -23,13 +23,7 @@ export type Schedule = { timezone?: string; }; -export function AvailabilityList({ - schedules, - onCreateMutation, - updateMutation, - duplicateMutation, - deleteMutation, -}: { +type AvailabilityListProps = { schedules: Schedule[] | []; onCreateMutation: (values: { onSucess: (schedule: Schedule) => void; @@ -38,7 +32,15 @@ export function AvailabilityList({ updateMutation: ({ scheduleId, isDefault }: { scheduleId: number; isDefault: boolean }) => void; duplicateMutation: ({ scheduleId }: { scheduleId: number }) => void; deleteMutation: ({ scheduleId }: { scheduleId: number }) => void; -}) { +}; + +export function AvailabilityList({ + schedules, + onCreateMutation, + updateMutation, + duplicateMutation, + deleteMutation, +}: AvailabilityListProps) { if (schedules.length === 0) { return (
diff --git a/packages/atoms/availabilitylist/EmptyScreen.tsx b/packages/atoms/availabilitylist/EmptyScreen.tsx index 791f0dc4c2..6cf320e20d 100644 --- a/packages/atoms/availabilitylist/EmptyScreen.tsx +++ b/packages/atoms/availabilitylist/EmptyScreen.tsx @@ -6,6 +6,18 @@ import React from "react"; import { classNames } from "@calcom/lib"; import type { SVGComponent } from "@calcom/types/SVGComponent"; +type EmptyScreenProps = { + Icon?: SVGComponent | IconType; + avatar?: React.ReactElement; + headline: string | React.ReactElement; + description?: string | React.ReactElement; + buttonText?: string; + buttonOnClick?: (event: React.MouseEvent) => void; + buttonRaw?: ReactNode; // Used incase you want to provide your own button. + border?: boolean; + dashedBorder?: boolean; +}; + export function EmptyScreen({ Icon, avatar, @@ -17,17 +29,7 @@ export function EmptyScreen({ border = true, dashedBorder = true, className, -}: { - Icon?: SVGComponent | IconType; - avatar?: React.ReactElement; - headline: string | React.ReactElement; - description?: string | React.ReactElement; - buttonText?: string; - buttonOnClick?: (event: React.MouseEvent) => void; - buttonRaw?: ReactNode; // Used incase you want to provide your own button. - border?: boolean; - dashedBorder?: boolean; -} & React.HTMLAttributes) { +}: EmptyScreenProps & React.HTMLAttributes) { return ( <>
void; onError: (err: HttpError) => void; }) => void; -}) { +}; + +export function NewScheduleButton({ name = "new-schedule", createMutation }: NewScheduleButtonProps) { const form = useForm<{ name: string; }>();