Skip to content

Commit

Permalink
feat: add toast informing user about upload
Browse files Browse the repository at this point in the history
  • Loading branch information
trobonox committed Aug 14, 2023
1 parent 2dca0e7 commit cced960
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions src/routes/dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ import SpinnerRingResize from "~icons/svg-spinners/ring-resize";
import FullscreenLoader from "@/components/FullscreenLoader";
import { createFileImporter, makeFileUpload } from "@/utils/files";
import { setWorkspaces, workspaces } from "@/stores/workspaces";
import { WorkspaceContent } from "@/types/api";
import { UploadedFile, WorkspaceContent } from "@/types/api";
import { DropdownMenu } from "@kobalte/core";
import { createModal } from "@/primitives/modal";
import { createWorkspace } from "@/utils/workspaces";
import toast from "solid-toast";

export const [layoutLoading, setLayoutLoading] = createSignal(true);

Expand All @@ -37,11 +38,26 @@ export const fileUploadHandler = async (workspace_id: string | undefined, files:
if (!workspace_id) return;

try {
const uploaded = await makeFileUpload(files, {
workspace_id: workspace_id,
private: true,
});
let uploaded: UploadedFile[] | null = null;

await toast.promise(
makeFileUpload(files, {
workspace_id: workspace_id,
private: true,
}),
{
loading: "Uploading your file...",
success: (val) => {
uploaded = val;
console.log(val);
return <span>Upload successful!</span>;
},
error: <span>Theme could not be saved</span>
}
)
if (!uploaded) return;

// @ts-ignore
const new_content: WorkspaceContent[] = uploaded.map((file) => ({
type: "file",
data: file,
Expand Down

0 comments on commit cced960

Please sign in to comment.