grand commit
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
'use server'
|
||||
|
||||
import {Meta, ProductLocale, ProductToStore} from '@prisma/client'
|
||||
import sanitizeHtml from 'sanitize-html'
|
||||
import {Meta, ProductLocale} from '@prisma/client'
|
||||
import {z} from 'zod'
|
||||
|
||||
import {i18nLocalesCodes} from '@/i18n-config'
|
||||
@@ -9,12 +8,7 @@ import {STORE_ID} from '@/lib/config/constants'
|
||||
import {getProductBySlug} from '@/lib/data/models/product'
|
||||
import {db} from '@/lib/db/prisma/client'
|
||||
import {createProductFormSchema} from '@/lib/schemas/admin/product'
|
||||
import {
|
||||
cleanEmptyParams,
|
||||
dbErrorHandling,
|
||||
isEmptyObj,
|
||||
slug as slugger
|
||||
} from '@/lib/utils'
|
||||
import {cleanEmptyParams, dbErrorHandling, slug as slugger} from '@/lib/utils'
|
||||
|
||||
export const onProductCreateAction = async (
|
||||
formData: z.infer<typeof createProductFormSchema>
|
||||
@@ -42,7 +36,6 @@ export const onProductCreateAction = async (
|
||||
for (const i in validatedData.meta) {
|
||||
const normalizedMeta: any = cleanEmptyParams(validatedData.meta[i])
|
||||
|
||||
//if (!isEmptyObj(normalizedMeta)) {}
|
||||
meta.push(normalizedMeta)
|
||||
}
|
||||
|
||||
@@ -58,7 +51,6 @@ export const onProductCreateAction = async (
|
||||
if (!result) {
|
||||
const normalized: any = cleanEmptyParams({slug, ...locale})
|
||||
|
||||
//locales.push({...normalized, meta: {create: meta[i]}})
|
||||
locales.push(normalized)
|
||||
} else {
|
||||
return {error: `Продукт з такою назвою ${title} вже існує`}
|
||||
|
||||
@@ -15,3 +15,9 @@ export const getCategoryBySlug = async (data: {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export const getCategoryLocalesById = async (id: number) => {
|
||||
return db.categoryLocale.findMany({
|
||||
where: {categoryId: id}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user