Files
supabase/apps/studio/components/interfaces/Database/Backups/PITR/TimezoneSelection.tsx
Ivan VasilovandJoshen Lim 05a542ccea chore: Migrate all feather icons to lucide icons (#29038)
* Add lucide-react to docs (to make the autocomplete work).

* Migrate the docs app icons.

* Migrate the ui-patterns.

* Remove the old icons from ui package.

* Migrate the www app from react-feather icons.

* Migrate all of studio icons.

* Migrate the only component in design-system.

* Fix an old import in ui package. Revert an import in docs app.

* Fix some pages in www.

* Remove unneeded files used in generation of icons.

* Fix a prettier error.

* Fix more issues in www.

* Fix an issue in Log Date picker.

* Replace all string sizes with number sizes because the icons grew in some cases.

* Fix more imports in security page.

* Fix an extra import.

* Remove the size prop from all icons if they're in a button and they match the button size.

* Minor fixes for docs and www.

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2024-09-04 19:46:21 +08:00

90 lines
2.9 KiB
TypeScript

import { CheckIcon, ChevronsUpDown, Globe } from 'lucide-react'
import { useState } from 'react'
import {
Button,
CommandEmpty_Shadcn_,
CommandGroup_Shadcn_,
CommandInput_Shadcn_,
CommandItem_Shadcn_,
CommandList_Shadcn_,
Command_Shadcn_,
PopoverContent_Shadcn_,
PopoverTrigger_Shadcn_,
Popover_Shadcn_,
ScrollArea,
cn,
} from 'ui'
import { ALL_TIMEZONES } from './PITR.constants'
import type { Timezone } from './PITR.types'
interface TimezoneSelectionProps {
selectedTimezone: Timezone
onSelectTimezone: (timezone: Timezone) => void
}
export const TimezoneSelection = ({
selectedTimezone,
onSelectTimezone,
}: TimezoneSelectionProps) => {
const [open, setOpen] = useState(false)
const timezoneOptions = ALL_TIMEZONES.map((option) => option.text)
return (
<div className="w-full">
<Popover_Shadcn_ open={open} onOpenChange={setOpen}>
<PopoverTrigger_Shadcn_ asChild>
<Button
role="combobox"
aria-expanded={open}
className="w-[350px] justify-between"
size="small"
icon={<Globe />}
iconRight={<ChevronsUpDown size={14} strokeWidth={1.5} />}
>
{selectedTimezone
? timezoneOptions.find((option) => option === selectedTimezone.text)
: 'Select timezone...'}
</Button>
</PopoverTrigger_Shadcn_>
<PopoverContent_Shadcn_ className="w-[350px] p-0">
<Command_Shadcn_>
<CommandInput_Shadcn_ placeholder="Search timezone..." className="h-9" />
<CommandList_Shadcn_>
<CommandEmpty_Shadcn_>No timezones found...</CommandEmpty_Shadcn_>
<CommandGroup_Shadcn_>
<ScrollArea className="h-72">
{timezoneOptions.map((option) => (
<CommandItem_Shadcn_
key={option}
value={option}
onSelect={(text) => {
const selectedTimezone = ALL_TIMEZONES.find(
(option) => option.text.toLocaleLowerCase() === text
)
if (selectedTimezone) {
onSelectTimezone(selectedTimezone)
setOpen(false)
}
}}
>
{option}
<CheckIcon
className={cn(
'ml-auto h-4 w-4',
selectedTimezone.text === option ? 'opacity-100' : 'opacity-0'
)}
/>
</CommandItem_Shadcn_>
))}
</ScrollArea>
</CommandGroup_Shadcn_>
</CommandList_Shadcn_>
</Command_Shadcn_>
</PopoverContent_Shadcn_>
</Popover_Shadcn_>
</div>
)
}