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