63 lines
1.7 KiB
TypeScript
63 lines
1.7 KiB
TypeScript
import { prisma } from "./db";
|
|
|
|
export const DEFAULT_COLOR_PRIMARIO = "#0400C4";
|
|
export const DEFAULT_COLOR_SECUNDARIO = "#0F172A";
|
|
|
|
export async function getConfigBranding() {
|
|
try {
|
|
const configs = await prisma.configuracion.findMany({
|
|
where: { clave: { in: ["color_primario", "color_secundario", "logo_base64"] } },
|
|
});
|
|
const map: Record<string, string> = {};
|
|
for (const c of configs) map[c.clave] = c.valor;
|
|
return {
|
|
colorPrimario: map.color_primario || DEFAULT_COLOR_PRIMARIO,
|
|
colorSecundario: map.color_secundario || DEFAULT_COLOR_SECUNDARIO,
|
|
logoBase64: map.logo_base64
|
|
? map.logo_base64.includes(":")
|
|
? map.logo_base64.split(":").slice(1).join(":")
|
|
: map.logo_base64
|
|
: undefined,
|
|
logoMime: map.logo_base64
|
|
? map.logo_base64.includes(":")
|
|
? map.logo_base64.split(":")[0]
|
|
: "image/png"
|
|
: undefined,
|
|
};
|
|
} catch {
|
|
return {
|
|
colorPrimario: DEFAULT_COLOR_PRIMARIO,
|
|
colorSecundario: DEFAULT_COLOR_SECUNDARIO,
|
|
};
|
|
}
|
|
}
|
|
|
|
export async function getConfigBancaria() {
|
|
try {
|
|
const configs = await prisma.configuracion.findMany({
|
|
where: {
|
|
clave: {
|
|
in: [
|
|
"razon_social",
|
|
"rfc",
|
|
"domicilio_fiscal",
|
|
"cuenta_nacional",
|
|
"clabe_interbancaria",
|
|
"cuenta_internacional",
|
|
"cuenta_internacional_swift",
|
|
"hora_centinela",
|
|
"terminos_condiciones",
|
|
"no_incluye",
|
|
"notas_adicionales",
|
|
],
|
|
},
|
|
},
|
|
});
|
|
const map: Record<string, string> = {};
|
|
for (const c of configs) map[c.clave] = c.valor;
|
|
return map;
|
|
} catch {
|
|
return {};
|
|
}
|
|
}
|