From c2967a867cb90a47848df1874c8dfbad85a4e8c9 Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Tue, 11 Feb 2025 18:22:40 +0300 Subject: [PATCH] extend slot card information --- .../time-slots/components/slot-card.tsx | 53 ++++++++++++++----- packages/ui/src/components/ui/badge.tsx | 2 - packages/ui/src/globals.css | 8 --- packages/ui/tailwind.config.ts | 8 --- 4 files changed, 41 insertions(+), 30 deletions(-) diff --git a/apps/web/components/schedule/time-slots/components/slot-card.tsx b/apps/web/components/schedule/time-slots/components/slot-card.tsx index a3cd6e6..e80cfe5 100644 --- a/apps/web/components/schedule/time-slots/components/slot-card.tsx +++ b/apps/web/components/schedule/time-slots/components/slot-card.tsx @@ -1,34 +1,63 @@ +/* eslint-disable canonical/id-match */ 'use client'; import { type SlotProps } from '../../types'; import { ContextProvider } from '../context'; import { ReadonlyTimeRange } from './time-pair'; import { useSlotQuery } from '@/hooks/slots'; import { withContext } from '@/utils/context'; +import { Enum_Slot_State } from '@repo/graphql/types'; import { Badge } from '@repo/ui/components/ui/badge'; +import { cn } from '@repo/ui/lib/utils'; import Link from 'next/link'; +const MAP_BADGE_TEXT: Record = { + closed: 'Закрыто', + open: 'Открыто', + reserved: 'Зарезервировано', +}; + +function getBadgeText(state: Enum_Slot_State) { + if (!state) return ''; + + return MAP_BADGE_TEXT[state]; +} + export const SlotCard = withContext(ContextProvider)(function (props: Readonly) { const { documentId } = props; - const { data: slotData } = useSlotQuery({ documentId }); - if (!slotData?.slot) return null; + const { data } = useSlotQuery({ documentId }); + if (!data?.slot) return null; - const ordersNumber = slotData.slot.orders?.length; + const ordersNumber = data.slot.orders?.length; const hasOrders = Boolean(ordersNumber); + const isOpened = data?.slot?.state === Enum_Slot_State.Open; + const isClosed = data?.slot?.state === Enum_Slot_State.Closed; + return (
- -
- {hasOrders ? ( - Есть записи - ) : ( - - Свободно - - )} +
+ + + {hasOrders ? 'Есть записи' : 'Свободно'} +
+ {data.slot.state && ( + + {getBadgeText(data.slot.state)} + + )}
); diff --git a/packages/ui/src/components/ui/badge.tsx b/packages/ui/src/components/ui/badge.tsx index e0e5a20..0032de2 100644 --- a/packages/ui/src/components/ui/badge.tsx +++ b/packages/ui/src/components/ui/badge.tsx @@ -16,8 +16,6 @@ const badgeVariants = cva( outline: 'text-foreground', secondary: 'border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80', - success: 'border-transparent bg-success text-success-foreground hover:bg-success/80', - warning: 'border-transparent bg-warning text-warning-foreground hover:bg-warning/80', }, }, }, diff --git a/packages/ui/src/globals.css b/packages/ui/src/globals.css index 113c2a4..f7c0d53 100644 --- a/packages/ui/src/globals.css +++ b/packages/ui/src/globals.css @@ -30,10 +30,6 @@ --chart-3: 197 37% 24%; --chart-4: 43 74% 66%; --chart-5: 27 87% 67%; - --warning: 31 96% 53%; - --warning-foreground: 0 0% 98%; - --success: 100 77% 44%; - --success-foreground: 0 0% 98%; } .dark { @@ -62,10 +58,6 @@ --chart-3: 30 80% 55%; --chart-4: 280 65% 60%; --chart-5: 340 75% 55%; - --warning: 31 96% 53%; - --warning-foreground: 0 0% 98%; - --success: 100 77% 33%; - --success-foreground: 0 0% 98%; } } diff --git a/packages/ui/tailwind.config.ts b/packages/ui/tailwind.config.ts index 2a757a2..7c11487 100644 --- a/packages/ui/tailwind.config.ts +++ b/packages/ui/tailwind.config.ts @@ -65,14 +65,6 @@ const config = { DEFAULT: 'hsl(var(--secondary))', foreground: 'hsl(var(--secondary-foreground))', }, - success: { - DEFAULT: 'hsl(var(--success))', - foreground: 'hsl(var(--success-foreground))', - }, - warning: { - DEFAULT: 'hsl(var(--warning))', - foreground: 'hsl(var(--warning-foreground))', - }, }, keyframes: { 'accordion-down': {