Skip to content

Commit

Permalink
Folders
Browse files Browse the repository at this point in the history
  • Loading branch information
pontusab committed Dec 5, 2023
1 parent 291b729 commit 0a7a7bb
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 22 deletions.
1 change: 1 addition & 0 deletions .env-example
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
NEXT_PUBLIC_SUPABASE_URL=
NEXT_PUBLIC_SUPABASE_ANON_KEY=
NEXT_PUBLIC_SUPABASE_ID=
RESEND_API_KEY=
LOOPS_ENDPOINT=
GOCARDLESS_SECRET_ID=
Expand Down
8 changes: 4 additions & 4 deletions apps/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
"@midday/supabase": "workspace:*",
"@midday/ui": "workspace:*",
"@novu/headless": "^0.21.0",
"@trigger.dev/nextjs": "^2.2.10",
"@trigger.dev/nextjs": "^2.2.11",
"@vercel/edge-config": "^0.4.1",
"@vercel/toolbar": "^0.1.6",
"@zip.js/zip.js": "^2.7.31",
"@zip.js/zip.js": "^2.7.32",
"change-case": "^5.2.0",
"framer-motion": "^10.16.12",
"framer-motion": "^10.16.14",
"ms": "^2.1.3",
"next": "14.0.3",
"next-international": "^1.1.4",
Expand All @@ -47,7 +47,7 @@
"@midday/tsconfig": "workspace:*",
"@t3-oss/env-nextjs": "^0.7.1",
"@types/node": "^20.10.3",
"@types/react": "^18.2.41",
"@types/react": "^18.2.42",
"@types/react-dom": "^18.2.17",
"typescript": "^5.3.2"
}
Expand Down
9 changes: 5 additions & 4 deletions apps/dashboard/src/components/tables/vault/upload-zone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export function UploadZone({ children }) {
const createFolder = useAction(createFolderAction, {
onError: () => {
toast({
duration: 4000,
// position: "bottom-right",
duration: 2500,
variant: "error",
title:
"The folder already exists in the current directory. Please use a different name.",
});
Expand All @@ -64,14 +64,14 @@ export function UploadZone({ children }) {
setShowProgress(true);

const { data: userData } = await getCurrentUserTeamQuery(supabase);
console.log(`${userData?.team_id}/${folderPath}`);
const filePath = [userData?.team_id, ...folders].join("/");

try {
await Promise.all(
files.map(async (file, idx) => {
await resumableUpload(supabase, {
bucket: "vault",
path: `${userData?.team_id}/${folderPath}`,
path: filePath,
file,
onProgress: (bytesUploaded, bytesTotal) => {
uploadProgress.current[idx] = (bytesUploaded / bytesTotal) * 100;
Expand Down Expand Up @@ -103,6 +103,7 @@ export function UploadZone({ children }) {
} catch {
toast({
duration: 2500,
variant: "error",
title: "Something went wrong please try again.",
});
}
Expand Down
2 changes: 1 addition & 1 deletion apps/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"devDependencies": {
"@midday/tsconfig": "workspace:*",
"@types/node": "^20.10.3",
"@types/react": "^18.2.41",
"@types/react": "^18.2.42",
"@types/react-dom": "^18.2.17"
}
}
Binary file modified bun.lockb
Binary file not shown.
6 changes: 3 additions & 3 deletions packages/jobs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"check:types": "tsc --noEmit"
},
"dependencies": {
"@trigger.dev/react": "^2.2.10",
"@trigger.dev/sdk": "^2.2.10",
"@trigger.dev/supabase": "^2.2.10"
"@trigger.dev/react": "^2.2.11",
"@trigger.dev/sdk": "^2.2.11",
"@trigger.dev/supabase": "^2.2.11"
}
}

6 changes: 4 additions & 2 deletions packages/jobs/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ export const client = new TriggerClient({

export const supabase = new Supabase<Database>({
id: "supabase",
projectId: process.env.SUPABASE_ID!,
projectId: process.env.NEXT_PUBLIC_SUPABASE_ID!,
supabaseKey: process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
});

export const supabaseManagement = new SupabaseManagement({
id: "supabase-integration",
});

export const supabaseTriggers = supabaseManagement.db(process.env.SUPABASE_ID!);
export const supabaseTriggers = supabaseManagement.db(
process.env.NEXT_PUBLIC_SUPABASE_ID!
);
1 change: 1 addition & 0 deletions packages/supabase/src/queries/cached-queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ export const getVault = async (params) => {
},
["vault", teamId],
{
revalidate: 10,
tags: [`vault_${teamId}`],
}
)(params);
Expand Down
18 changes: 12 additions & 6 deletions packages/supabase/src/utils/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,31 @@ export async function upload(
throw result.error;
}

type ResumableUploadParmas = {
file: File;
path: string;
bucket: string;
onProgress?: (bytesUploaded: number, bytesTotal: number) => void;
};

export async function resumableUpload(
client: SupabaseClient,
{ file, path, bucket, onProgress }: UploadParams
{ file, path, bucket, onProgress }: ResumableUploadParmas
) {
const {
data: { session },
} = await client.auth.getSession();

const fullPath = `${path}/${file.name}`;

console.log(fullPath);

return new Promise((resolve, reject) => {
const upload = new tus.Upload(file, {
endpoint: `https://pytddvqiozwrhfbwqazp.supabase.co/storage/v1/upload/resumable`,
retryDelays: [0, 3000, 5000, 10000, 20000],
endpoint: `https://${process.env.NEXT_PUBLIC_SUPABASE_ID}.supabase.co/storage/v1/upload/resumable`,
retryDelays: [0, 3000, 5000, 10000],
headers: {
authorization: `Bearer ${session?.access_token}`,
"x-upsert": "true", // optionally set upsert to true to overwrite existing files
// optionally set upsert to true to overwrite existing files
"x-upsert": "true",
},
uploadDataDuringCreation: true,
// Important if you want to allow re-uploading the same file https://github.com/tus/tus-js-client/blob/main/docs/api.md#removefingerprintonsuccess
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@
"lucide-react": "^0.294.0",
"react-day-picker": "^8.9.1",
"react-icons": "^4.12.0",
"tailwind-merge": "2.0.0",
"tailwindcss": "^3.3.5",
"tailwind-merge": "2.1.0",
"tailwindcss": "^3.3.6",
"tailwindcss-animate": "^1.0.7"
}
}
2 changes: 2 additions & 0 deletions packages/ui/src/components/icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
MdDevices,
MdDriveFileMove,
MdDynamicForm,
MdErrorOutline,
MdExpandMore,
MdFastfood,
MdFence,
Expand Down Expand Up @@ -411,4 +412,5 @@ export const Icons = {
FileUpload: MdFileUpload,
Search: MdSearch,
CreateNewFolder: MdCreateNewFolder,
Error: MdErrorOutline,
};
1 change: 1 addition & 0 deletions packages/ui/src/components/toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const toastVariants = cva(
variants: {
variant: {
default: "border bg-secondary text-foreground",
error: "border bg-secondary text-foreground",
success: "border bg-secondary text-foreground",
progress: "border bg-secondary text-foreground",
destructive:
Expand Down
3 changes: 3 additions & 0 deletions packages/ui/src/components/toaster.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ export function Toaster() {
<div className="flex space-x-2 justify-between">
<div className="flex space-x-2 items-center">
{props?.variant === "success" && <Icons.Check />}
{props?.variant === "error" && (
<Icons.Error className="text-[#FF3638]" />
)}

{props?.variant === "progress" && (
<Loader2 className="h-4 w-4 animate-spin" />
Expand Down

0 comments on commit 0a7a7bb

Please sign in to comment.