barcha apilar ulandi
This commit is contained in:
@@ -242,7 +242,7 @@ export default function FinancePage({ user }: { user: Role }) {
|
|||||||
<CreditCard size={18} />
|
<CreditCard size={18} />
|
||||||
{t("Bandlovlar va to‘lovlar")}
|
{t("Bandlovlar va to‘lovlar")}
|
||||||
</button>
|
</button>
|
||||||
{user === "tour_admin" ||
|
{user === "moderator" ||
|
||||||
user === "buxgalter" ||
|
user === "buxgalter" ||
|
||||||
user === "admin" ||
|
user === "admin" ||
|
||||||
(user === "superuser" && (
|
(user === "superuser" && (
|
||||||
@@ -443,7 +443,7 @@ export default function FinancePage({ user }: { user: Role }) {
|
|||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{user === "tour_admin" ||
|
{user === "moderator" ||
|
||||||
user === "buxgalter" ||
|
user === "buxgalter" ||
|
||||||
user === "admin" ||
|
user === "admin" ||
|
||||||
(user === "superuser" && (
|
(user === "superuser" && (
|
||||||
|
|||||||
@@ -57,10 +57,8 @@ export const TourformSchema = z.object({
|
|||||||
.min(1, { message: "Jo‘nash vaqti majburiy" })
|
.min(1, { message: "Jo‘nash vaqti majburiy" })
|
||||||
.refine(
|
.refine(
|
||||||
(val) => {
|
(val) => {
|
||||||
// HH:MM:SS formatini tekshirish
|
|
||||||
const parts = val.split(":");
|
const parts = val.split(":");
|
||||||
if (parts.length !== 3) return false;
|
if (parts.length !== 3) return false;
|
||||||
|
|
||||||
const [hour, minute, second] = parts.map(Number);
|
const [hour, minute, second] = parts.map(Number);
|
||||||
return (
|
return (
|
||||||
!isNaN(hour) &&
|
!isNaN(hour) &&
|
||||||
@@ -84,10 +82,8 @@ export const TourformSchema = z.object({
|
|||||||
.min(1, { message: "Jo‘nash vaqti majburiy" })
|
.min(1, { message: "Jo‘nash vaqti majburiy" })
|
||||||
.refine(
|
.refine(
|
||||||
(val) => {
|
(val) => {
|
||||||
// HH:MM:SS formatini tekshirish
|
|
||||||
const parts = val.split(":");
|
const parts = val.split(":");
|
||||||
if (parts.length !== 3) return false;
|
if (parts.length !== 3) return false;
|
||||||
|
|
||||||
const [hour, minute, second] = parts.map(Number);
|
const [hour, minute, second] = parts.map(Number);
|
||||||
return (
|
return (
|
||||||
!isNaN(hour) &&
|
!isNaN(hour) &&
|
||||||
@@ -105,7 +101,7 @@ export const TourformSchema = z.object({
|
|||||||
),
|
),
|
||||||
}),
|
}),
|
||||||
languages: z.string().min(1, { message: "Majburiy maydon" }),
|
languages: z.string().min(1, { message: "Majburiy maydon" }),
|
||||||
duration: z.number().min(1, { message: "Kamida 1kun bo'lishi kerak" }),
|
duration: z.number().min(1, { message: "Kamida 1 kun bo'lishi kerak" }),
|
||||||
badges: z.array(z.number()).optional(),
|
badges: z.array(z.number()).optional(),
|
||||||
tarif: z
|
tarif: z
|
||||||
.array(
|
.array(
|
||||||
@@ -113,18 +109,17 @@ export const TourformSchema = z.object({
|
|||||||
tariff: z.number().min(1, { message: "Transport ID majburiy" }),
|
tariff: z.number().min(1, { message: "Transport ID majburiy" }),
|
||||||
price: z
|
price: z
|
||||||
.number()
|
.number()
|
||||||
.min(0, { message: "Narx 0 dan kichik bo‘lishi mumkin emas" }), // 0 ham ruxsat
|
.min(0, { message: "Narx 0 dan kichik bo‘lishi mumkin emas" }),
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.min(1, { message: "Kamida bitta transport tanlang." }),
|
.min(1, { message: "Kamida bitta transport tanlang." }),
|
||||||
|
|
||||||
transport: z
|
transport: z
|
||||||
.array(
|
.array(
|
||||||
z.object({
|
z.object({
|
||||||
transport: z.number().min(1, { message: "Transport ID majburiy" }),
|
transport: z.number().min(1, { message: "Transport ID majburiy" }),
|
||||||
price: z
|
price: z
|
||||||
.number()
|
.number()
|
||||||
.min(0, { message: "Narx 0 dan kichik bo‘lishi mumkin emas" }), // 0 ham ruxsat
|
.min(0, { message: "Narx 0 dan kichik bo‘lishi mumkin emas" }),
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.min(1, { message: "Kamida bitta transport tanlang." }),
|
.min(1, { message: "Kamida bitta transport tanlang." }),
|
||||||
@@ -135,23 +130,26 @@ export const TourformSchema = z.object({
|
|||||||
amenities: z
|
amenities: z
|
||||||
.array(
|
.array(
|
||||||
z.object({
|
z.object({
|
||||||
name: z.string().min(1, { message: "Majburoy maydon" }),
|
name: z.string().min(1, { message: "Majburiy maydon" }),
|
||||||
name_ru: z.string().min(1, { message: "Majburoy maydon" }),
|
name_ru: z.string().min(1, { message: "Majburiy maydon" }),
|
||||||
icon_name: z.string().min(1, { message: "Majburoy maydon" }),
|
icon_name: z.string().min(1, { message: "Majburiy maydon" }),
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.min(1, { message: "Kamida bitta qulaylik kiriting." }),
|
.min(1, { message: "Kamida bitta qulaylik kiriting." }),
|
||||||
|
|
||||||
|
// 🔹 Quyidagilar endi ixtiyoriy (required emas)
|
||||||
hotel_services: z
|
hotel_services: z
|
||||||
.array(
|
.array(
|
||||||
z.object({
|
z.object({
|
||||||
image: z.any().nullable(),
|
image: z.any().nullable(),
|
||||||
title: z.string().min(1, "Xizmat nomi majburiy"),
|
title: z.string().min(1, "Xizmat nomi majburiy"),
|
||||||
title_ru: z.string().min(1, { message: "Majburoy maydon" }),
|
title_ru: z.string().min(1, { message: "Majburiy maydon" }),
|
||||||
description: z.string().min(1, "Tavsif majburiy"),
|
description: z.string().min(1, "Tavsif majburiy"),
|
||||||
desc_ru: z.string().min(1, { message: "Majburoy maydon" }),
|
desc_ru: z.string().min(1, { message: "Majburiy maydon" }),
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.min(1, { message: "Kamida bitta xizmat kiriting." }),
|
.optional(),
|
||||||
|
|
||||||
hotel_meals: z
|
hotel_meals: z
|
||||||
.array(
|
.array(
|
||||||
z.object({
|
z.object({
|
||||||
@@ -184,6 +182,7 @@ export const TourformSchema = z.object({
|
|||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.min(1, { message: "Kamida bitta xizmat kiriting." }),
|
.min(1, { message: "Kamida bitta xizmat kiriting." }),
|
||||||
|
|
||||||
extra_service: z
|
extra_service: z
|
||||||
.array(
|
.array(
|
||||||
z.object({
|
z.object({
|
||||||
@@ -191,7 +190,7 @@ export const TourformSchema = z.object({
|
|||||||
name_ru: z.string().min(1, { message: "Xizmat nomi (RU) majburiy" }),
|
name_ru: z.string().min(1, { message: "Xizmat nomi (RU) majburiy" }),
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.min(1, { message: "Kamida bitta bepul xizmat kiriting." }),
|
.optional(),
|
||||||
|
|
||||||
paid_extra_service: z
|
paid_extra_service: z
|
||||||
.array(
|
.array(
|
||||||
@@ -203,5 +202,5 @@ export const TourformSchema = z.object({
|
|||||||
.min(0, { message: "Narx manfiy bo‘lishi mumkin emas." }),
|
.min(0, { message: "Narx manfiy bo‘lishi mumkin emas." }),
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.min(1, { message: "Kamida bitta pullik xizmat kiriting." }),
|
.optional(),
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -356,15 +356,16 @@ const StepOne = ({
|
|||||||
name_ru: e.name_ru,
|
name_ru: e.name_ru,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
value.hotel_services.forEach((e, i) => {
|
value.hotel_services &&
|
||||||
if (e instanceof File) {
|
value.hotel_services.forEach((e, i) => {
|
||||||
formData.append(`ticket_included_services[${i}]image`, e.image);
|
if (e instanceof File) {
|
||||||
formData.append(`ticket_included_services[${i}]title`, e.title);
|
formData.append(`ticket_included_services[${i}]image`, e.image);
|
||||||
formData.append(`ticket_included_services[${i}]title_ru`, e.title_ru);
|
formData.append(`ticket_included_services[${i}]title`, e.title);
|
||||||
formData.append(`ticket_included_services[${i}]desc_ru`, e.desc_ru);
|
formData.append(`ticket_included_services[${i}]title_ru`, e.title_ru);
|
||||||
formData.append(`ticket_included_services[${i}]desc`, e.description);
|
formData.append(`ticket_included_services[${i}]desc_ru`, e.desc_ru);
|
||||||
}
|
formData.append(`ticket_included_services[${i}]desc`, e.description);
|
||||||
});
|
}
|
||||||
|
});
|
||||||
value.ticket_itinerary.forEach((e, i) => {
|
value.ticket_itinerary.forEach((e, i) => {
|
||||||
e.ticket_itinerary_image.forEach((l, f) => {
|
e.ticket_itinerary_image.forEach((l, f) => {
|
||||||
if (e instanceof File) {
|
if (e instanceof File) {
|
||||||
@@ -397,15 +398,17 @@ const StepOne = ({
|
|||||||
formData.append(`ticket_hotel_meals[${i}]desc_ru`, e.desc_ru);
|
formData.append(`ticket_hotel_meals[${i}]desc_ru`, e.desc_ru);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
value.extra_service.forEach((e, i) => {
|
value.extra_service &&
|
||||||
formData.append(`extra_service[${i}]name`, e.name);
|
value.extra_service.forEach((e, i) => {
|
||||||
formData.append(`extra_service[${i}]name_ru`, e.name_ru);
|
formData.append(`extra_service[${i}]name`, e.name);
|
||||||
});
|
formData.append(`extra_service[${i}]name_ru`, e.name_ru);
|
||||||
value.paid_extra_service.forEach((e, i) => {
|
});
|
||||||
formData.append(`paid_extra_service[${i}]name`, e.name);
|
value.paid_extra_service &&
|
||||||
formData.append(`paid_extra_service[${i}]name_ru`, e.name_ru);
|
value.paid_extra_service.forEach((e, i) => {
|
||||||
formData.append(`paid_extra_service[${i}]price`, String(e.price));
|
formData.append(`paid_extra_service[${i}]name`, e.name);
|
||||||
});
|
formData.append(`paid_extra_service[${i}]name_ru`, e.name_ru);
|
||||||
|
formData.append(`paid_extra_service[${i}]price`, String(e.price));
|
||||||
|
});
|
||||||
if (isEditMode && id) {
|
if (isEditMode && id) {
|
||||||
update({
|
update({
|
||||||
body: formData,
|
body: formData,
|
||||||
@@ -1383,7 +1386,7 @@ const StepOne = ({
|
|||||||
<div className="flex flex-col gap-4">
|
<div className="flex flex-col gap-4">
|
||||||
{/* Ko'rsatilayotgan xizmatlar */}
|
{/* Ko'rsatilayotgan xizmatlar */}
|
||||||
<div className="flex flex-wrap gap-2">
|
<div className="flex flex-wrap gap-2">
|
||||||
{form.watch("extra_service").map((item, idx) => (
|
{(form.watch("extra_service") ?? []).map((item, idx) => (
|
||||||
<Badge
|
<Badge
|
||||||
key={idx}
|
key={idx}
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
@@ -1393,7 +1396,7 @@ const StepOne = ({
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
const current = form.getValues("extra_service");
|
const current = form.getValues("extra_service") ?? [];
|
||||||
form.setValue(
|
form.setValue(
|
||||||
"extra_service",
|
"extra_service",
|
||||||
current.filter((_, i) => i !== idx),
|
current.filter((_, i) => i !== idx),
|
||||||
@@ -1432,7 +1435,7 @@ const StepOne = ({
|
|||||||
) as HTMLInputElement;
|
) as HTMLInputElement;
|
||||||
|
|
||||||
if (nameInput.value && nameRuInput.value) {
|
if (nameInput.value && nameRuInput.value) {
|
||||||
const current = form.getValues("extra_service");
|
const current = form.getValues("extra_service") ?? [];
|
||||||
form.setValue("extra_service", [
|
form.setValue("extra_service", [
|
||||||
...current,
|
...current,
|
||||||
{
|
{
|
||||||
@@ -1479,7 +1482,8 @@ const StepOne = ({
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
const current = form.getValues("paid_extra_service");
|
const current =
|
||||||
|
form.getValues("paid_extra_service") ?? [];
|
||||||
form.setValue(
|
form.setValue(
|
||||||
"paid_extra_service",
|
"paid_extra_service",
|
||||||
current.filter((_, i) => i !== idx),
|
current.filter((_, i) => i !== idx),
|
||||||
@@ -1545,7 +1549,8 @@ const StepOne = ({
|
|||||||
nameRuInput.value.trim() &&
|
nameRuInput.value.trim() &&
|
||||||
!isNaN(num)
|
!isNaN(num)
|
||||||
) {
|
) {
|
||||||
const current = form.getValues("paid_extra_service");
|
const current =
|
||||||
|
form.getValues("paid_extra_service") ?? [];
|
||||||
form.setValue("paid_extra_service", [
|
form.setValue("paid_extra_service", [
|
||||||
...current,
|
...current,
|
||||||
{
|
{
|
||||||
@@ -1641,7 +1646,8 @@ const StepOne = ({
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
const current = form.getValues("hotel_services");
|
const current =
|
||||||
|
form.getValues("hotel_services") ?? [];
|
||||||
form.setValue(
|
form.setValue(
|
||||||
"hotel_services",
|
"hotel_services",
|
||||||
current.filter((_, i) => i !== idx),
|
current.filter((_, i) => i !== idx),
|
||||||
|
|||||||
Reference in New Issue
Block a user