fix: Fix station create page
All checks were successful
release-tag / release-image (push) Successful in 2m16s

This commit is contained in:
2025-05-25 23:16:33 +03:00
parent b1a4edc136
commit db5e9d9fc4
8 changed files with 565 additions and 416 deletions

View File

@ -50,8 +50,12 @@ const style = {
};
export const StationEditModal = observer(() => {
const { stationModalOpen, setStationModalOpenAction, selectedStationId, selectedRouteId } =
stationStore;
const {
stationModalOpen,
setStationModalOpenAction,
selectedStationId,
selectedRouteId,
} = stationStore;
const { language } = languageStore;
useEffect(() => {
@ -63,10 +67,9 @@ export const StationEditModal = observer(() => {
const apiUrl = useApiUrl();
const { data: stationQuery, isLoading: isStationLoading } = useCustom({
url: `${apiUrl}/route/${selectedRouteId ?? 1}/station`,
method: 'get'
});
url: `${apiUrl}/route/${selectedRouteId ?? 1}/station`,
method: "get",
});
const {
register,
@ -84,7 +87,6 @@ export const StationEditModal = observer(() => {
id: "",
redirect: false,
onMutationSuccess: (data) => {
console.log(data);
setStationModalOpenAction(false);
reset();
window.location.reload();
@ -99,14 +101,14 @@ export const StationEditModal = observer(() => {
useEffect(() => {
if (stationModalOpen) {
const station = stationQuery?.data?.find((station: StationItem) => station.id === selectedStationId);
if(!station) return;
for(const key in station) {
const station = stationQuery?.data?.find(
(station: StationItem) => station.id === selectedStationId
);
if (!station) return;
for (const key in station) {
setValue(key, station[key]);
console.log(key, station[key]);
}
setValue("station_id", station.id);
console.log(stationQuery);
}
}, [stationModalOpen, stationQuery]);