From 0990aa643a2731c11eb38decec6608ce1396ee8b Mon Sep 17 00:00:00 2001 From: Biswajeet Das Date: Fri, 7 Feb 2025 21:01:46 +0530 Subject: [PATCH] feat(select): enhance locale and timezone components with selection indicators --- .../components/subscribers/locale-select.tsx | 22 ++++++++++++++----- .../subscribers/timezone-select.tsx | 7 ++++-- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/apps/dashboard/src/components/subscribers/locale-select.tsx b/apps/dashboard/src/components/subscribers/locale-select.tsx index d7492d9b255..1a2f2a03c7f 100644 --- a/apps/dashboard/src/components/subscribers/locale-select.tsx +++ b/apps/dashboard/src/components/subscribers/locale-select.tsx @@ -1,6 +1,6 @@ import { locales } from '@/utils/locales'; import { cn } from '@/utils/ui'; -import { RiArrowDownSLine, RiEarthLine } from 'react-icons/ri'; +import { RiArrowDownSLine, RiCheckLine, RiEarthLine } from 'react-icons/ri'; import { type Country } from 'react-phone-number-input'; import flags from 'react-phone-number-input/flags'; import { Button } from '../primitives/button'; @@ -58,12 +58,13 @@ export function LocaleSelect({ { onChange(val); setOpen(false); }} + currentValue={value} /> ))} @@ -78,23 +79,32 @@ export function LocaleSelect({ const FlagItem = ({ countryCode, languageName, - value, + optionValue, onChange, + currentValue, }: { countryCode: string; languageName: string; - value: string; + optionValue: string; onChange: (val: string) => void; + currentValue?: string; }) => { const CurrentFlag = countryCode ? flags[countryCode as Country] : RiEarthLine; + const isSelected = optionValue === currentValue; return ( - onChange(value)}> + onChange(optionValue)} + >
{CurrentFlag && }
- {value} - {languageName} + {optionValue} - {languageName} +
); diff --git a/apps/dashboard/src/components/subscribers/timezone-select.tsx b/apps/dashboard/src/components/subscribers/timezone-select.tsx index 781e353aa3c..c644b6bfc33 100644 --- a/apps/dashboard/src/components/subscribers/timezone-select.tsx +++ b/apps/dashboard/src/components/subscribers/timezone-select.tsx @@ -1,5 +1,5 @@ import { cn } from '@/utils/ui'; -import { RiArrowDownSLine, RiTimeLine } from 'react-icons/ri'; +import { RiArrowDownSLine, RiCheckLine, RiTimeLine } from 'react-icons/ri'; import { useTimezoneSelect } from 'react-timezone-select'; import { Button } from '../primitives/button'; import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from '../primitives/command'; @@ -60,7 +60,9 @@ export function TimezoneSelect({ {options.map((item) => ( { const parsedValue = parseTimezone(item.value); onChange(parsedValue.value); @@ -69,6 +71,7 @@ export function TimezoneSelect({ key={item.value} > {item.label} + ))}