import { Autocomplete, Box, TextField } from "@mui/material"; import { Edit, useAutocomplete } from "@refinedev/mui"; import { useForm } from "@refinedev/react-hook-form"; import { languageStore, META_LANGUAGE } from "@stores"; import { LanguageSelector, MediaView } from "@ui"; import { observer } from "mobx-react-lite"; import { Controller } from "react-hook-form"; export const CarrierEdit = observer(() => { const { language } = languageStore; const { saveButtonProps, register, control, watch, formState: { errors }, } = useForm({ refineCoreProps: META_LANGUAGE(language) }); const { autocompleteProps: cityAutocompleteProps } = useAutocomplete({ resource: "city", onSearch: (value) => [ { field: "name", operator: "contains", value, }, ], ...META_LANGUAGE("ru") }); const { autocompleteProps: mediaAutocompleteProps } = useAutocomplete({ resource: "media", onSearch: (value) => [ { field: "media_name", operator: "contains", value, }, ], ...META_LANGUAGE("ru") }); return ( ( option.id === field.value ) ?? null } onChange={(_, value) => { field.onChange(value?.id ?? ""); }} getOptionLabel={(item) => { return item ? item.name : ""; }} isOptionEqualToValue={(option, value) => { return option.id === value?.id; }} filterOptions={(options, { inputValue }) => { return options.filter((option) => option.name.toLowerCase().includes(inputValue.toLowerCase()) ); }} renderInput={(params) => ( )} /> )} /> ( option.id === field.value ) ?? null } onChange={(_, value) => { field.onChange(value?.id ?? ""); }} getOptionLabel={(item) => { return item ? item.media_name : ""; }} isOptionEqualToValue={(option, value) => { return option.id === value?.id; }} filterOptions={(options, { inputValue }) => { return options.filter((option) => option.media_name .toLowerCase() .includes(inputValue.toLowerCase()) && option.media_type == 3 ); }} renderInput={(params) => ( )} /> )} /> ); });