Skip to content

Commit

Permalink
feat(widgets/LocationSelectTable): get location list in widget
Browse files Browse the repository at this point in the history
  • Loading branch information
ooooorobo committed Jul 3, 2024
1 parent d7e893d commit 0a7d8e1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 17 deletions.
6 changes: 1 addition & 5 deletions src/processes/ideal_partner/LocationForm/LocationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,7 @@ export const LocationForm = ({ locations = [] }: LocationFormProps) => {
</Chip>
))}
</div>
<LocationSelectTable
locations={locations}
selectedLocations={selectedTownList}
selectLocation={handleSelectLocation}
/>
<LocationSelectTable selectedLocations={selectedTownList} selectLocation={handleSelectLocation} />
</section>
);
};
12 changes: 2 additions & 10 deletions src/processes/my_profile/LocationForm/LocationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@ import { useMyProfileStore } from 'src/entities/profile/model/myProfileStore';
import { LocationSelectTable } from 'src/widgets/LocationSelectTable/LocationSelectTable';
import { useMultiSelectToggle } from 'src/shared/functions/useMultiSelectToggle';

type LocationFormProps = {
locations?: Location[];
};

const MAX_LOCATION_COUNT = 5;

export const LocationForm = ({ locations = [] }: LocationFormProps) => {
export const LocationForm = () => {
const { list: selectedTownList, toggle: toggleTown } = useMultiSelectToggle<Location>(
[],
(a, b) => a.town[0]?.town === b.town[0]?.town,
Expand Down Expand Up @@ -44,11 +40,7 @@ export const LocationForm = ({ locations = [] }: LocationFormProps) => {
</Chip>
))}
</div>
<LocationSelectTable
locations={locations}
selectedLocations={selectedTownList}
selectLocation={handleSelectLocation}
/>
<LocationSelectTable selectedLocations={selectedTownList} selectLocation={handleSelectLocation} />
</section>
);
};
6 changes: 4 additions & 2 deletions src/widgets/LocationSelectTable/LocationSelectTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ import styles from './LocationSelectTable.module.css';
import { Minus, Plus } from 'src/shared/ui/icons';
import { useState } from 'react';
import { Location } from 'src/entities/location/types/location';
import { locationListMock } from 'src/entities/location/api/__mock__/location.mock';

type Props = {
locations: Location[];
selectedLocations: Location[];
selectLocation: (loc: Location) => void;
};

export const LocationSelectTable = ({ locations, selectedLocations, selectLocation }: Props) => {
const locations = locationListMock;

export const LocationSelectTable = ({ selectedLocations, selectLocation }: Props) => {
const [selectedMainLocation, setSelectedMainLocation] = useState<Location>(locations[0]);

return (
Expand Down

0 comments on commit 0a7d8e1

Please sign in to comment.