Added a logging helper
This commit is contained in:
parent
39ba151fd7
commit
279e50019c
1 changed files with 26 additions and 2 deletions
|
@ -1,6 +1,6 @@
|
||||||
import { json2csv } from "csv42";
|
import { json2csv } from "csv42";
|
||||||
|
|
||||||
export function jsonToCsv(jsonObject: Array<object>, fileName: string) {
|
export const jsonToCsv = (jsonObject: Array<object>, fileName: string) => {
|
||||||
const csv = json2csv(jsonObject);
|
const csv = json2csv(jsonObject);
|
||||||
const blob = new Blob([csv], { type: "text/csv;charset=utf-8;" });
|
const blob = new Blob([csv], { type: "text/csv;charset=utf-8;" });
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ export function jsonToCsv(jsonObject: Array<object>, fileName: string) {
|
||||||
document.body.appendChild(link);
|
document.body.appendChild(link);
|
||||||
link.click();
|
link.click();
|
||||||
document.body.removeChild(link);
|
document.body.removeChild(link);
|
||||||
}
|
};
|
||||||
|
|
||||||
export function isAdmin(meta: UserPublicMetadata | undefined) {
|
export function isAdmin(meta: UserPublicMetadata | undefined) {
|
||||||
return (meta?.isAdmin as boolean | undefined) || false;
|
return (meta?.isAdmin as boolean | undefined) || false;
|
||||||
|
@ -21,3 +21,27 @@ export function isAdmin(meta: UserPublicMetadata | undefined) {
|
||||||
export function isVIP(meta: UserPublicMetadata | undefined) {
|
export function isVIP(meta: UserPublicMetadata | undefined) {
|
||||||
return (meta?.isVIP as boolean | undefined) || false;
|
return (meta?.isVIP as boolean | undefined) || false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const writeToLogs = (
|
||||||
|
level: "warn" | "info" | "error" | "success",
|
||||||
|
message: string
|
||||||
|
) => {
|
||||||
|
switch (level) {
|
||||||
|
case "info":
|
||||||
|
console.log(`[ℹ️ INFO]: ${message}`);
|
||||||
|
break;
|
||||||
|
case "warn":
|
||||||
|
console.log(`[⚠️ WARN]: ${message}`);
|
||||||
|
break;
|
||||||
|
case "error":
|
||||||
|
console.log(`[❌ ERROR]: ${message}`);
|
||||||
|
break;
|
||||||
|
case "success":
|
||||||
|
console.log(`[✅ SUCCESS]: ${message}`);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
console.log(`[ℹ️ INFO]: ${message}`);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue