Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: RBAC #55

Merged
merged 3 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"build": "next build",
"start": "next start",
"lint": "next lint",
"postinstall": "prisma generate && prisma migrate deploy"
"postinstall": "prisma generate"
},
"prisma": {},
"dependencies": {
Expand Down Expand Up @@ -38,6 +38,7 @@
"@studio-freight/react-lenis": "^0.0.47",
"@tabler/icons-react": "^3.2.0",
"@tailwindcss/nesting": "^0.0.0-insiders.565cd3e",
"@tanstack/react-table": "^8.16.0",
"@vercel/analytics": "^1.2.2",
"@vercel/speed-insights": "^1.0.10",
"class-variance-authority": "^0.7.0",
Expand All @@ -53,6 +54,7 @@
"preline": "^2.1.0",
"razorpay": "^2.9.3",
"react": "^18",
"react-csv": "^2.2.2",
"react-dom": "^18",
"react-hook-form": "^7.51.3",
"react-icons": "^5.1.0",
Expand All @@ -72,6 +74,7 @@
"@types/node": "^20",
"@types/nodemailer": "^6.4.14",
"@types/react": "^18.3.1",
"@types/react-csv": "^1.1.10",
"@types/react-dom": "^18",
"@types/shortid": "^0.0.32",
"autoprefixer": "^10.4.19",
Expand Down
21 changes: 21 additions & 0 deletions src/app/(content)/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import Glow from "@/components/shared/glow";
import { StarsCanvas } from "@/components/ui/Stars";
import Footer from "@/components/widgets/Footer";
import { Header } from "@/components/widgets/Header";
import React from "react";

function ContentLayout({ children }: { children: React.ReactNode }) {
return (
<>
<StarsCanvas />
<Glow />
<div className="flex min-h-screen w-full flex-col">
<Header />
{children}
</div>
<Footer />
</>
);
}

export default ContentLayout;
4 changes: 2 additions & 2 deletions src/app/page.tsx → src/app/(content)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import Lenis from "@/components/shared/lenis";
import { LabIntro } from "@/components/story/intro";
import { HeroParallax } from "@/components/widgets/Hero";
import { tiaraAssetsPrefix } from "@/lib/utils";
import RegisterNow from "../components/ui/registernow";
import EventsPage from "./(content)/events/page";
import RegisterNow from "../../components/ui/registernow";
import EventsPage from "./events/page";

const images = [
{ alt: "Image 0", src: `${tiaraAssetsPrefix}/hero/3(1).avif` },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { categoriesList } from "@/data/categoryList";
import { tiaraFont } from "@/lib/fonts";
import { CheckedItem, Event, Events } from "@/lib/interfaces";
import { cn } from "@/lib/utils";
import { signIn, useSession } from "next-auth/react";
import React, { useEffect, useState } from "react";

function processEvents(
Expand All @@ -38,14 +37,7 @@ function processEvents(
setEvents(eventsData);
}

const Register: React.FC = () => {
const session = useSession({
required: true,
onUnauthenticated: async () => {
await signIn("google");
},
});

export const Register = ({ name, email }: { name: string; email: string }) => {
const [technicalCheckedItems, setTechnicalCheckedItems] = useState<
CheckedItem[]
>([]);
Expand Down Expand Up @@ -74,6 +66,7 @@ const Register: React.FC = () => {
processEvents("cultural", categoriesList, setCultural);
processEvents("mega", categoriesList, setMega);
}, []);

const handleCheckboxChange = (
event: React.ChangeEvent<HTMLInputElement>,
category: string
Expand Down Expand Up @@ -236,7 +229,7 @@ const Register: React.FC = () => {
id="name"
aria-label="Name"
placeholder="Name"
value={session.data?.user?.name!}
value={name}
disabled
/>
<br />
Expand All @@ -246,7 +239,7 @@ const Register: React.FC = () => {
id="email"
aria-label="Email"
placeholder="Email"
value={session.data?.user?.email!}
value={email}
disabled
/>
<br />
Expand Down Expand Up @@ -275,5 +268,3 @@ const Register: React.FC = () => {
</div>
);
};

export default Register;
18 changes: 18 additions & 0 deletions src/app/(content)/register/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from "react";
import { auth, signIn } from "@/auth";
import { Register } from "./_components/Register";

async function RegisterPage() {
const session = await auth();
if (!session) {
<form
action={async () => {
"use server";
await signIn("google");
}}
/>;
}
return <Register name={session?.user.name!} email={session?.user.email!} />;
}

export default RegisterPage;
31 changes: 17 additions & 14 deletions src/app/(content)/terms/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,21 @@ import { cn } from "@/lib/utils";
import { legalInfo } from "../../../data/legal_Info";
import { Text } from "@/components/shared/text";
export default function Terms() {

return (
<Container className="mx-auto">
<div className="py-4 mx-6 sm:mx-12 space-y-4 pt-32 text-white">
<Text variant="h1" className={cn("text-5xl", tiaraFont)}>Terms & Conditions</Text>
{legalInfo.terms.map((terms, index) => (
<div key={index}>
<Text variant="h2" className={cn("text-2xl", tiaraFont)}>{terms.title}</Text>
<p dangerouslySetInnerHTML={{ __html: terms.description }}></p>
</div>
))}
</div>
</Container>
);
return (
<Container className="mx-auto">
<div className="py-4 mx-6 sm:mx-12 space-y-4 pt-32 text-white">
<Text variant="h1" className={cn("text-5xl", tiaraFont)}>
Terms & Conditions
</Text>
{legalInfo.terms.map((terms, index) => (
<div key={index}>
<Text variant="h2" className={cn("text-2xl", tiaraFont)}>
{terms.title}
</Text>
<p dangerouslySetInnerHTML={{ __html: terms.description }}></p>
</div>
))}
</div>
</Container>
);
}
96 changes: 96 additions & 0 deletions src/app/admin/_components/columnsPayments.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
"use client";
import { ColumnDef } from "@tanstack/react-table";
import { Payment } from "@prisma/client";
import { ArrowUpDown } from "lucide-react";
import { Button } from "@/components/ui/button";

export const columns: ColumnDef<Payment>[] = [
{
header: ({ column }) => {
return (
<Button
variant="ghost"
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
>
Name
<ArrowUpDown className="ml-2 h-4 w-4" />
</Button>
);
},
accessorKey: "user.name",
},
{
header: ({ column }) => {
return (
<Button
variant="ghost"
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
>
Email
<ArrowUpDown className="ml-2 h-4 w-4" />
</Button>
);
},
accessorKey: "user.email",
},
{
header: ({ column }) => {
return (
<Button
variant="ghost"
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
>
Events
<ArrowUpDown className="ml-2 h-4 w-4" />
</Button>
);
},
accessorKey: "user.events",
cell: ({ row }) => {
// @ts-ignore
return row.original.user.events.map((event, i) => <div key={i}>{event}</div>);
},
},
{
header: ({ column }) => {
return (
<Button
variant="ghost"
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
>
College
<ArrowUpDown className="ml-2 h-4 w-4" />
</Button>
);
},
accessorKey: "user.college",
},
{
header: ({ column }) => {
return (
<Button
variant="ghost"
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
>
Status
<ArrowUpDown className="ml-2 h-4 w-4" />
</Button>
);
},
accessorKey: "status",
},
{
header: ({ column }) => {
return (
<Button
variant="ghost"
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
>
Order ID
<ArrowUpDown className="ml-2 h-4 w-4" />
</Button>
);
},
accessorKey: "orderCreationId",
},
];
Loading
Loading