[Update] Config Page: Add notification ui. show error messages.

This commit is contained in:
Sakamoto Shiina
2024-12-08 17:02:19 +09:00
parent c65bb4578c
commit e7b8dac36d
8 changed files with 117 additions and 1 deletions

View File

@@ -5,6 +5,7 @@ export { useWindow } from "./useWindow";
export { useIsOpenedConfigPage } from "./useIsOpenedConfigPage";
export { useIsSoftwareUpdateAvailable } from "./useIsSoftwareUpdateAvailable";
export { useIsSoftwareUpdating } from "./useIsSoftwareUpdating";
export { useNotificationStatus } from "./useNotificationStatus";
export { useOpenFolder } from "./useOpenFolder";
export { useMessage } from "./useMessage";
export { useUpdateSoftware } from "./useUpdateSoftware";

View File

@@ -0,0 +1,42 @@
import { useStore_NotificationStatus } from "@store";
export const useNotificationStatus = () => {
const { currentNotificationStatus, updateNotificationStatus } = useStore_NotificationStatus();
const generateRandomKey = () => Math.random();
const showNotification_Error = (message) => {
updateNotificationStatus({
status: "error",
is_open: true,
key: generateRandomKey(),
message: message,
});
};
const showNotification_Success = (message) => {
updateNotificationStatus({
status: "success",
is_open: true,
key: generateRandomKey(),
message: message,
});
};
const closeNotification = (event, reason) => {
if (reason === "clickaway") return;
updateNotificationStatus((prev) => ({
...prev.data,
is_open: false,
}));
};
return {
currentNotificationStatus,
updateNotificationStatus,
showNotification_Error,
showNotification_Success,
closeNotification,
};
};