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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user