Skip to content

Commit

Permalink
Landing
Browse files Browse the repository at this point in the history
  • Loading branch information
pontusab committed Dec 4, 2023
1 parent b9fdea5 commit c88b094
Show file tree
Hide file tree
Showing 18 changed files with 320 additions and 293 deletions.
2 changes: 1 addition & 1 deletion apps/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"devDependencies": {
"@midday/tsconfig": "workspace:*",
"@t3-oss/env-nextjs": "^0.7.1",
"@types/node": "^20.10.2",
"@types/node": "^20.10.3",
"@types/react": "^18.2.41",
"@types/react-dom": "^18.2.17",
"typescript": "^5.3.2"
Expand Down
1 change: 0 additions & 1 deletion apps/dashboard/src/app/[locale]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Provider } from "./provider";
export default async function Layout({
dashboard,
login,

params: { locale },
}: {
dashboard: React.ReactNode;
Expand Down
6 changes: 6 additions & 0 deletions apps/dashboard/src/app/api/auth/callback/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export async function GET(req: NextRequest) {
const code = requestUrl.searchParams.get("code");
const returnTo = requestUrl.searchParams.get("return_to");
const provider = requestUrl.searchParams.get("provider");
const onboardingVisited = cookieStore.get(Cookies.OnboardingVisited)?.value;

if (provider) {
cookieStore.set(Cookies.PrefferedSignInProvider, provider);
Expand All @@ -23,6 +24,11 @@ export async function GET(req: NextRequest) {
await supabase.auth.exchangeCodeForSession(code);
}

if (!onboardingVisited) {
cookieStore.set(Cookies.OnboardingVisited, "true");
return NextResponse.redirect(`${requestUrl.origin}/onboarding`);
}

if (returnTo) {
return NextResponse.redirect(`${requestUrl.origin}/${returnTo}`);
}
Expand Down
41 changes: 28 additions & 13 deletions apps/dashboard/src/app/api/download/zip/route.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
import { getUser } from "@midday/supabase/cached-queries";
import { getVaultRecursiveQuery } from "@midday/supabase/queries";
import { createClient } from "@midday/supabase/server";
import { download } from "@midday/supabase/storage";
import { BlobReader, BlobWriter, ZipWriter } from "@zip.js/zip.js";

export const preferredRegion = "fra1";
export const runtime = "edge";
export const dynamic = "force-dynamic";

export async function GET(req, res) {
const promises = [];
const supabase = createClient();
const requestUrl = new URL(req.url);
const supabase = createClient();
const user = await getUser();
const path = requestUrl.searchParams.get("path");
const filename = requestUrl.searchParams.get("filename");

const promises: any = [];

const files = await getVaultRecursiveQuery(supabase, {
teamId: user.data.team_id,
path,
});

files.forEach((file) => {
promises.push(
supabaseClient.storage.from(bucket).download(`${folder}/${file.name}`)
download(supabase, {
bucket: "vault",
path: `${file.basePath}/${file.name}`,
})
);
});

Expand All @@ -32,20 +46,21 @@ export async function GET(req, res) {
});

downloadedFiles.forEach((downloadedFile) => {
if (downloadedFile) {
if (downloadedFile?.blob) {
zipWriter.add(downloadedFile.name, new BlobReader(downloadedFile.blob));
}
});

// const { data } = await supabase.storage.from("vault").download(path);
// const responseHeaders = new Headers(res.headers);
const responseHeaders = new Headers(res.headers);

responseHeaders.set(
"Content-Disposition",
`attachment; filename="${filename}.zip"`
);

// responseHeaders.set(
// "Content-Disposition",
// `attachment; filename="${filename}"`
// );
const data = await zipWriter.close();

// return new Response(data, {
// headers: responseHeaders,
// });
return new Response(data, {
headers: responseHeaders,
});
}
10 changes: 8 additions & 2 deletions apps/dashboard/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,15 @@ export const metadata: Metadata = {
],
};

export default function Layout({ children }: { children: ReactElement }) {
export default function Layout({
children,
params,
}: {
children: ReactElement;
params: { locale: string };
}) {
return (
<html lang="en" suppressHydrationWarning>
<html lang={params.locale} suppressHydrationWarning>
<body className={cn(fontSans.variable, "whitespace-pre-line")}>
<ThemeProvider
attribute="class"
Expand Down
7 changes: 3 additions & 4 deletions apps/dashboard/src/components/charts/chart-period.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"use client";

import { DateRangePicker } from "@midday/ui/date-range-picker";
import { Icons } from "@midday/ui/icons";
import {
Select,
SelectContent,
Expand All @@ -21,12 +20,12 @@ export function ChartPeriod({ initialValue, defaultValue, disabled }) {
to: parseAsString.withDefault(initialValue?.to ?? undefined),
from: parseAsString.withDefault(initialValue?.from ?? undefined),
period: parseAsString.withDefault(
initialValue?.period ?? defaultValue.period,
initialValue?.period ?? defaultValue.period
),
},
{
shallow: false,
},
}
);

if (state?.from) {
Expand All @@ -40,7 +39,7 @@ export function ChartPeriod({ initialValue, defaultValue, disabled }) {
} else {
placeholder = `${placeholder} -${format(
new Date(defaultValue.to),
"LLL dd, y",
"LLL dd, y"
)} `;
}

Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/src/components/charts/chart-type.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function ChartType({ initialValue, disabled }) {
initialValue,
(_, newState) => {
return newState;
},
}
);

return (
Expand Down
7 changes: 2 additions & 5 deletions apps/dashboard/src/components/tables/vault/data-table-row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,8 @@ import {
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuGroup,
DropdownMenuItem,
DropdownMenuPortal,
DropdownMenuSeparator,
DropdownMenuShortcut,
DropdownMenuSub,
DropdownMenuSubContent,
DropdownMenuSubTrigger,
Expand Down Expand Up @@ -209,7 +206,7 @@ export function DataTableRow({ data, addOptimisticData }) {
<DropdownMenuItem>
{data.isFolder ? (
<a
href={`/api/download/zip?path=${folderPath}&filename=${data.name}`}
href={`/api/download/zip?path=${filepath}&filename=${data.name}`}
download
className="truncate"
>
Expand Down Expand Up @@ -292,7 +289,7 @@ export function DataTableRow({ data, addOptimisticData }) {
<ContextMenuItem>
{data.isFolder ? (
<a
href={`/api/download/zip?path=${folderPath}&filename=${data.name}`}
href={`/api/download/zip?path=${filepath}&filename=${data.name}`}
download
className="truncate"
>
Expand Down
1 change: 0 additions & 1 deletion apps/dashboard/src/locales/client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"use client";

import { createT } from "next-international";
import { createI18nClient } from "next-international/client";

export const languages = ["en", "sv"];
Expand Down
1 change: 1 addition & 0 deletions apps/dashboard/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ export const Cookies = {
SpendingPeriod: "spending-period",
ChartType: "chart-type",
TransactionsPeriod: "transactions-period",
OnboardingVisited: "onboarding-visited",
};
2 changes: 1 addition & 1 deletion apps/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"devDependencies": {
"@midday/tsconfig": "workspace:*",
"@types/node": "^20.10.2",
"@types/node": "^20.10.3",
"@types/react": "^18.2.41",
"@types/react-dom": "^18.2.17"
}
Expand Down
10 changes: 8 additions & 2 deletions apps/website/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,15 @@ export const metadata: Metadata = {
],
};

export default function Layout({ children }: { children: ReactElement }) {
export default function Layout({
children,
params,
}: {
children: ReactElement;
params: { locale: string };
}) {
return (
<html lang="en" suppressHydrationWarning>
<html lang={params.locale} suppressHydrationWarning>
<body className={cn(fontSans.variable, "whitespace-pre-line")}>
<ThemeProvider
attribute="class"
Expand Down
Loading

0 comments on commit c88b094

Please sign in to comment.