ammenities

This commit is contained in:
Samandar Turgunboyev
2025-11-05 18:44:53 +05:00
parent 65a6c963f2
commit b3401085c7

View File

@@ -1046,48 +1046,50 @@ const StepOne = ({
<Command> <Command>
<CommandList> <CommandList>
<CommandGroup heading={t("Mavjud qulayliklar")}> <CommandGroup heading={t("Mavjud qulayliklar")}>
{badge?.data?.data?.results?.map((item: any) => { {amenitiesData?.data?.data?.results?.map(
const currentBadges = (item: any) => {
form.getValues("amenities") ?? []; const currentBadges =
const selected = currentBadges.includes(item.id); form.getValues("amenities") ?? [];
const selected = currentBadges.includes(item.id);
return ( return (
<CommandItem <CommandItem
key={item.id} key={item.id}
onSelect={() => { onSelect={() => {
const selected = currentBadges.includes( const selected = currentBadges.includes(
item.id,
);
if (selected) {
removeAmenity(item.id);
form.setValue(
"amenities",
currentBadges.filter(
(b: number) => b !== item.id,
),
);
} else {
addAmenity(item.id);
form.setValue("amenities", [
...currentBadges,
item.id, item.id,
]); );
}
}} if (selected) {
className="flex items-center gap-2" removeAmenity(item.id);
> form.setValue(
<SquareCheckBig "amenities",
className={`size-4 ${ currentBadges.filter(
selected (b: number) => b !== item.id,
? "text-green-500" ),
: "text-muted-foreground" );
}`} } else {
/> addAmenity(item.id);
{item.name} form.setValue("amenities", [
</CommandItem> ...currentBadges,
); item.id,
})} ]);
}
}}
className="flex items-center gap-2"
>
<SquareCheckBig
className={`size-4 ${
selected
? "text-green-500"
: "text-muted-foreground"
}`}
/>
{item.name}
</CommandItem>
);
},
)}
</CommandGroup> </CommandGroup>
</CommandList> </CommandList>
</Command> </Command>