[Update] Add save success notification.
This commit is contained in:
@@ -3,13 +3,11 @@ 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(),
|
||||
category_id: (options.category_id) ? options.category_id : null,
|
||||
message: message,
|
||||
options: options,
|
||||
});
|
||||
@@ -19,7 +17,7 @@ export const useNotificationStatus = () => {
|
||||
updateNotificationStatus({
|
||||
status: "error",
|
||||
is_open: true,
|
||||
key: generateRandomKey(),
|
||||
category_id: (options.category_id) ? options.category_id : null,
|
||||
message: message,
|
||||
options: options,
|
||||
});
|
||||
@@ -29,12 +27,23 @@ export const useNotificationStatus = () => {
|
||||
updateNotificationStatus({
|
||||
status: "success",
|
||||
is_open: true,
|
||||
key: generateRandomKey(),
|
||||
category_id: (options.category_id) ? options.category_id : null,
|
||||
message: message,
|
||||
options: options,
|
||||
});
|
||||
};
|
||||
|
||||
const showNotification_SaveSuccess = (options = {}) => {
|
||||
options = { hide_duration: 2000, to_hide_progress_bar: true, ...options };
|
||||
updateNotificationStatus({
|
||||
status: "success",
|
||||
is_open: true,
|
||||
category_id: (options.category_id) ? options.category_id : null,
|
||||
message: "設定の適用と、保存が完了しました。",
|
||||
options: options,
|
||||
});
|
||||
};
|
||||
|
||||
const closeNotification = () => {
|
||||
updateNotificationStatus((prev) => ({
|
||||
...prev.data,
|
||||
@@ -49,6 +58,7 @@ export const useNotificationStatus = () => {
|
||||
showNotification_Warning,
|
||||
showNotification_Error,
|
||||
showNotification_Success,
|
||||
showNotification_SaveSuccess,
|
||||
closeNotification,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user