add toast notification system with success, error, and info variants
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import { useAppStore } from "@/stores/app-store";
|
||||
import { useBoardStore } from "@/stores/board-store";
|
||||
import { useToastStore } from "@/stores/toast-store";
|
||||
import { saveBoard } from "@/lib/storage";
|
||||
import {
|
||||
exportBoardAsJson,
|
||||
@@ -31,6 +32,7 @@ function downloadBlob(content: string, filename: string, mimeType: string) {
|
||||
|
||||
export function ImportExportButtons() {
|
||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||
const addToast = useToastStore((s) => s.addToast);
|
||||
const board = useBoardStore((s) => s.board);
|
||||
const refreshBoards = useAppStore((s) => s.refreshBoards);
|
||||
const setView = useAppStore((s) => s.setView);
|
||||
@@ -42,6 +44,7 @@ export function ImportExportButtons() {
|
||||
const json = exportBoardAsJson(board);
|
||||
const safeName = board.title.replace(/[^a-zA-Z0-9-_]/g, "_");
|
||||
downloadBlob(json, `${safeName}.json`, "application/json");
|
||||
addToast("Board exported as JSON", "success");
|
||||
}
|
||||
|
||||
function handleExportCsv() {
|
||||
@@ -49,6 +52,7 @@ export function ImportExportButtons() {
|
||||
const csv = exportBoardAsCsv(board);
|
||||
const safeName = board.title.replace(/[^a-zA-Z0-9-_]/g, "_");
|
||||
downloadBlob(csv, `${safeName}.csv`, "text/csv");
|
||||
addToast("Board exported as CSV", "success");
|
||||
}
|
||||
|
||||
function handleImportClick() {
|
||||
@@ -77,9 +81,10 @@ export function ImportExportButtons() {
|
||||
await openBoard(imported.id);
|
||||
setView({ type: "board", boardId: imported.id });
|
||||
addRecentBoard(imported.id);
|
||||
addToast("Board imported successfully", "success");
|
||||
} catch (err) {
|
||||
console.error("Import failed:", err);
|
||||
// Could show a toast here in the future
|
||||
addToast("Import failed - check file format", "error");
|
||||
}
|
||||
|
||||
// Reset the input so the same file can be re-imported
|
||||
|
||||
Reference in New Issue
Block a user