diff --git a/src/pages/finance/ui/Finance.tsx b/src/pages/finance/ui/Finance.tsx
index 9a59605..e10aacc 100644
--- a/src/pages/finance/ui/Finance.tsx
+++ b/src/pages/finance/ui/Finance.tsx
@@ -242,22 +242,22 @@ export default function FinancePage({ user }: { user: Role }) {
{t("Bandlovlar va to‘lovlar")}
- {user === "moderator" ||
+ {(user === "moderator" ||
user === "buxgalter" ||
user === "admin" ||
- (user === "superuser" && (
-
- ))}
+ user === "superuser") && (
+
+ )}
{tab === "bookings" && (
@@ -443,148 +443,146 @@ export default function FinancePage({ user }: { user: Role }) {
>
)}
- {user === "moderator" ||
+ {(user === "moderator" ||
user === "buxgalter" ||
user === "admin" ||
- (user === "superuser" && (
- <>
- {tab === "agencies" && (
- <>
- {agenctLoad ? (
-
- {agencyData?.data.data.results.map((a) => (
-
-
-
- {a.name}
-
+ user === "superuser") && (
+ <>
+ {tab === "agencies" && (
+ <>
+ {agenctLoad ? (
+
+
+
+ {t("Ma'lumotlar yuklanmoqda...")}
+
+
+ ) : agencyError ? (
+
+
+
+ {t("Ma'lumotlarni yuklashda xatolik yuz berdi.")}
+
+
+
+ ) : (
+ agencyData &&
+ !agencyError &&
+ !agenctLoad && (
+ <>
+
+ {t("Partner Agencies")}
+
+
+ {agencyData?.data.data.results.map((a) => (
+
+
+
+ {a.name}
+
-
-
-
- {t("Paid")}
-
-
- {formatPrice(a.paid, true)}
-
-
-
-
- {t("Pending")}
-
-
- {formatPrice(a.pending, true)}
-
-
-
-
-
-
- {t("Bookings")}:{" "}
-
- {a.ticket_sold_count}
-
+
+
+
+ {t("Paid")}
-
- {t("Destinations")}:{" "}
-
- {a.ticket_count}
-
+
+ {formatPrice(a.paid, true)}
-
-
-
-
{t("Ko'rish")}
-
+
+
+ {t("Pending")}
+
+
+ {formatPrice(a.pending, true)}
+
- ))}
-
- >
- )
- )}
-
-
- {[...Array(agencyData?.data.data.total_pages)].map(
- (_, i) => (
-
- ),
- )}
+
+
+ {t("Bookings")}:{" "}
+
+ {a.ticket_sold_count}
+
+
+
+ {t("Destinations")}:{" "}
+
+ {a.ticket_count}
+
+
+
+
+
+ {t("Ko'rish")}
+
+
+
+ ))}
+
+ >
+ )
+ )}
+
+
+
+ {[...Array(agencyData?.data.data.total_pages)].map((_, i) => (
-
- >
- )}
- >
- ))}
+ ))}
+
+
+
+ >
+ )}
+ >
+ )}
);
diff --git a/src/pages/tours/lib/form.ts b/src/pages/tours/lib/form.ts
index b9c9a22..f82c32d 100644
--- a/src/pages/tours/lib/form.ts
+++ b/src/pages/tours/lib/form.ts
@@ -109,20 +109,20 @@ export const TourformSchema = z.object({
tariff: z.number().min(1, { message: "Transport ID majburiy" }),
price: z
.number()
- .min(0, { message: "Narx 0 dan kichik bo‘lishi mumkin emas" }),
+ .min(0, { message: "Narx 0 dan kichik bo'lishi mumkin emas" }),
}),
)
- .min(1, { message: "Kamida bitta transport tanlang." }),
+ .optional(),
transport: z
.array(
z.object({
transport: z.number().min(1, { message: "Transport ID majburiy" }),
price: z
.number()
- .min(0, { message: "Narx 0 dan kichik bo‘lishi mumkin emas" }),
+ .min(0, { message: "Narx 0 dan kichik bo'lishi mumkin emas" }),
}),
)
- .min(1, { message: "Kamida bitta transport tanlang." }),
+ .optional(),
banner: z.any().nullable(),
images: z
.array(z.union([z.instanceof(File), z.string()]))
@@ -199,7 +199,7 @@ export const TourformSchema = z.object({
name_ru: z.string().min(1, { message: "Xizmat nomi (RU) majburiy" }),
price: z
.number()
- .min(0, { message: "Narx manfiy bo‘lishi mumkin emas." }),
+ .min(0, { message: "Narx manfiy bo'lishi mumkin emas." }),
}),
)
.optional(),
diff --git a/src/pages/tours/lib/type.ts b/src/pages/tours/lib/type.ts
index dda88e4..438cdb6 100644
--- a/src/pages/tours/lib/type.ts
+++ b/src/pages/tours/lib/type.ts
@@ -64,6 +64,7 @@ export interface GetOneTours {
{
price: number;
transport: {
+ id: number;
name: string;
icon_name: string;
};
@@ -394,6 +395,7 @@ export interface GetDetailTours {
transports: {
price: number;
transport: {
+ id: number;
name: string;
icon_name: string;
};
@@ -447,9 +449,7 @@ export interface GetDetailTours {
];
tariff: [
{
- tariff: {
- name: string;
- };
+ tariff: number;
price: number;
},
];
diff --git a/src/pages/tours/ui/StepOne.tsx b/src/pages/tours/ui/StepOne.tsx
index 1b02370..ec104b5 100644
--- a/src/pages/tours/ui/StepOne.tsx
+++ b/src/pages/tours/ui/StepOne.tsx
@@ -330,11 +330,11 @@ const StepOne = ({
if (value.banner instanceof File) {
formData.append("image_banner", value.banner);
}
- value.tarif.forEach((e, i) => {
+ value.tarif?.forEach((e, i) => {
formData.append(`tariff[${i}]tariff`, String(e.tariff));
formData.append(`tariff[${i}]price`, String(e.price));
});
- value.transport.forEach((e, i) => {
+ value.transport?.forEach((e, i) => {
formData.append(`transports[${i}]transport`, String(e.transport));
formData.append(`transports[${i}]price`, String(e.price));
});
@@ -1005,11 +1005,10 @@ const StepOne = ({
onChange={(e) => {
const raw = e.target.value.replace(/\D/g, "");
const num = Number(raw);
- const updatedTransport = form
- .getValues("tarif")
- .map((t, i) =>
- i === idx ? { ...t, price: num } : t,
- );
+ const currentTarifs = form.getValues("tarif") || [];
+ const updatedTransport = currentTarifs.map((t, i) =>
+ i === idx ? { ...t, price: num } : t,
+ );
form.setValue("tarif", updatedTransport);
@@ -1024,7 +1023,7 @@ const StepOne = ({