Files
VRCT/src-ui/logics/common/useNotificationStatus.js
Sakamoto Shiina bcef981955 [Update] Change the notification UI.
(Change the base notification library from MUI to React-Toastify.)
2025-06-05 18:11:53 +09:00

54 lines
1.5 KiB
JavaScript

import { useStore_NotificationStatus } from "@store";
export const useNotificationStatus = () => {
const { currentNotificationStatus, updateNotificationStatus } = useStore_NotificationStatus();
const generateRandomKey = () => Math.random();
const showNotification_Warning = (message, options = {}) => {
updateNotificationStatus({
status: "warning",
is_open: true,
key: generateRandomKey(),
message: message,
options: options,
});
};
const showNotification_Error = (message, options = {}) => {
updateNotificationStatus({
status: "error",
is_open: true,
key: generateRandomKey(),
message: message,
options: options,
});
};
const showNotification_Success = (message, options = {}) => {
updateNotificationStatus({
status: "success",
is_open: true,
key: generateRandomKey(),
message: message,
options: options,
});
};
const closeNotification = () => {
updateNotificationStatus((prev) => ({
...prev.data,
is_open: false,
}));
};
return {
currentNotificationStatus,
updateNotificationStatus,
showNotification_Warning,
showNotification_Error,
showNotification_Success,
closeNotification,
};
};