bug fix
This commit is contained in:
@@ -488,44 +488,42 @@ export interface GetHotelRes {
|
|||||||
total_pages: number;
|
total_pages: number;
|
||||||
page_size: number;
|
page_size: number;
|
||||||
current_page: number;
|
current_page: number;
|
||||||
results: [
|
results: {
|
||||||
{
|
id: number;
|
||||||
id: number;
|
name: string;
|
||||||
name: string;
|
rating: number;
|
||||||
rating: number;
|
meal_plan: string;
|
||||||
meal_plan: string;
|
ticket: number;
|
||||||
ticket: number;
|
hotel_type: [
|
||||||
hotel_type: [
|
{
|
||||||
{
|
id: number;
|
||||||
|
name: string;
|
||||||
|
name_ru: string;
|
||||||
|
name_uz: string;
|
||||||
|
},
|
||||||
|
];
|
||||||
|
hotel_amenities: [
|
||||||
|
{
|
||||||
|
name: string;
|
||||||
|
name_ru: string;
|
||||||
|
name_uz: string;
|
||||||
|
icon_name: string;
|
||||||
|
},
|
||||||
|
];
|
||||||
|
hotel_features: [
|
||||||
|
{
|
||||||
|
id: number;
|
||||||
|
feature_name: string;
|
||||||
|
feature_name_uz: string;
|
||||||
|
feature_name_ru: string;
|
||||||
|
feature_type: {
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
hotel_feature_type_name_ru: string;
|
||||||
name_ru: string;
|
hotel_feature_type_name_uz: string;
|
||||||
name_uz: string;
|
};
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
hotel_amenities: [
|
}[];
|
||||||
{
|
|
||||||
name: string;
|
|
||||||
name_ru: string;
|
|
||||||
name_uz: string;
|
|
||||||
icon_name: string;
|
|
||||||
},
|
|
||||||
];
|
|
||||||
hotel_features: [
|
|
||||||
{
|
|
||||||
id: number;
|
|
||||||
feature_name: string;
|
|
||||||
feature_name_uz: string;
|
|
||||||
feature_name_ru: string;
|
|
||||||
feature_type: {
|
|
||||||
id: number;
|
|
||||||
hotel_feature_type_name_ru: string;
|
|
||||||
hotel_feature_type_name_uz: string;
|
|
||||||
};
|
|
||||||
},
|
|
||||||
];
|
|
||||||
},
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ import { Popover, PopoverContent, PopoverTrigger } from "@/shared/ui/popover";
|
|||||||
import { RadioGroup, RadioGroupItem } from "@/shared/ui/radio-group";
|
import { RadioGroup, RadioGroupItem } from "@/shared/ui/radio-group";
|
||||||
import { Textarea } from "@/shared/ui/textarea";
|
import { Textarea } from "@/shared/ui/textarea";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||||
import { ChevronDownIcon, Loader2, SquareCheckBig, XIcon } from "lucide-react";
|
import { ChevronDownIcon, Loader2, SquareCheckBig, XIcon } from "lucide-react";
|
||||||
import { useEffect, useState, type Dispatch, type SetStateAction } from "react";
|
import { useEffect, useState, type Dispatch, type SetStateAction } from "react";
|
||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
@@ -54,6 +54,7 @@ const StepOne = ({
|
|||||||
isEditMode: boolean;
|
isEditMode: boolean;
|
||||||
}) => {
|
}) => {
|
||||||
const [displayPrice, setDisplayPrice] = useState("");
|
const [displayPrice, setDisplayPrice] = useState("");
|
||||||
|
const queryClient = useQueryClient();
|
||||||
// const [tarifdisplayPrice, setTarifDisplayPrice] = useState<string[]>([]);
|
// const [tarifdisplayPrice, setTarifDisplayPrice] = useState<string[]>([]);
|
||||||
const [transportPrices, setTransportPrices] = useState<string[]>([]);
|
const [transportPrices, setTransportPrices] = useState<string[]>([]);
|
||||||
|
|
||||||
@@ -126,7 +127,7 @@ const StepOne = ({
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// 🔹 Transport
|
// 🔹 TransportS
|
||||||
const transports =
|
const transports =
|
||||||
tour.transports?.map((t, i) => ({
|
tour.transports?.map((t, i) => ({
|
||||||
transport: i + 1,
|
transport: i + 1,
|
||||||
@@ -236,6 +237,8 @@ const StepOne = ({
|
|||||||
return createTours({ body });
|
return createTours({ body });
|
||||||
},
|
},
|
||||||
onSuccess: (res) => {
|
onSuccess: (res) => {
|
||||||
|
queryClient.refetchQueries({ queryKey: ["popular_tours"] });
|
||||||
|
queryClient.refetchQueries({ queryKey: ["all_tours"] });
|
||||||
setId(res.data.data.id);
|
setId(res.data.data.id);
|
||||||
setStep(2);
|
setStep(2);
|
||||||
},
|
},
|
||||||
@@ -252,6 +255,8 @@ const StepOne = ({
|
|||||||
return updateTours({ body, id });
|
return updateTours({ body, id });
|
||||||
},
|
},
|
||||||
onSuccess: (res) => {
|
onSuccess: (res) => {
|
||||||
|
queryClient.refetchQueries({ queryKey: ["all_tours"] });
|
||||||
|
queryClient.refetchQueries({ queryKey: ["popular_tours"] });
|
||||||
setId(res.data.data.id);
|
setId(res.data.data.id);
|
||||||
setStep(2);
|
setStep(2);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -232,6 +232,8 @@ const StepTwo = ({
|
|||||||
mutationFn: (body: FormData) => createHotel({ body }),
|
mutationFn: (body: FormData) => createHotel({ body }),
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
queryClient.refetchQueries({ queryKey: ["hotel_detail"] });
|
queryClient.refetchQueries({ queryKey: ["hotel_detail"] });
|
||||||
|
queryClient.refetchQueries({ queryKey: ["popular_tours"] });
|
||||||
|
queryClient.refetchQueries({ queryKey: ["all_tours"] });
|
||||||
toast.success(t("Muvaffaqiyatli saqlandi"));
|
toast.success(t("Muvaffaqiyatli saqlandi"));
|
||||||
navigate("/tours");
|
navigate("/tours");
|
||||||
setStep(1);
|
setStep(1);
|
||||||
@@ -248,6 +250,8 @@ const StepTwo = ({
|
|||||||
editHotel({ body, id }),
|
editHotel({ body, id }),
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
queryClient.refetchQueries({ queryKey: ["hotel_detail"] });
|
queryClient.refetchQueries({ queryKey: ["hotel_detail"] });
|
||||||
|
queryClient.refetchQueries({ queryKey: ["popular_tours"] });
|
||||||
|
queryClient.refetchQueries({ queryKey: ["all_tours"] });
|
||||||
toast.success(t("Muvaffaqiyatli saqlandi"));
|
toast.success(t("Muvaffaqiyatli saqlandi"));
|
||||||
navigate("/tours");
|
navigate("/tours");
|
||||||
setStep(1);
|
setStep(1);
|
||||||
@@ -312,16 +316,20 @@ const StepTwo = ({
|
|||||||
data.hotelFeatures &&
|
data.hotelFeatures &&
|
||||||
data.hotelFeatures.forEach((id) => formData.append("hotel_features", id));
|
data.hotelFeatures.forEach((id) => formData.append("hotel_features", id));
|
||||||
|
|
||||||
if (isEditMode && hotelDetail) {
|
if (isEditMode && hotelDetail && hotelDetail?.length > 0) {
|
||||||
edit({
|
edit({
|
||||||
body: formData,
|
body: formData,
|
||||||
id: Number(hotelDetail[0].id),
|
id: Number(hotelDetail[0].id),
|
||||||
});
|
});
|
||||||
|
} else if (isEditMode && hotelDetail && hotelDetail?.length === 0) {
|
||||||
|
mutate(formData);
|
||||||
} else {
|
} else {
|
||||||
mutate(formData);
|
mutate(formData);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
console.log(hotelDetail);
|
||||||
|
|
||||||
const mealPlans = [
|
const mealPlans = [
|
||||||
"Breakfast Only",
|
"Breakfast Only",
|
||||||
"Half Board",
|
"Half Board",
|
||||||
|
|||||||
Reference in New Issue
Block a user