Skip to content

Commit

Permalink
Merge pull request #207 from Sahil-Connect/SAH-96
Browse files Browse the repository at this point in the history
[SAH-96]: Generate magic invitation link
  • Loading branch information
Emmanuel-Melon authored Sep 9, 2024
2 parents 46e98d3 + f5139f6 commit 9f884a3
Show file tree
Hide file tree
Showing 45 changed files with 6,030 additions and 971 deletions.
12 changes: 9 additions & 3 deletions apps/admin/src/Layout/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ import { Navbar } from "ui";
type LayoutProps = {
children: ReactNode;
};
import { HiOutlineUsers, HiOutlineQueueList, HiOutlineMap, HiOutlineIdentification, HiOutlineBuildingOffice2 } from "react-icons/hi2";
import {
HiOutlineUsers,
HiOutlineQueueList,
HiOutlineMap,
HiOutlineIdentification,
HiOutlineBuildingOffice2,
} from "react-icons/hi2";

const links = [
{
Expand All @@ -27,13 +33,13 @@ const links = [
{
name: "Orders",
href: "/orders",
icon: HiOutlineQueueList,
icon: HiOutlineQueueList,
},
{
name: "Clients",
href: "/clients",
icon: HiOutlineBuildingOffice2,
}
},
];

export default function Layout({ children, ...props }: LayoutProps) {
Expand Down
6 changes: 3 additions & 3 deletions apps/admin/src/pages/404.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { StatusPage } from 'ui';
import errorImg from '../../public/404.svg'
import { StatusPage } from "ui";
import errorImg from "../../public/404.svg";

export default function Custom404() {
return (
<StatusPage
<StatusPage
statusCode="Error 404"
message="Oops! Page not Found"
desc="Sorry, it seems the page you are trying to access has either been deleted or never existed."
Expand Down
6 changes: 3 additions & 3 deletions apps/admin/src/pages/500.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { StatusPage } from 'ui';
import errorImg from '../../public/500.svg'
import { StatusPage } from "ui";
import errorImg from "../../public/500.svg";

export default function Custom500() {
return (
<StatusPage
<StatusPage
statusCode="Error 500"
message="Oops! Server-side error"
desc="Sorry, it seems we have encountered an internal server error. Please try again later."
Expand Down
17 changes: 8 additions & 9 deletions apps/admin/src/pages/agents/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
export default function Agents() {
return (
<section className="space-y-2">
<div>
<h1>Agents Page</h1>
</div>
</section>
);
}

return (
<section className="space-y-2">
<div>
<h1>Agents Page</h1>
</div>
</section>
);
}
9 changes: 3 additions & 6 deletions apps/admin/src/pages/auth/signin.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { useEffect } from "react";
import type { NextPage } from "next";
import { getProviders, useSession } from "next-auth/react";
import { useRouter } from "next/router";
import { getProviders, useSession } from "next-auth/react";
import logo from "../../../public/logo-alt.svg";
import LoginForm from "@sahil/features/auth/forms/LoginForm";
import AuthCard from "@sahil/features/auth/AuthCard";

Expand All @@ -19,14 +20,10 @@ const SignInPage: NextPage = ({ providers }: any) => {
return (
<>
<AuthCard
logo={logo}
providers={providers}
form={<LoginForm />}
title="Sign in to your account"
sub={{
text: "Don't have an account?",
href: "/auth/signup",
cta: "Sign Up",
}}
/>
</>
);
Expand Down
40 changes: 40 additions & 0 deletions apps/admin/src/pages/auth/verify.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { useEffect, useState } from "react";
import { useRouter } from "next/router";
import { signIn, useSession } from "next-auth/react";

const VerifyPage = () => {
const router = useRouter();
const { status } = useSession();
const { token } = router.query;
const [error, setError] = useState<string | null>(null);

useEffect(() => {
if (token && status === "unauthenticated") {
signIn("email", { token, redirect: false }).then((result) => {
if (result?.error) {
console.error("Verification failed:", result.error);
setError(result.error);
// Handle error (e.g., show error message to user)
} else {
// Successful verification, redirect to appropriate page
router.push(result?.url!);
}
});
} else if (status === "authenticated") {
// User is already signed in, redirect to appropriate page
router.push("/");
}
}, [token, status, router]);

if (status === "loading") {
return <div>Loading...</div>;
}

if (error) {
return <div>Error: {error}</div>;
}

return <div>Verifying your email...</div>;
};

export default VerifyPage;
17 changes: 8 additions & 9 deletions apps/admin/src/pages/clients/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
export default function Clients() {
return (
<section className="space-y-2">
<div>
<h1>Clients Page</h1>
</div>
</section>
);
}

return (
<section className="space-y-2">
<div>
<h1>Clients Page</h1>
</div>
</section>
);
}
17 changes: 8 additions & 9 deletions apps/admin/src/pages/orders/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
export default function Orders() {
return (
<section className="space-y-2">
<div>
<h1>Orders Page</h1>
</div>
</section>
);
}

return (
<section className="space-y-2">
<div>
<h1>Orders Page</h1>
</div>
</section>
);
}
2 changes: 1 addition & 1 deletion apps/admin/src/pages/users/new.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export default function CreateUserPage() {
return (
<section className="space-y-2">
<div className="mx-auto max-w-96">
<CreateUser />
<CreateUser />
</div>
</section>
);
Expand Down
6 changes: 3 additions & 3 deletions apps/agent/src/pages/404.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { StatusPage } from 'ui';
import errorImg from '../../public/404.svg'
import { StatusPage } from "ui";
import errorImg from "../../public/404.svg";

export default function Custom404() {
return (
<StatusPage
<StatusPage
statusCode="Error 404"
message="Oops! Page not Found"
desc="Sorry, it seems the page you are trying to access has either been deleted or never existed."
Expand Down
6 changes: 3 additions & 3 deletions apps/agent/src/pages/500.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { StatusPage } from 'ui';
import errorImg from '../../public/500.svg'
import { StatusPage } from "ui";
import errorImg from "../../public/500.svg";

export default function Custom500() {
return (
<StatusPage
<StatusPage
statusCode="Error 500"
message="Oops! Server-side error"
desc="Sorry, it seems we have encountered an internal server error. Please try again later."
Expand Down
5 changes: 0 additions & 5 deletions apps/agent/src/pages/auth/signin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ const SignInPage: NextPage = ({ providers }: any) => {
logo={logo}
form={<LoginForm />}
title="Sign in to your account"
sub={{
text: "Don't have an account?",
href: "/auth/signup",
cta: "Sign Up",
}}
/>
</>
);
Expand Down
31 changes: 0 additions & 31 deletions apps/agent/src/pages/auth/signup.tsx

This file was deleted.

6 changes: 3 additions & 3 deletions apps/client/src/pages/404.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { StatusPage } from 'ui';
import errorImg from '../../public/404.svg'
import { StatusPage } from "ui";
import errorImg from "../../public/404.svg";

export default function Custom404() {
return (
<StatusPage
<StatusPage
statusCode="Error 404"
message="Oops! Page not Found"
desc="Sorry, it seems the page you are trying to access has either been deleted or never existed."
Expand Down
6 changes: 3 additions & 3 deletions apps/client/src/pages/500.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { StatusPage } from 'ui';
import errorImg from '../../public/500.svg'
import { StatusPage } from "ui";
import errorImg from "../../public/500.svg";

export default function Custom500() {
return (
<StatusPage
<StatusPage
statusCode="Error 500"
message="Oops! Server-side error"
desc="Sorry, it seems we have encountered an internal server error. Please try again later."
Expand Down
5 changes: 0 additions & 5 deletions apps/client/src/pages/auth/signin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ const SignInPage: NextPage = ({ providers }: any) => {
providers={providers}
form={<LoginForm />}
title="Sign in to your account"
sub={{
text: "Don't have an account?",
href: "/auth/signup",
cta: "Sign Up",
}}
/>
</>
);
Expand Down
6 changes: 3 additions & 3 deletions apps/courier/src/pages/404.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { StatusPage } from 'ui';
import errorImg from '../../public/404.svg'
import { StatusPage } from "ui";
import errorImg from "../../public/404.svg";

export default function Custom404() {
return (
<StatusPage
<StatusPage
statusCode="Error 404"
message="Oops! Page not Found"
desc="Sorry, it seems the page you are trying to access has either been deleted or never existed."
Expand Down
6 changes: 3 additions & 3 deletions apps/courier/src/pages/500.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { StatusPage } from 'ui';
import errorImg from '../../public/500.svg'
import { StatusPage } from "ui";
import errorImg from "../../public/500.svg";

export default function Custom500() {
return (
<StatusPage
<StatusPage
statusCode="Error 500"
message="Oops! Server-side error"
desc="Sorry, it seems we have encountered an internal server error. Please try again later."
Expand Down
5 changes: 0 additions & 5 deletions apps/courier/src/pages/auth/signin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ const SignInPage: NextPage = ({ providers }: any) => {
providers={providers}
form={<LoginForm />}
title="Sign in to your account"
sub={{
text: "Don't have an account?",
href: "/auth/signup",
cta: "Sign Up",
}}
/>
</>
);
Expand Down
1 change: 1 addition & 0 deletions packages/configs/env/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./url";
16 changes: 16 additions & 0 deletions packages/configs/env/url.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const { ADMIN_URL, AGENT_URL, CLIENT_URL, COURIER_URL, SERVER_URL } =
process.env;
if (!ADMIN_URL || !AGENT_URL || !CLIENT_URL || !COURIER_URL || !SERVER_URL) {
throw new Error("Missing required environment variables for Apps url");
}

export const URLS = {
development: SERVER_URL,
staging: {},
production: {
admin: ADMIN_URL!,
agent: AGENT_URL!,
client: CLIENT_URL!,
courier: COURIER_URL!,
},
};
Loading

0 comments on commit 9f884a3

Please sign in to comment.