admin(ui): fix SearchableSelect, other tweaks
This commit is contained in:
parent
d43e70c97a
commit
9b08b6b595
6 changed files with 40 additions and 28 deletions
|
@ -1,9 +1,12 @@
|
|||
import React, { useState } from 'react';
|
||||
import { useFormikContext } from 'formik';
|
||||
import { Location } from '@/api/admin/locations/getLocations';
|
||||
import searchLocations from '@/api/admin/locations/searchLocations';
|
||||
import SearchableSelect, { Option } from '@/components/elements/SearchableSelect';
|
||||
|
||||
export default ({ selected }: { selected: Location | null }) => {
|
||||
const context = useFormikContext();
|
||||
|
||||
const [ location, setLocation ] = useState<Location | null>(selected);
|
||||
const [ locations, setLocations ] = useState<Location[]>([]);
|
||||
|
||||
|
@ -16,8 +19,9 @@ export default ({ selected }: { selected: Location | null }) => {
|
|||
});
|
||||
};
|
||||
|
||||
const onSelect = (location: Location) => {
|
||||
const onSelect = (location: Location | null) => {
|
||||
setLocation(location);
|
||||
context.setFieldValue('locationId', location?.id || null);
|
||||
};
|
||||
|
||||
const getSelectedText = (location: Location | null): string => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue