handle change data in doctor model, set previous data when user close modal, update list doctor after update data and change key name in url

This commit is contained in:
Ehsan
2025-09-05 23:05:02 +03:30
parent ebfe47468c
commit dc40129034
13 changed files with 175 additions and 56 deletions
-13
View File
@@ -1,17 +1,7 @@
import { useRouter } from "next/navigation";
import specialties from "@/data/specialties.json";
import Form from "./form";
function Content({ data, setData }) {
const router = useRouter();
const changeUrl = (value, name) => {
const current = new URLSearchParams(window.location.search);
current.set(name, value.id || value);
const queryString = current.toString();
router.push(`/doctors?${queryString}`);
};
const changeData = (value, name, isCategory, key) => {
const newData = { ...data, [name]: value };
@@ -23,9 +13,6 @@ function Content({ data, setData }) {
const firstChildren = filteredChildrenList[0];
newData.specialties = firstChildren || "";
changeUrl(firstChildren || value, key);
} else {
changeUrl(value, key);
}
setData(newData);