Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 88aac8f5dc | |||
| 78e00094f5 | |||
| 8ac199103a | |||
| f21ce92bc3 | |||
| 826c802962 | |||
| daf0178330 | |||
| 7e39683aa2 | |||
| f60dbe14e6 | |||
| 71da0243be | |||
| 86d41f6c2f |
@@ -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