show only the first item in appo list & update appo item text && change key in /doctors page URL && handle setting and updating data on first modal filter load

This commit is contained in:
Ehsan
2025-08-26 22:35:05 +03:30
parent 8e4f182868
commit 09867bf84a
13 changed files with 137 additions and 85 deletions
@@ -0,0 +1,82 @@
import BottomSelect from "@/components/icons/BottomSelect";
import { Autocomplete, Button, TextField } from "@mui/material";
import { styleTextSelectRight } from "@/mui";
function CateSelector({ list, value, isError, updateData, label }) {
return (
<Autocomplete
disablePortal
value={value}
options={list}
getOptionLabel={(option) => option?.name}
className="!w-full !rounded-lg auto-complete-selector"
onChange={(_, newValue) => updateData(newValue)}
sx={{
...styleTextSelectRight,
// Hide Icon Number
"& input::-webkit-outer-spin-button, & input::-webkit-inner-spin-button":
{
display: "none",
},
"& input[type=number]": {
MozAppearance: "textfield",
},
"& .MuiInputBase-input": { padding: "12.5px 14px !important" },
"& .MuiInputBase-root": {
borderRadius: 2,
padding: "0 !important",
height: {
xs: "43px !important",
sm: "43px !important",
md: "46px !important",
lg: "48px !important",
},
},
"& .MuiOutlinedInput-notchedOutline": {
border: "1px solid #D7D7D7",
},
"& .MuiInput-underline:hover:not(.Mui-disabled):before, .MuiOutlinedInput-notchedOutline":
{
borderColor: "#D7D7D7 !important",
},
"& .muirtl-1kiro5a-MuiInputBase-root-MuiOutlinedInput-root.Mui-focused .MuiOutlinedInput-notchedOutline":
{
border: "1px solid #5559CE !important",
},
"& .MuiOutlinedInput-notchedOutline": {
border: isError ? "1px solid red !important" : "",
},
}}
renderOption={(props, option) => (
<Button
fullWidth
{...props}
key={option.id || props.id}
className="!flex !justify-start !p-[8px] !text-start !text-[#A1A1A1] hover:dark:!bg-[#35343D] !bg-[#FFF] dark:!bg-[#1F1D2B]"
>
{option.name}
</Button>
)}
renderInput={(params) => (
<TextField
fullWidth
{...params}
InputProps={{
...params.InputProps,
endAdornment: (
<div className="absolute left-4">
<BottomSelect />
</div>
),
}}
placeholder={label}
sx={{
borderRadius: "8px",
}}
/>
)}
/>
);
}
export default CateSelector;
+1 -1
View File
@@ -5,7 +5,7 @@ function Radios({ group, value, changeData, name }) {
<RadioGroup
value={value}
className="radio-mui"
onChange={(e) => changeData(e.target.value, name)}
onChange={(e) => changeData(e.target.value, name, false, name)}
sx={{
"& .MuiFormControlLabel-root": {
marginRight: "0 !important",
+12 -18
View File
@@ -1,37 +1,31 @@
import AutoCompleteSelect from "@/app/component/element/AutoCompleteSelect";
import SwitchContent from "./SwitchContent";
import RadioContent from "./RadioContent";
import { filterList } from "@/helper";
import { useState } from "react";
import CateSelector from "./CateSelector";
const gender = ["زن", "مرد", "هر دو"];
const degree = ["پزشک عمومی", "پزشک متخصص", "پزشک فوق تخصص", "همه موارد"];
function Form({ data, changeUrl, changeData }) {
const [list, setList] = useState({});
function Form({ data, changeData }) {
const { parentList, childrenList } = filterList(data);
console.log(filterList(data));
return (
<>
<AutoCompleteSelect
list={list.parentList}
sendAll={true}
<CateSelector
list={parentList}
label="دسته بندی"
value={data.category?.name}
updateData={(value) => {
const newData = changeData(value, "specialties", true);
setList(filterList(newData));
console.log(newData);
}}
value={data.category}
updateData={(value) => changeData(value, "category", true, "field")}
/>
{!!childrenList.length && (
<div className="mt-[24px]">
<AutoCompleteSelect
list={list.childrenList}
updateData={(value) => changeData(value, "specialties")}
sendAll={true}
value={data.specialties?.name}
<CateSelector
list={childrenList}
updateData={(value) =>
changeData(value, "specialties", false, "field")
}
value={data.specialties}
label="تخصص"
/>
</div>