Skip to content

Commit

Permalink
Add notion
Browse files Browse the repository at this point in the history
  • Loading branch information
pontusab committed Dec 3, 2023
1 parent af7d870 commit b9fdea5
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 3 deletions.
4 changes: 1 addition & 3 deletions apps/dashboard/src/actions/create-folder-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@ export const createFolderAction = action(createFolderSchema, async (value) => {
const supabase = createClient();
const user = await getUser();

const { error } = await createFolder(supabase, {
await createFolder(supabase, {
bucket: "vault",
path: `${user.data.team_id}/${value.path}`,
name: value.name,
});

console.log(error);

await revalidateTag(`vault_${user.data.team_id}`);

return error;
Expand Down
21 changes: 21 additions & 0 deletions apps/dashboard/src/app/[locale]/@login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { AppleSignIn } from "@/components/apple-sign-in";
import { FigmaSignIn } from "@/components/figma-sign-in";
import { GithubSignIn } from "@/components/github-sign-in";
import { GoogleSignIn } from "@/components/google-sign-in";
import { NotionSignIn } from "@/components/notion-sign-in";
import { SlackSignIn } from "@/components/slack-sign-in";
import { Cookies } from "@/utils/constants";
import {
Expand Down Expand Up @@ -34,6 +35,7 @@ export default async function Login() {
<SlackSignIn />
<GithubSignIn />
<FigmaSignIn />
<NotionSignIn />
</>
);
break;
Expand All @@ -46,6 +48,7 @@ export default async function Login() {
<AppleSignIn />
<GithubSignIn />
<FigmaSignIn />
<NotionSignIn />
</>
);
break;
Expand All @@ -58,6 +61,7 @@ export default async function Login() {
<AppleSignIn />
<SlackSignIn />
<FigmaSignIn />
<NotionSignIn />
</>
);
break;
Expand All @@ -70,6 +74,7 @@ export default async function Login() {
<AppleSignIn />
<GithubSignIn />
<SlackSignIn />
<NotionSignIn />
</>
);
break;
Expand All @@ -82,6 +87,20 @@ export default async function Login() {
<GithubSignIn />
<SlackSignIn />
<FigmaSignIn />
<NotionSignIn />
</>
);
break;

case "notion":
prefferedSignInOption = <NotionSignIn />;
moreSignInOptions = (
<>
<GoogleSignIn />
<AppleSignIn />
<GithubSignIn />
<SlackSignIn />
<FigmaSignIn />
</>
);
break;
Expand All @@ -94,6 +113,7 @@ export default async function Login() {
<SlackSignIn />
<GithubSignIn />
<FigmaSignIn />
<NotionSignIn />
</>
);
} else {
Expand All @@ -103,6 +123,7 @@ export default async function Login() {
<SlackSignIn />
<GithubSignIn />
<FigmaSignIn />
<NotionSignIn />
</>
);
}
Expand Down
39 changes: 39 additions & 0 deletions apps/dashboard/src/components/notion-sign-in.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"use client";

import { createClient } from "@midday/supabase/client";
import { Button } from "@midday/ui/button";
import { Icons } from "@midday/ui/icons";
import { useSearchParams } from "next/navigation";

export function NotionSignIn() {
const supabase = createClient();
const searchParams = useSearchParams();
const returnTo = searchParams.get("return_to");

const handleSignIn = async () => {
const redirectTo = new URL("/api/auth/callback", location.origin);

if (returnTo) {
redirectTo.searchParams.append("return_to", returnTo);
}

redirectTo.searchParams.append("provider", "notion");

await supabase.auth.signInWithOAuth({
provider: "notion",
options: {
redirectTo: redirectTo.toString(),
},
});
};

return (
<Button
onClick={handleSignIn}
className="active:scale-[0.98] rounded-xl bg-primary px-6 py-4 text-secondary font-medium flex space-x-2 h-[40px] w-full"
>
<Icons.Notion />
<span>Continue with Notion</span>
</Button>
);
}
15 changes: 15 additions & 0 deletions packages/ui/src/components/icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ export const Icons = {
viewBox="0 0 20 21"
fill="none"
xmlns="http://www.w3.org/2000/svg"
{...props}
>
<g clipPath="url(#clip0_1185_1063)">
<path
Expand All @@ -325,6 +326,20 @@ export const Icons = {
</defs>
</svg>
),
Notion: (props: any) => (
<svg
xmlns="http://www.w3.org/2000/svg"
width={20}
height={20}
fill="none"
{...props}
>
<path
fill="currentColor"
d="M3.778 3.571c.616.5.847.463 2.004.385l10.902-.654c.231 0 .039-.23-.038-.27l-1.811-1.308c-.347-.27-.81-.578-1.695-.5l-10.557.77c-.385.037-.462.23-.308.384l1.503 1.193Zm.655 2.541v11.471c0 .617.308.848 1.001.81l11.982-.694c.694-.038.77-.462.77-.963V5.342c0-.5-.191-.77-.616-.731l-12.521.73c-.462.04-.616.27-.616.771Zm11.828.616c.077.346 0 .693-.347.732l-.578.115v8.469c-.501.269-.963.423-1.348.423-.617 0-.771-.193-1.233-.77L8.978 9.77v5.736l1.195.27s0 .692-.964.692l-2.657.154c-.078-.154 0-.539.27-.616l.693-.192V8.23l-.963-.077c-.077-.346.115-.846.655-.885l2.85-.192 3.93 6.005V7.767l-1.001-.115c-.077-.424.23-.731.616-.77l2.659-.154ZM1.697.954l10.98-.809c1.35-.115 1.696-.038 2.543.578l3.506 2.463c.578.424.77.54.77 1.001V17.7c0 .847-.308 1.348-1.386 1.424l-12.752.77c-.81.039-1.195-.076-1.619-.616l-2.581-3.349c-.463-.616-.655-1.078-.655-1.617V2.3c0-.693.308-1.27 1.194-1.347Z"
/>
</svg>
),
Github: (props: any) => (
<svg
xmlns="http://www.w3.org/2000/svg"
Expand Down

0 comments on commit b9fdea5

Please sign in to comment.