fix: Fix station create page
All checks were successful
release-tag / release-image (push) Successful in 2m16s
All checks were successful
release-tag / release-image (push) Successful in 2m16s
This commit is contained in:
@ -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]);
|
||||
|
||||
|
Reference in New Issue
Block a user