stuff done

This commit is contained in:
2025-03-11 02:54:09 +02:00
parent 58e7ed2f06
commit 516b45fad9
90 changed files with 2950 additions and 9458 deletions

View File

@@ -3,6 +3,7 @@ import bcrypt from 'bcryptjs'
import {type ClassValue, clsx} from 'clsx'
import {getLocale} from 'next-intl/server'
import slugify from 'slugify'
import striptags from 'striptags'
import {twMerge} from 'tailwind-merge'
import {i18nDefaultLocale} from '@/i18n-config'
@@ -157,3 +158,40 @@ export const dbErrorHandling = (e: unknown, message?: string | null) => {
*/
export const isEmptyObj = (obj: object): boolean =>
Object.keys(obj).length === 0
/**
* To convert letter on typing from latin to cyr
* TODO: need to complete
*
* @param term
*/
export const replacerLat2Cyr = (term: string): string => {
const obj = {g: 'п', e: 'у', o: 'щ', f: 'а'}
return term
.split('')
.map((ch: PropertyKey): string => {
return obj.hasOwnProperty(ch as PropertyKey)
? (obj[ch as never] as string)
: (ch as string)
})
.join('')
}
type NormalizeConfigType =
| {
stripTags?: boolean
}
| undefined
| null
export function normalizeData(
data: string | null,
config?: NormalizeConfigType
): string {
if (config?.stripTags) {
data = striptags(data as string)
}
return data as string
}