Skip to content

Commit a8e2d13

Browse files
committed
feature: switching the county selection box to disabled when the city is not selected
1 parent 8b6d461 commit a8e2d13

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/components/SelectLocation.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,14 @@ const SelectLocation: React.FC<SelectLocationProps> = ({ type, value, onChange,
3434
setOpen(false)
3535
}, [onChange])
3636

37-
const placeholder = type === 'city' ? 'Bir Şehir Seçin' : 'Bir İlçe Seçin'
37+
const disabledDistrict: boolean = (type === 'district' && !cityValue)
38+
const placeholder = type === 'city' ? 'Bir Şehir Seçin' : disabledDistrict ? 'Bir Şehir Seçmelisin' : 'Bir İlçe Seçin'
3839

3940
return (
4041
<Popover open={open} onOpenChange={setOpen}>
4142
<PopoverTrigger asChild>
42-
<Button variant="outline" className="flex items-center justify-between gap-5 w-full">
43+
<Button variant="outline" disabled={disabledDistrict}
44+
className="flex items-center justify-between gap-5 w-full">
4345
<span>{value || placeholder}</span>
4446
<IoCaretDown className="text-4xl" />
4547
</Button>

0 commit comments

Comments
 (0)