update modals & text & design

This commit is contained in:
Ehsan
2025-05-09 22:04:56 +03:30
parent 8ee3defdc0
commit a89fc4a3f9
7 changed files with 115 additions and 44 deletions
+44 -11
View File
@@ -6,22 +6,46 @@ import SortList from "./sortlist";
import ListDoctors from "./listDoctors";
import LocationD from "../icons/LocationD";
import { useSearchParams } from "next/navigation";
import ModalSearchCity from "@/app/component/modalSearchCity";
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() {
const [loading, setLoading] = useState(true);
const searchParams = useSearchParams();
const [open, setOpen] = useState(false);
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 = {
province: searchParams.get("province"),
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({
expertise: "",
gender: 0,
degree: 0,
turn: true,
});
console.log(newCity);
useEffect(() => {
setTimeout(() => {
@@ -32,16 +56,25 @@ function DoctorsPage() {
return (
<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 items-center justify-start gap-2 w-full">
<LocationD />
<p className="text-[#525252] text-[16px] font-semibold">
{" "}
{isProvinceInclude?.name || locationSelected.province || "استان"}
{/* {isProvinceInclude?.name ? "" : " / "} */}
{" / "}
{locationSelected.city || "شهر"}
</p>
</div>
<ModalSearchCity
open={open}
setOpen={setOpen}
selected={selected}
setSelected={setSelected}
>
<Button
className="!flex !ml-auto !w-fit !px-3 !py-1 !items-center !justify-start !gap-2 !cursor-pointer"
onClick={() => setOpen(true)}
>
<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">
<SearchBar data={data} setData={setData} />
<SortList data={data} setData={setData} />
+23 -2
View File
@@ -5,15 +5,36 @@ import { Button, ButtonGroup, TextField } from "@mui/material";
import SearchD from "@/components/icons/SearchD";
import ModalSearchCity from "@/app/component/modalSearchCity";
import ButtonFilter from "@/app/component/modalSearchCity/ButtonFilter";
import { useState } from "react";
import { useState, useCallback } from "react";
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() {
const [selected, setSelected] = useState({
province: "",
city: "",
});
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 (
<ButtonGroup
@@ -59,7 +80,7 @@ function SearchBar() {
pathname: "/doctors",
query: {
province: selected.province,
city: selected.city,
city: selected.city || getDefaultCityForProvince(selected.province),
},
}}
>
+13 -1
View File
@@ -1,8 +1,14 @@
import Field from "@/app/component/element/Field";
import { Button } from "@mui/material";
import Link from "next/link";
import { useState } from "react";
function LogInPage({ setIsSendMsg, setStep }) {
const [num, setNum] = useState("09");
const updateNum = (value) => {
setNum(value === "0" || !value ? "09" : value);
};
return (
<div
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>
<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>
<Button
fullWidth