Initial open-source release

This commit is contained in:
Will Chen
2025-04-11 09:37:05 -07:00
commit 43f67e0739
208 changed files with 45476 additions and 0 deletions

53
src/lib/toast.ts Normal file
View File

@@ -0,0 +1,53 @@
import { toast } from "sonner";
/**
* Toast utility functions for consistent notifications across the app
*/
/**
* Show a success toast
* @param message The message to display
*/
export const showSuccess = (message: string) => {
toast.success(message);
};
/**
* Show an error toast
* @param message The error message to display
*/
export const showError = (message: any) => {
toast.error(message.toString());
console.error(message);
};
/**
* Show an info toast
* @param message The info message to display
*/
export const showInfo = (message: string) => {
toast.info(message);
};
/**
* Show a loading toast that can be updated with success/error
* @param loadingMessage The message to show while loading
* @param promise The promise to track
* @param successMessage Optional success message
* @param errorMessage Optional error message
*/
export const showLoading = <T>(
loadingMessage: string,
promise: Promise<T>,
successMessage?: string,
errorMessage?: string
) => {
return toast.promise(promise, {
loading: loadingMessage,
success: (data) => successMessage || "Operation completed successfully",
error: (err) => errorMessage || `Error: ${err.message || "Unknown error"}`,
});
};
// Re-export for direct use
export { toast };