formatting and merge solving conflict
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import {Autocomplete, CircularProgress, TextField} from "@mui/material";
|
||||
import {useEffect, useState} from "react";
|
||||
import { Autocomplete, CircularProgress, TextField } from "@mui/material";
|
||||
import { useEffect, useState } from "react";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import {debounce} from "@mui/material/utils";
|
||||
import {GET_CAR_LIST_SEARCH} from "@/core/utils/routes";
|
||||
import { debounce } from "@mui/material/utils";
|
||||
import { GET_CAR_LIST_SEARCH } from "@/core/utils/routes";
|
||||
|
||||
const CarCode = ({carCode, setCarCode, inputValueDefault = "", error, multiple = false}) => {
|
||||
const CarCode = ({ carCode, setCarCode, inputValueDefault = "", error, multiple = false }) => {
|
||||
const [inputValue, setInputValue] = useState(inputValueDefault);
|
||||
const [options, setOptions] = useState([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
@@ -18,10 +18,10 @@ const CarCode = ({carCode, setCarCode, inputValueDefault = "", error, multiple =
|
||||
}
|
||||
setLoading(true);
|
||||
requestServer(`${GET_CAR_LIST_SEARCH}?machine_code=${query}`, "get", {
|
||||
requestOptions: {signal: controller.signal},
|
||||
requestOptions: { signal: controller.signal },
|
||||
})
|
||||
.then((response) => {
|
||||
const combinedArray = [...carCode, ...response.data.data];
|
||||
const combinedArray = carCode ? [...carCode, ...response.data.data] : [...response.data.data];
|
||||
const uniqueArray = Array.from(new Map(combinedArray.map((item) => [item.id, item])).values());
|
||||
setOptions(uniqueArray || []);
|
||||
})
|
||||
@@ -55,7 +55,7 @@ const CarCode = ({carCode, setCarCode, inputValueDefault = "", error, multiple =
|
||||
options={options}
|
||||
getOptionLabel={(option) => {
|
||||
if (typeof option === "string") return option;
|
||||
const {machine_code, car_name, plak_number} = option;
|
||||
const { machine_code, car_name, plak_number } = option;
|
||||
let label = `${machine_code || ""}`;
|
||||
if (car_name) {
|
||||
label += ` | ${car_name}`;
|
||||
@@ -85,7 +85,7 @@ const CarCode = ({carCode, setCarCode, inputValueDefault = "", error, multiple =
|
||||
...params.InputProps,
|
||||
endAdornment: (
|
||||
<>
|
||||
{loading ? <CircularProgress size="25px" color="inherit"/> : null}
|
||||
{loading ? <CircularProgress size="25px" color="inherit" /> : null}
|
||||
{params.InputProps.endAdornment}
|
||||
</>
|
||||
),
|
||||
|
||||
@@ -22,7 +22,9 @@ const RahdarCode = ({ rahdarsCode, setRahdarsCode, error, multiple = true }) =>
|
||||
requestOptions: { signal: controller.signal },
|
||||
})
|
||||
.then((response) => {
|
||||
const combinedArray = [...rahdarsCode, ...response.data.data];
|
||||
const combinedArray = rahdarsCode
|
||||
? [...rahdarsCode, ...response.data.data]
|
||||
: [...response.data.data];
|
||||
const uniqueArray = Array.from(new Map(combinedArray.map((item) => [item.id, item])).values());
|
||||
setOptions(uniqueArray || []);
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user