add: more things

Signed-off-by: Kenneth Obsequio <k80308392@gmail.com>
This commit is contained in:
2026-07-06 15:21:36 +08:00
parent 41e98bb602
commit 244aa607f7
71 changed files with 2998 additions and 1014 deletions
@@ -34,7 +34,12 @@ export function NotificationBroadcastsProvider({ children }) {
return await fn();
} catch (err) {
const message = err?.response?.data?.message ?? "Something went wrong.";
toast.error(message);
toast(message, {
action: {
label: "Close",
onClick: () => {}
}
});
return null;
} finally {
setLoading(false);
@@ -100,7 +105,12 @@ export function NotificationBroadcastsProvider({ children }) {
const broadcast = res.data?.data?.data ?? null;
if (broadcast) {
setBroadcasts((prev) => [broadcast, ...prev]);
toast.success("Notification broadcast created.");
toast("Notification broadcast created.", {
action: {
label: "Close",
onClick: () => {}
}
});
}
return res.data;
}),
@@ -116,7 +126,12 @@ export function NotificationBroadcastsProvider({ children }) {
if (broadcast) {
setBroadcasts((prev) => prev.map((b) => (b.broadcast_id === broadcastId ? broadcast : b)));
setSelectedBroadcast(broadcast);
toast.success("Notification broadcast updated.");
toast("Notification broadcast updated.", {
action: {
label: "Close",
onClick: () => {}
}
});
}
return res.data;
}),
@@ -132,7 +147,12 @@ export function NotificationBroadcastsProvider({ children }) {
if (broadcast) {
setBroadcasts((prev) => prev.map((b) => (b.broadcast_id === broadcastId ? broadcast : b)));
setSelectedBroadcast(broadcast);
toast.success("Notification broadcast sent.");
toast("Notification broadcast sent.", {
action: {
label: "Close",
onClick: () => {}
}
});
}
return res.data;
}),
@@ -148,7 +168,12 @@ export function NotificationBroadcastsProvider({ children }) {
});
setBroadcasts((prev) => prev.filter((b) => b.broadcast_id !== broadcastId));
setSelectedBroadcast((prev) => (prev?.broadcast_id === broadcastId ? null : prev));
toast.success("Notification broadcast archived.");
toast("Notification broadcast archived.", {
action: {
label: "Close",
onClick: () => {}
}
});
return res.data;
}),
[request]
@@ -162,7 +187,12 @@ export function NotificationBroadcastsProvider({ children }) {
data: { ids, deletedBy },
});
setBroadcasts((prev) => prev.filter((b) => !ids.includes(b.broadcast_id)));
toast.success(`${ids.length} notification broadcast(s) archived.`);
toast(`${ids.length} notification broadcast(s) archived.`, {
action: {
label: "Close",
onClick: () => {}
}
});
return res.data;
}),
[request]
@@ -176,7 +206,12 @@ export function NotificationBroadcastsProvider({ children }) {
const broadcast = res.data?.data?.data ?? null;
if (broadcast) {
setBroadcasts((prev) => prev.filter((b) => b.broadcast_id !== broadcastId));
toast.success("Notification broadcast restored.");
toast("Notification broadcast restored.", {
action: {
label: "Close",
onClick: () => {}
}
});
}
return res.data;
}),
@@ -189,7 +224,12 @@ export function NotificationBroadcastsProvider({ children }) {
request(async () => {
const res = await api.patch("/admin/notification-broadcasts/bulk-restore", { ids });
setBroadcasts((prev) => prev.filter((b) => !ids.includes(b.broadcast_id)));
toast.success(`${ids.length} notification broadcast(s) restored.`);
toast(`${ids.length} notification broadcast(s) restored.`, {
action: {
label: "Close",
onClick: () => {}
}
});
return res.data;
}),
[request]
@@ -201,7 +241,12 @@ export function NotificationBroadcastsProvider({ children }) {
request(async () => {
const res = await api.delete(`/admin/notification-broadcasts/${broadcastId}/permanent`);
setBroadcasts((prev) => prev.filter((b) => b.broadcast_id !== broadcastId));
toast.success("Notification broadcast permanently deleted.");
toast("Notification broadcast permanently deleted.", {
action: {
label: "Close",
onClick: () => {}
}
});
return res.data;
}),
[request]
@@ -213,7 +258,12 @@ export function NotificationBroadcastsProvider({ children }) {
request(async () => {
const res = await api.delete("/admin/notification-broadcasts/bulk/permanent", { data: { ids } });
setBroadcasts((prev) => prev.filter((b) => !ids.includes(b.broadcast_id)));
toast.success(`${ids.length} notification broadcast(s) permanently deleted.`);
toast(`${ids.length} notification broadcast(s) permanently deleted.`, {
action: {
label: "Close",
onClick: () => {}
}
});
return res.data;
}),
[request]