feat: clinic doc integration
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Clear } from '@mui/icons-material';
|
||||
import ExpandMoreOutlinedIcon from '@mui/icons-material/ExpandMoreOutlined';
|
||||
import { Clear } from "@mui/icons-material";
|
||||
import ExpandMoreOutlinedIcon from "@mui/icons-material/ExpandMoreOutlined";
|
||||
import {
|
||||
Autocomplete,
|
||||
Box,
|
||||
@@ -8,17 +8,16 @@ import {
|
||||
CircularProgress,
|
||||
ListItemText,
|
||||
Stack,
|
||||
TextField
|
||||
} from '@mui/material';
|
||||
import debounce from 'lodash/debounce';
|
||||
import React, { useEffect, useMemo, useState } from 'react';
|
||||
import { NOTIFICATION } from '../constants';
|
||||
import { pushNotification } from '../utils/notification';
|
||||
import { useStyles } from './styles/multiSelectStyles';
|
||||
TextField,
|
||||
} from "@mui/material";
|
||||
import debounce from "lodash/debounce";
|
||||
import React, { useEffect, useMemo, useState } from "react";
|
||||
import { NOTIFICATION } from "../constants";
|
||||
import { pushNotification } from "../utils/notification";
|
||||
import { useStyles } from "./styles/multiSelectStyles";
|
||||
import { getMasterData } from "../services/masterData.services";
|
||||
|
||||
const MultiSelect = ({
|
||||
apiCall,
|
||||
searchParams = {},
|
||||
searchDebounceTime = 500,
|
||||
maxSelections = Infinity,
|
||||
formik,
|
||||
@@ -26,19 +25,16 @@ const MultiSelect = ({
|
||||
fieldObjectValue,
|
||||
getOptionLabel,
|
||||
customErrorMessage = null,
|
||||
hideEndAdornment = false,
|
||||
onError = (error) => console.error(error),
|
||||
onOptionsChange = () => {},
|
||||
fieldName,
|
||||
styleForSelectorParent,
|
||||
styleForSelector,
|
||||
placeholderText = '',
|
||||
placeholderText = "",
|
||||
inputRef,
|
||||
}) => {
|
||||
const classes = useStyles();
|
||||
const [data, setData] = useState([]);
|
||||
const [page, setPage] = useState(0);
|
||||
const [searchQuery, setSearchQuery] = useState('');
|
||||
const [searchQuery, setSearchQuery] = useState("");
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [hasMore, setHasMore] = useState(true);
|
||||
const [dropdownOpen, setDropdownOpen] = useState(false);
|
||||
@@ -47,20 +43,8 @@ const MultiSelect = ({
|
||||
const fetchData = async () => {
|
||||
try {
|
||||
setIsLoading(true);
|
||||
const response = await apiCall({
|
||||
...searchParams,
|
||||
page,
|
||||
size: 30,
|
||||
search: searchQuery,
|
||||
});
|
||||
const newData = response?.data || [];
|
||||
if (page === 0) {
|
||||
setData(newData);
|
||||
} else {
|
||||
setData((prevData) => [...prevData, ...newData]);
|
||||
}
|
||||
setHasMore(newData.length > 0);
|
||||
onOptionsChange(newData);
|
||||
const response = await getMasterData();
|
||||
setData(response?.data?.data?.data);
|
||||
} catch (error) {
|
||||
onError(error);
|
||||
} finally {
|
||||
@@ -182,13 +166,13 @@ const MultiSelect = ({
|
||||
debouncedSearch(event.target.value.trim());
|
||||
}}
|
||||
onKeyDown={(event) => {
|
||||
if (event.key === 'Backspace') {
|
||||
if (event.key === "Backspace") {
|
||||
event.stopPropagation();
|
||||
}
|
||||
}}
|
||||
InputProps={{
|
||||
...params.InputProps,
|
||||
type: 'search',
|
||||
type: "search",
|
||||
endAdornment: (
|
||||
<>
|
||||
{isLoading ? (
|
||||
|
||||
Reference in New Issue
Block a user