mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-05-03 23:13:55 +01:00
26 lines
904 B
TypeScript
26 lines
904 B
TypeScript
import * as _ from "underscore";
|
|
import { ConsoleDataType } from "../Explorer/Menus/NotificationConsole/ConsoleData";
|
|
import { useNotificationConsole } from "../hooks/useNotificationConsole";
|
|
|
|
function log(type: ConsoleDataType, message: string): () => void {
|
|
const id = _.uniqueId();
|
|
const date = new Intl.DateTimeFormat("en-EN", {
|
|
hour12: true,
|
|
hour: "numeric",
|
|
minute: "numeric",
|
|
}).format(new Date());
|
|
|
|
useNotificationConsole.getState().setNotificationConsoleData({ type, date, message, id });
|
|
return () => useNotificationConsole.getState().setInProgressConsoleDataIdToBeDeleted(id);
|
|
}
|
|
|
|
export const logConsoleProgress = (msg: string): (() => void) => log(ConsoleDataType.InProgress, msg);
|
|
|
|
export const logConsoleError = (msg: string): void => {
|
|
log(ConsoleDataType.Error, msg);
|
|
};
|
|
|
|
export const logConsoleInfo = (msg: string): void => {
|
|
log(ConsoleDataType.Info, msg);
|
|
};
|