update modals & text & design
This commit is contained in:
@@ -10,13 +10,15 @@ function AutoCompleteSelect({
|
|||||||
name,
|
name,
|
||||||
label,
|
label,
|
||||||
disabled = false,
|
disabled = false,
|
||||||
|
listboxProps
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<Autocomplete
|
<Autocomplete
|
||||||
value={value || null}
|
|
||||||
disablePortal
|
disablePortal
|
||||||
options={list}
|
options={list}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
|
value={value || null}
|
||||||
|
ListboxProps={listboxProps}
|
||||||
className="!w-full !rounded-lg auto-complete-selector"
|
className="!w-full !rounded-lg auto-complete-selector"
|
||||||
onChange={(event, newValue) => {
|
onChange={(event, newValue) => {
|
||||||
updateData && updateData(newValue ? newValue.label : "", name);
|
updateData && updateData(newValue ? newValue.label : "", name);
|
||||||
@@ -25,9 +27,9 @@ function AutoCompleteSelect({
|
|||||||
...styleTextSelectRight,
|
...styleTextSelectRight,
|
||||||
// Hide Icon Number
|
// Hide Icon Number
|
||||||
"& input::-webkit-outer-spin-button, & input::-webkit-inner-spin-button":
|
"& input::-webkit-outer-spin-button, & input::-webkit-inner-spin-button":
|
||||||
{
|
{
|
||||||
display: "none",
|
display: "none",
|
||||||
},
|
},
|
||||||
"& input[type=number]": {
|
"& input[type=number]": {
|
||||||
MozAppearance: "textfield",
|
MozAppearance: "textfield",
|
||||||
},
|
},
|
||||||
@@ -46,13 +48,13 @@ function AutoCompleteSelect({
|
|||||||
border: "1px solid #D7D7D7",
|
border: "1px solid #D7D7D7",
|
||||||
},
|
},
|
||||||
"& .MuiInput-underline:hover:not(.Mui-disabled):before, .MuiOutlinedInput-notchedOutline":
|
"& .MuiInput-underline:hover:not(.Mui-disabled):before, .MuiOutlinedInput-notchedOutline":
|
||||||
{
|
{
|
||||||
borderColor: "#D7D7D7 !important",
|
borderColor: "#D7D7D7 !important",
|
||||||
},
|
},
|
||||||
"& .muirtl-1kiro5a-MuiInputBase-root-MuiOutlinedInput-root.Mui-focused .MuiOutlinedInput-notchedOutline":
|
"& .muirtl-1kiro5a-MuiInputBase-root-MuiOutlinedInput-root.Mui-focused .MuiOutlinedInput-notchedOutline":
|
||||||
{
|
{
|
||||||
border: "1px solid #5559CE !important",
|
border: "1px solid #5559CE !important",
|
||||||
},
|
},
|
||||||
"& .MuiOutlinedInput-notchedOutline": {
|
"& .MuiOutlinedInput-notchedOutline": {
|
||||||
border: isError ? "1px solid red !important" : "",
|
border: isError ? "1px solid red !important" : "",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,25 +1,22 @@
|
|||||||
import { TextField } from "@mui/material";
|
import { TextField } from "@mui/material";
|
||||||
import { styleTextSelectRight } from "@/mui";
|
import { styleTextSelectRight } from "@/mui";
|
||||||
|
|
||||||
function Field({
|
function Field({ title, type, dir, value, updateState }) {
|
||||||
title,
|
|
||||||
type,
|
|
||||||
dir,
|
|
||||||
// isPlaceHolder
|
|
||||||
}) {
|
|
||||||
return (
|
return (
|
||||||
<TextField
|
<TextField
|
||||||
label={title}
|
label={title}
|
||||||
dir={dir || "rtl"}
|
dir={dir || "rtl"}
|
||||||
type={type || "text"}
|
type={type || "text"}
|
||||||
|
value={value}
|
||||||
|
onChange={(e) => updateState(e.target.value)}
|
||||||
className="!w-full !mx-auto !bg-[#FFF]"
|
className="!w-full !mx-auto !bg-[#FFF]"
|
||||||
sx={{
|
sx={{
|
||||||
...styleTextSelectRight,
|
...styleTextSelectRight,
|
||||||
// Hide Icon Number
|
// Hide Icon Number
|
||||||
"& input::-webkit-outer-spin-button, & input::-webkit-inner-spin-button":
|
"& input::-webkit-outer-spin-button, & input::-webkit-inner-spin-button":
|
||||||
{
|
{
|
||||||
display: "none",
|
display: "none",
|
||||||
},
|
},
|
||||||
"& input[type=number]": {
|
"& input[type=number]": {
|
||||||
MozAppearance: "textfield",
|
MozAppearance: "textfield",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -15,6 +15,12 @@ function Content({
|
|||||||
isProvinceInclude,
|
isProvinceInclude,
|
||||||
}) {
|
}) {
|
||||||
const citySelected = selected.city;
|
const citySelected = selected.city;
|
||||||
|
const listboxProps = {
|
||||||
|
style: {
|
||||||
|
maxHeight: 200,
|
||||||
|
overflow: "auto",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
@@ -29,15 +35,17 @@ function Content({
|
|||||||
</p>
|
</p>
|
||||||
<div className="flex md:min-w-[344px] flex-col mt-[52px] md:mt-[44px] mb-14 justify-center items-center gap-10">
|
<div className="flex md:min-w-[344px] flex-col mt-[52px] md:mt-[44px] mb-14 justify-center items-center gap-10">
|
||||||
<AutoCompleteSelect
|
<AutoCompleteSelect
|
||||||
updateData={updateData}
|
|
||||||
value={selected && provinceSelected}
|
value={selected && provinceSelected}
|
||||||
disabled={isProvinceInclude}
|
disabled={isProvinceInclude}
|
||||||
|
listboxProps={listboxProps}
|
||||||
|
updateData={updateData}
|
||||||
list={states}
|
list={states}
|
||||||
label="استان"
|
label="استان"
|
||||||
name="province"
|
name="province"
|
||||||
/>
|
/>
|
||||||
<AutoCompleteSelect
|
<AutoCompleteSelect
|
||||||
updateData={updateData}
|
updateData={updateData}
|
||||||
|
listboxProps={listboxProps}
|
||||||
value={
|
value={
|
||||||
selected &&
|
selected &&
|
||||||
citySelected &&
|
citySelected &&
|
||||||
@@ -50,8 +58,8 @@ function Content({
|
|||||||
disabled={
|
disabled={
|
||||||
isProvinceInclude
|
isProvinceInclude
|
||||||
? !isProvinceInclude ||
|
? !isProvinceInclude ||
|
||||||
!provinceSelected ||
|
!provinceSelected ||
|
||||||
filteredCities.length === 0
|
filteredCities.length === 0
|
||||||
: !provinceSelected || filteredCities.length === 0
|
: !provinceSelected || filteredCities.length === 0
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -13,7 +13,10 @@ import { useProvince } from "@/context/ProvinceProvider";
|
|||||||
function ModalSearchCity({ children, selected, setSelected, open, setOpen }) {
|
function ModalSearchCity({ children, selected, setSelected, open, setOpen }) {
|
||||||
const provinceSelected = selected.province;
|
const provinceSelected = selected.province;
|
||||||
const { isProvinceInclude } = useProvince();
|
const { isProvinceInclude } = useProvince();
|
||||||
const newProvinceData = isProvinceInclude?.id === 63;
|
const newProvinceData =
|
||||||
|
isProvinceInclude && isProvinceInclude.id === "63"
|
||||||
|
? false
|
||||||
|
: isProvinceInclude;
|
||||||
|
|
||||||
const [states, setStates] = useState([]);
|
const [states, setStates] = useState([]);
|
||||||
const [cities, setCities] = useState([]);
|
const [cities, setCities] = useState([]);
|
||||||
@@ -21,15 +24,12 @@ function ModalSearchCity({ children, selected, setSelected, open, setOpen }) {
|
|||||||
|
|
||||||
const handleClose = () => setOpen(false);
|
const handleClose = () => setOpen(false);
|
||||||
|
|
||||||
// Load states and cities from JSON files
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Format states data to match the structure expected by AutoCompleteSelect
|
|
||||||
const formattedStates = statesData.map((state) => ({
|
const formattedStates = statesData.map((state) => ({
|
||||||
label: state.name,
|
label: state.name,
|
||||||
id: state.id,
|
id: state.id,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Format cities data
|
|
||||||
const formattedCities = citiesData.map((city) => ({
|
const formattedCities = citiesData.map((city) => ({
|
||||||
label: city.name,
|
label: city.name,
|
||||||
id: city.id,
|
id: city.id,
|
||||||
@@ -40,7 +40,6 @@ function ModalSearchCity({ children, selected, setSelected, open, setOpen }) {
|
|||||||
setCities(formattedCities);
|
setCities(formattedCities);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// Filter cities when state is selected
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (provinceSelected) {
|
if (provinceSelected) {
|
||||||
const selectedState = states.find(
|
const selectedState = states.find(
|
||||||
@@ -53,11 +52,11 @@ function ModalSearchCity({ children, selected, setSelected, open, setOpen }) {
|
|||||||
);
|
);
|
||||||
setFilteredCities(filteredCities);
|
setFilteredCities(filteredCities);
|
||||||
}
|
}
|
||||||
} else if (isProvinceInclude) {
|
} else if (newProvinceData) {
|
||||||
setSelected({
|
setSelected({
|
||||||
...selected,
|
...selected,
|
||||||
province: statesData.find(
|
province: statesData.find(
|
||||||
(state) => state.id === isProvinceInclude.province_id
|
(state) => state.id === newProvinceData.province_id
|
||||||
)?.name,
|
)?.name,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -68,7 +67,6 @@ function ModalSearchCity({ children, selected, setSelected, open, setOpen }) {
|
|||||||
|
|
||||||
const updateData = (event, name) => {
|
const updateData = (event, name) => {
|
||||||
if (name === "province" && event !== provinceSelected) {
|
if (name === "province" && event !== provinceSelected) {
|
||||||
// If state changes, reset city selection
|
|
||||||
setSelected({ province: event, city: "" });
|
setSelected({ province: event, city: "" });
|
||||||
} else {
|
} else {
|
||||||
setSelected({ ...selected, [name]: event });
|
setSelected({ ...selected, [name]: event });
|
||||||
|
|||||||
+44
-11
@@ -6,22 +6,46 @@ import SortList from "./sortlist";
|
|||||||
import ListDoctors from "./listDoctors";
|
import ListDoctors from "./listDoctors";
|
||||||
import LocationD from "../icons/LocationD";
|
import LocationD from "../icons/LocationD";
|
||||||
import { useSearchParams } from "next/navigation";
|
import { useSearchParams } from "next/navigation";
|
||||||
|
import ModalSearchCity from "@/app/component/modalSearchCity";
|
||||||
import { useProvince } from "@/context/ProvinceProvider";
|
import { useProvince } from "@/context/ProvinceProvider";
|
||||||
|
import { Button } from "@mui/material";
|
||||||
|
|
||||||
|
// Data
|
||||||
|
import citiesData from "@/data/city.json";
|
||||||
|
import statesData from "@/data/state.json";
|
||||||
|
|
||||||
function DoctorsPage() {
|
function DoctorsPage() {
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const searchParams = useSearchParams();
|
const [open, setOpen] = useState(false);
|
||||||
const { isProvinceInclude } = useProvince();
|
const { isProvinceInclude } = useProvince();
|
||||||
|
const [selected, setSelected] = useState({
|
||||||
|
// province: isProvinceInclude?.name || locationSelected.province,
|
||||||
|
// city: locationSelected.city || newCity,
|
||||||
|
province: isProvinceInclude?.name,
|
||||||
|
city: null,
|
||||||
|
});
|
||||||
|
const searchParams = useSearchParams();
|
||||||
const locationSelected = {
|
const locationSelected = {
|
||||||
province: searchParams.get("province"),
|
province: searchParams.get("province"),
|
||||||
city: searchParams.get("city"),
|
city: searchParams.get("city"),
|
||||||
};
|
};
|
||||||
|
const provinceId = statesData.find(
|
||||||
|
(state) => state.name === locationSelected?.province
|
||||||
|
);
|
||||||
|
|
||||||
|
const newCity =
|
||||||
|
locationSelected.city ||
|
||||||
|
(provinceId &&
|
||||||
|
citiesData.find((city) => city.province_id === provinceId.id)?.name);
|
||||||
|
|
||||||
const [data, setData] = useState({
|
const [data, setData] = useState({
|
||||||
expertise: "",
|
expertise: "",
|
||||||
gender: 0,
|
gender: 0,
|
||||||
degree: 0,
|
degree: 0,
|
||||||
turn: true,
|
turn: true,
|
||||||
});
|
});
|
||||||
|
console.log(newCity);
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -32,16 +56,25 @@ function DoctorsPage() {
|
|||||||
return (
|
return (
|
||||||
<div className="pt-[95px] sm:pt-[120px] padding-responsive">
|
<div className="pt-[95px] sm:pt-[120px] padding-responsive">
|
||||||
<div className="flex justify-center gap-[16px] sm:gap-[19px] md:gap-[22px] lg:gap-[24px] flex-col items-center mt-0 md:mt-[40px] lg:mt-[90px]">
|
<div className="flex justify-center gap-[16px] sm:gap-[19px] md:gap-[22px] lg:gap-[24px] flex-col items-center mt-0 md:mt-[40px] lg:mt-[90px]">
|
||||||
<div className="flex items-center justify-start gap-2 w-full">
|
<ModalSearchCity
|
||||||
<LocationD />
|
open={open}
|
||||||
<p className="text-[#525252] text-[16px] font-semibold">
|
setOpen={setOpen}
|
||||||
{" "}
|
selected={selected}
|
||||||
{isProvinceInclude?.name || locationSelected.province || "استان"}
|
setSelected={setSelected}
|
||||||
{/* {isProvinceInclude?.name ? "" : " / "} */}
|
>
|
||||||
{" / "}
|
<Button
|
||||||
{locationSelected.city || "شهر"}
|
className="!flex !ml-auto !w-fit !px-3 !py-1 !items-center !justify-start !gap-2 !cursor-pointer"
|
||||||
</p>
|
onClick={() => setOpen(true)}
|
||||||
</div>
|
>
|
||||||
|
<LocationD />
|
||||||
|
<p className="text-[#525252] text-[16px] font-semibold">
|
||||||
|
{" "}
|
||||||
|
{selected.province || "استان"}
|
||||||
|
{" / "}
|
||||||
|
{selected.city || "شهر"}
|
||||||
|
</p>
|
||||||
|
</Button>
|
||||||
|
</ModalSearchCity>
|
||||||
<div className="flex flex-col lg:flex-row items-start lg:items-center justify-center gap-[24px] lg:gap-[32px] w-full">
|
<div className="flex flex-col lg:flex-row items-start lg:items-center justify-center gap-[24px] lg:gap-[32px] w-full">
|
||||||
<SearchBar data={data} setData={setData} />
|
<SearchBar data={data} setData={setData} />
|
||||||
<SortList data={data} setData={setData} />
|
<SortList data={data} setData={setData} />
|
||||||
|
|||||||
@@ -5,15 +5,36 @@ import { Button, ButtonGroup, TextField } from "@mui/material";
|
|||||||
import SearchD from "@/components/icons/SearchD";
|
import SearchD from "@/components/icons/SearchD";
|
||||||
import ModalSearchCity from "@/app/component/modalSearchCity";
|
import ModalSearchCity from "@/app/component/modalSearchCity";
|
||||||
import ButtonFilter from "@/app/component/modalSearchCity/ButtonFilter";
|
import ButtonFilter from "@/app/component/modalSearchCity/ButtonFilter";
|
||||||
import { useState } from "react";
|
import { useState, useCallback } from "react";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
|
||||||
|
import statesData from "@/data/state.json";
|
||||||
|
import citiesData from "@/data/city.json";
|
||||||
|
|
||||||
|
const provinceIdMap = Object.fromEntries(
|
||||||
|
statesData.map((state) => [state.name, state.id])
|
||||||
|
);
|
||||||
|
const citiesByProvinceId = citiesData.reduce((acc, city) => {
|
||||||
|
if (!acc[city.province_id]) acc[city.province_id] = [];
|
||||||
|
acc[city.province_id].push(city);
|
||||||
|
return acc;
|
||||||
|
}, {});
|
||||||
|
|
||||||
function SearchBar() {
|
function SearchBar() {
|
||||||
const [selected, setSelected] = useState({
|
const [selected, setSelected] = useState({
|
||||||
province: "",
|
province: "",
|
||||||
city: "",
|
city: "",
|
||||||
});
|
});
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
|
const getDefaultCityForProvince = useCallback((provinceName) => {
|
||||||
|
if (!provinceName) return undefined;
|
||||||
|
const provinceId = provinceIdMap[provinceName];
|
||||||
|
return citiesByProvinceId[provinceId]?.[0]?.name;
|
||||||
|
}, []);
|
||||||
|
console.log(getDefaultCityForProvince(selected.province));
|
||||||
|
console.log(selected.province);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ButtonGroup
|
<ButtonGroup
|
||||||
@@ -59,7 +80,7 @@ function SearchBar() {
|
|||||||
pathname: "/doctors",
|
pathname: "/doctors",
|
||||||
query: {
|
query: {
|
||||||
province: selected.province,
|
province: selected.province,
|
||||||
city: selected.city,
|
city: selected.city || getDefaultCityForProvince(selected.province),
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,8 +1,14 @@
|
|||||||
import Field from "@/app/component/element/Field";
|
import Field from "@/app/component/element/Field";
|
||||||
import { Button } from "@mui/material";
|
import { Button } from "@mui/material";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
import { useState } from "react";
|
||||||
|
|
||||||
function LogInPage({ setIsSendMsg, setStep }) {
|
function LogInPage({ setIsSendMsg, setStep }) {
|
||||||
|
const [num, setNum] = useState("09");
|
||||||
|
const updateNum = (value) => {
|
||||||
|
setNum(value === "0" || !value ? "09" : value);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="rounded-[16px] mt-[64px] opacity-page sm:mt-[32px] border border-solid sm:border-[#EFEFEF] bg-transparent sm:bg-[#FFF]
|
className="rounded-[16px] mt-[64px] opacity-page sm:mt-[32px] border border-solid sm:border-[#EFEFEF] bg-transparent sm:bg-[#FFF]
|
||||||
@@ -15,7 +21,13 @@ function LogInPage({ setIsSendMsg, setStep }) {
|
|||||||
شماره همراه خود را وارد نمایید.
|
شماره همراه خود را وارد نمایید.
|
||||||
</p>
|
</p>
|
||||||
<div className="mt-[16px] sm:mt-[19px] md:mt-[22px] lg:mt-[24px] mb-[40px] sm:mb-[37px] md:mb-[36px] lg:mb-[32px]">
|
<div className="mt-[16px] sm:mt-[19px] md:mt-[22px] lg:mt-[24px] mb-[40px] sm:mb-[37px] md:mb-[36px] lg:mb-[32px]">
|
||||||
<Field type="number" title="شماره همراه" dir="ltr" />
|
<Field
|
||||||
|
dir="ltr"
|
||||||
|
value={num}
|
||||||
|
type="number"
|
||||||
|
title="شماره همراه"
|
||||||
|
updateState={updateNum}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<Button
|
<Button
|
||||||
fullWidth
|
fullWidth
|
||||||
|
|||||||
Reference in New Issue
Block a user