grand commit

This commit is contained in:
2025-02-07 08:34:42 +02:00
parent f594f001f6
commit c6c34f0453
53 changed files with 1283 additions and 625 deletions

View File

@@ -1,9 +1,12 @@
import {Prisma} from '@prisma/client'
import bcrypt from 'bcryptjs'
import {type ClassValue, clsx} from 'clsx'
import {getLocale} from 'next-intl/server'
import slugify from 'slugify'
import {twMerge} from 'tailwind-merge'
import {i18nDefaultLocale} from '@/i18n-config'
/**
* Just output dump using pretty output
*
@@ -16,6 +19,8 @@ export function dump(variable: any): [string, string] {
]
}
export const toPrice = (price: any) => parseFloat(price).toFixed(2)
/**
* Create fallback avatar for showing during login process or in case if empty
*
@@ -118,6 +123,16 @@ export const toEmptyParams = (data: object | object[]) => {
return result
}
export const thisLocales = async (locales: any) => {
const loc = await getLocale()
return locales.filter((locale: any) => locale.lang === loc)
}
export const thisLocale = async (locales: any) => {
const loc = await getLocale()
return locales.find((locale: any) => locale.lang === loc)
}
export const dbErrorHandling = (e: unknown, message?: string | null) => {
if (e instanceof Prisma.PrismaClientKnownRequestError) {
return {error: `${e.code}: ${e.message}`}