mirror of
https://github.com/MrUnknownDE/panel.git
synced 2026-04-18 14:23:44 +02:00
admin(ui): fix SearchableSelect, other tweaks
This commit is contained in:
@@ -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 => {
|
||||
|
||||
Reference in New Issue
Block a user