[2.0.1] #56
@@ -147,7 +147,9 @@ export const createPackage = async (req, res) => {
|
||||
image,
|
||||
discountedPrice,
|
||||
inclusions,
|
||||
categoryId: Number(categoryId),
|
||||
category: {
|
||||
connect: { id: Number(categoryId) },
|
||||
},
|
||||
isActive: isActive ?? true,
|
||||
isFeatured: isFeatured ?? false,
|
||||
sortOrder: sortOrder ? Number(sortOrder) : 1000,
|
||||
@@ -184,15 +186,23 @@ export const updatePackage = async (req, res) => {
|
||||
try {
|
||||
const { id } = req.params;
|
||||
const data = { ...req.body };
|
||||
|
||||
delete data.id;
|
||||
delete data.category;
|
||||
delete data.createdAt;
|
||||
delete data.updatedAt;
|
||||
delete data.seoId;
|
||||
|
||||
if (data.categoryId) data.categoryId = Number(data.categoryId);
|
||||
if (data.categoryId) {
|
||||
data.category = { connect: { id: Number(data.categoryId) } };
|
||||
delete data.categoryId;
|
||||
}
|
||||
|
||||
if (data.sortOrder) data.sortOrder = Number(data.sortOrder);
|
||||
|
||||
const seoData = data.seo;
|
||||
delete data.seo;
|
||||
|
||||
const existingPackage = await prisma.healthPackage.findUnique({
|
||||
where: { id: Number(id) },
|
||||
select: { slug: true },
|
||||
@@ -205,29 +215,29 @@ export const updatePackage = async (req, res) => {
|
||||
data: {
|
||||
...data,
|
||||
|
||||
seo: data.seo
|
||||
seo: seoData
|
||||
? {
|
||||
upsert: {
|
||||
create: {
|
||||
seoTitle: data.seo.seoTitle,
|
||||
metaDescription: data.seo.metaDescription,
|
||||
focusKeyphrase: data.seo.focusKeyphrase,
|
||||
seoTitle: seoData.seoTitle,
|
||||
metaDescription: seoData.metaDescription,
|
||||
focusKeyphrase: seoData.focusKeyphrase,
|
||||
slug: seoSlug,
|
||||
tags: data.seo.tags || [],
|
||||
ogTitle: data.seo.ogTitle,
|
||||
ogDescription: data.seo.ogDescription,
|
||||
ogImage: data.seo.ogImage,
|
||||
tags: seoData.tags || [],
|
||||
ogTitle: seoData.ogTitle,
|
||||
ogDescription: seoData.ogDescription,
|
||||
ogImage: seoData.ogImage,
|
||||
},
|
||||
|
||||
update: {
|
||||
seoTitle: data.seo.seoTitle,
|
||||
metaDescription: data.seo.metaDescription,
|
||||
focusKeyphrase: data.seo.focusKeyphrase,
|
||||
seoTitle: seoData.seoTitle,
|
||||
metaDescription: seoData.metaDescription,
|
||||
focusKeyphrase: seoData.focusKeyphrase,
|
||||
slug: seoSlug,
|
||||
tags: data.seo.tags || [],
|
||||
ogTitle: data.seo.ogTitle,
|
||||
ogDescription: data.seo.ogDescription,
|
||||
ogImage: data.seo.ogImage,
|
||||
tags: seoData.tags || [],
|
||||
ogTitle: seoData.ogTitle,
|
||||
ogDescription: seoData.ogDescription,
|
||||
ogImage: seoData.ogImage,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user