Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated api data to accroding to new schema #106

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/app/(vendor onboarding)/decorator/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -269,15 +269,15 @@ const Decorators: React.FC = () => {
formData.append(`cancellationPolicy`, file);
});
} else {
formData.append("cancellation_policy", formState.cancellationPolicy);
formData.append("cancellationPolicy", formState.cancellationPolicy);
}

if (Array.isArray(formState.termsAndConditions)) {
formState.termsAndConditions.forEach((file, index) => {
formData.append(`termsAndConditions`, file);
});
} else {
formData.append("terms_and_conditions", formState.termsAndConditions);
formData.append("termsAndConditions", formState.termsAndConditions);
}

// Additional fields
Expand Down
121 changes: 68 additions & 53 deletions src/app/(vendor onboarding)/pav/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,97 +129,112 @@ const Page = () => {
console.error("No token found!");
return;
}

const formData = new FormData();

formData.append("venId", venId);
// page 1
formData.append("name", name);
formData.append("description", description);
formData.append("events", JSON.stringify(events));
formData.append("eventsize", JSON.stringify(eventsize));
formData.append("eventTypes", JSON.stringify(events));
formData.append("eventSize", eventsize);

// page 2
formData.append("Photosstyles", JSON.stringify(Photosstyles));
formData.append("Photosequipments", JSON.stringify(Photosequipments));
formData.append("PhotosAddones", JSON.stringify(PhotosAddons));
// page 2: Photography and Videography details
formData.append(
"Photography.equipmentAvailable",
JSON.stringify(Photosequipments),
);
formData.append("Photography.typesofstyles", JSON.stringify(Photosstyles));
formData.append(
"Photography.addonsOrUpgradeAvailable",
JSON.stringify(PhotosAddons),
);
formData.append(
"Photosfinaldeliverymethods",
"Photography.finalDeliveryMethods",
JSON.stringify(Photosfinaldeliverymethods),
);

// page 3
formData.append("Videosstyles", JSON.stringify(Videosstyles));
formData.append("Videosequipments", JSON.stringify(Videosequipments));
formData.append("VideoAddones", JSON.stringify(VideoAddons));
formData.append(
"Videofinaldeliverymethods",
"Videography.equipmentAvailable",
JSON.stringify(Videosequipments),
);
formData.append("Videography.typesofstyles", JSON.stringify(Videosstyles));
formData.append(
"Videography.addonsOrUpgradeAvailable",
JSON.stringify(VideoAddons),
);
formData.append(
"Videography.finalDeliveryMethods",
JSON.stringify(Videofinaldeliverymethods),
);

// page 4
formData.append("Durationoffinaldelivery", Durationoffinaldelivery);
formData.append("Packagetype", Packagetype);
// page 3
formData.append("duration", Durationoffinaldelivery);
formData.append("PackageTypes", Packagetype);
formData.append(
"availablefordestinationevents",
"availableForOutofTownbooking",
JSON.stringify(availablefordestinationevents),
);
formData.append(
"postproductionservices",
JSON.stringify(postproductionservices),
);

formData.append(
"freeInitialConsultation",
JSON.stringify(freeInitialConsultation),
);
formData.append("advanceSetup", JSON.stringify(advanceSetup));
formData.append("setupsInstallations", JSON.stringify(setupsInstallations));
formData.append("bookingDeposit", JSON.stringify(bookingDeposit));

// page 5
formData.append(
"termsandconditions",
termsandconditions instanceof File
? termsandconditions
: JSON.stringify(termsandconditions),
);
formData.append(
"policy",
policy instanceof File ? policy : JSON.stringify(policy),
);
formData.append("websiteurl", websiteurl);
formData.append("intstagramurl", intstagramurl);
formData.append("Recongnition_awards", Recongnition_awards);
formData.append("advbookingperiod", advbookingperiod);
formData.append("Advancesetup", JSON.stringify(advanceSetup));
formData.append("bookingDepositRequired", JSON.stringify(bookingDeposit));
formData.append("designProposals", JSON.stringify(proposalsToClients));
// page 4
formData.append("website", websiteurl);
formData.append("instagram", intstagramurl);
formData.append("awards", Recongnition_awards);
formData.append("advanceBookingPeriod", advbookingperiod);
formData.append("clientTestimonials", clientTestimonials);
formData.append(
"writtenthemeproposalafterconsultaion",
"WrittenthemeProposelsafterconsultaion",
JSON.stringify(writtenthemeproposalafterconsultaion),
);
formData.append(
"freerevisionforinitialthemeproposal",
"initialthemeProposels",
JSON.stringify(freerevisionforinitialthemeproposal),
);

// page 6
if (photos instanceof File) {
formData.append("photos", photos);
} else if (Array.isArray(photos)) {
photos.forEach((photo, index) =>
formData.append(`photos[${index}]`, photo),
);
// page 5

if (Array.isArray(policy)) {
policy.forEach((file, index) => {
formData.append(`cancellationPolicy`, file);
});
} else {
formData.append("photos", JSON.stringify(photos));
formData.append("cancellationPolicy", policy);
}

if (videos instanceof File) {
formData.append("videos", videos);
} else if (Array.isArray(videos)) {
videos.forEach((video, index) =>
formData.append(`videos[${index}]`, video),
);
if (Array.isArray(termsandconditions)) {
termsandconditions.forEach((file, index) => {
formData.append(`termsAndConditions`, file);
});
} else {
formData.append("termsAndConditions", termsandconditions);
}

// page 4: Photos and Videos
if (Array.isArray(photos)) {
photos.forEach((file) => {
formData.append("photos", file); // No index here
});
} else {
formData.append("videos", JSON.stringify(videos));
formData.append("photos", photos);
}
if (Array.isArray(videos)) {
videos.forEach((file) => {
if (file instanceof File) {
formData.append("videos", file); // Append as 'videos' without the array index
}
});
} else if (typeof videos === "string") {
formData.append("videos", videos); // Append the string (URL)
}

try {
Expand Down