Skip to content

Commit

Permalink
Merge pull request #24 from tnamdevnote/chore/revise-auth-flow
Browse files Browse the repository at this point in the history
Chore/Revise Auth Flow
  • Loading branch information
tnamdevnote authored May 10, 2024
2 parents d3b1454 + c7349b1 commit ce0d5f8
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 83 deletions.
36 changes: 0 additions & 36 deletions app/(auth)/sign-in/page.tsx

This file was deleted.

35 changes: 0 additions & 35 deletions app/(auth)/sign-up/page.tsx

This file was deleted.

28 changes: 22 additions & 6 deletions app/(main)/components/heroSection/heroSection.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import React from "react";
import Image from "next/image";
import { SplitContainer } from "@/components/templates/container";
import { RegisterLink } from "@kinde-oss/kinde-auth-nextjs/components";
import { barber } from "@/public/illustrations";
import React from "react";
import { SplitContainer } from "@/components/templates/container";
import { Button } from "@/components/atoms/button";
import { getKindeServerSession } from "@kinde-oss/kinde-auth-nextjs/server";
import Link from "next/link";

const HeroSection = () => {
async function HeroSection() {
const { isAuthenticated } = getKindeServerSession();
const isSignedIn = await isAuthenticated();

return (
<section aria-label="Hero">
<SplitContainer className="h-[80vh] py-12 md:flex-row-reverse md:justify-between md:py-44">
Expand All @@ -31,14 +36,25 @@ const HeroSection = () => {
className="w-full animate-fade-in"
style={{ "--index": 1 } as React.CSSProperties}
>
<Button size="lg" className="w-full md:w-auto" asChild>
<Link href={"/sign-in"}>Get started!</Link>
<Button size="md" className="w-full md:w-auto" asChild>
{isSignedIn ? (
<Link href="/my-appointments">Book your next appointment</Link>
) : (
<RegisterLink
authUrlParams={{
connection_id:
process.env.NEXT_PUBLIC_KINDE_CONNECTION_GOOGLE || "",
}}
>
Get started!
</RegisterLink>
)}
</Button>
</div>
</SplitContainer.Right>
</SplitContainer>
</section>
);
};
}

export default HeroSection;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Meta, StoryObj } from "@storybook/react";
import HeroSection from "./heroSection";
import HeroSection from "../app/(main)/components/heroSection/heroSection";

const meta: Meta<typeof HeroSection> = {
title: "Pages/Home/HeroSection",
Expand All @@ -11,9 +11,15 @@ const meta: Meta<typeof HeroSection> = {
},
layout: "fullscreen",
},
/** Disabling the test since current version of storybook does not support dynamic server components.
* This should be fixed in version 8.
*/
tags: ["no-tests"],
};

export default meta;
type Story = StoryObj<typeof HeroSection>;

export const Default: Story = {};
export const Default: Story = {
render: () => <HeroSection />,
};
6 changes: 5 additions & 1 deletion app/(main)/home.stories.tsx → archive/home.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Meta, StoryObj } from "@storybook/react";
import Home from "./page";
import Home from "../app/(main)/page";

const meta: Meta<typeof Home> = {
title: "Pages/Home",
Expand All @@ -11,6 +11,10 @@ const meta: Meta<typeof Home> = {
},
layout: "fullscreen",
},
/** Disabling the test since current version of storybook does not support dynamic server components.
* This should be fixed in version 8.
*/
tags: ["no-tests"],
};

export default meta;
Expand Down
13 changes: 10 additions & 3 deletions components/organisms/header/header.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";

import React, { useEffect, useState } from "react";
import { LogoutLink } from "@kinde-oss/kinde-auth-nextjs/components";
import { LoginLink, LogoutLink } from "@kinde-oss/kinde-auth-nextjs/components";
import { CalendarIcon, LogOutIcon } from "lucide-react";
import { Container } from "@/components/templates/container";
import { Button } from "@/components/atoms/button";
Expand Down Expand Up @@ -58,7 +58,6 @@ function Header({ photo, isAuthenticated }: HeaderProps) {
</Avatar>
</PopoverTrigger>
<PopoverContent

className="flex w-fit flex-col items-start p-2"
align="end"
>
Expand Down Expand Up @@ -86,7 +85,15 @@ function Header({ photo, isAuthenticated }: HeaderProps) {
</Popover>
) : (
<Button aria-label="Sign in" iconPosition="after" size="sm" asChild>
<Link href="/sign-in">Sign in</Link>
<LoginLink
authUrlParams={{
connection_id:
process.env.NEXT_PUBLIC_KINDE_CONNECTION_GOOGLE || "",
}}
postLoginRedirectURL={`${process.env.NEXT_PUBLIC_BASE_URL}/api/auth/success`}
>
{"Sign in"}
</LoginLink>
</Button>
)}
</nav>
Expand Down

0 comments on commit ce0d5f8

Please sign in to comment.