fix tto order tables

This commit is contained in:
Danel Kungla
2025-10-22 10:29:07 +03:00
parent deee61e3ff
commit 86b2d02a8f
13 changed files with 130 additions and 71 deletions

View File

@@ -1,5 +1,4 @@
import { Label } from '@medusajs/ui';
import { useTranslation } from 'react-i18next';
import { RadioGroup, RadioGroupItem } from '@kit/ui/radio-group';
import { Card } from '@kit/ui/shadcn/card';
@@ -8,7 +7,6 @@ import { Trans } from '@kit/ui/trans';
import { useBooking } from './booking.provider';
const LocationSelector = () => {
const { t } = useTranslation();
const { selectedLocationId, setSelectedLocationId, locations } = useBooking();
const onLocationSelect = (locationId: number | string | null) => {
@@ -16,6 +14,15 @@ const LocationSelector = () => {
setSelectedLocationId(Number(locationId));
};
const uniqueLocations = locations?.filter((item, index, self) => {
return (
index ===
self.findIndex(
(loc) => loc.sync_id === item.sync_id && loc.name === item.name,
)
);
});
return (
<Card className="mb-4 p-4">
<h5 className="text-semibold mb-2">
@@ -26,20 +33,23 @@ const LocationSelector = () => {
className="mb-2 flex flex-col"
onValueChange={(val) => onLocationSelect(val)}
>
<div className="flex items-center gap-2">
{/* <div className="flex items-center gap-2">
<RadioGroupItem
value={'all'}
id={'all'}
value="all"
id="all"
checked={selectedLocationId === null}
/>
<Label htmlFor={'all'}>{t('booking:showAllLocations')}</Label>
</div>
{locations?.map((location) => (
<Label htmlFor="all">{t('booking:showAllLocations')}</Label>
</div> */}
{uniqueLocations?.map((location, index) => (
<div key={location.sync_id} className="flex items-center gap-2">
<RadioGroupItem
value={location.sync_id.toString()}
id={location.sync_id.toString()}
checked={selectedLocationId === location.sync_id}
checked={
selectedLocationId === location.sync_id ||
(index === 0 && selectedLocationId === null)
}
/>
<Label htmlFor={location.sync_id.toString()}>
{location.name}