diff --git a/public/favicon.ico b/public/favicon.ico index 60c702a..a1042d4 100644 Binary files a/public/favicon.ico and b/public/favicon.ico differ diff --git a/public/images/tech_tracker_logo.png b/public/images/tech_tracker_logo.png new file mode 100644 index 0000000..8973d13 Binary files /dev/null and b/public/images/tech_tracker_logo.png differ diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 1f97126..aebbeae 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -1,19 +1,20 @@ import "~/styles/globals.css"; import { Inter as FontSans } from "next/font/google"; import { cn } from "~/lib/utils"; +import { SessionProvider } from "next-auth/react"; + +import { type Metadata } from "next"; +export const metadata: Metadata = { + title: "Tech Tracker", + description: "App used by COG IT employees to update their status throughout the day.", + icons: [{ rel: "icon", url: "/favicon.ico" }], +}; const fontSans = FontSans({ subsets: ["latin"], variable: "--font-sans", }); -import { type Metadata } from "next"; -export const metadata: Metadata = { - title: "Create T3 App", - description: "Generated by create-t3-app", - icons: [{ rel: "icon", url: "/favicon.ico" }], -}; - export default function RootLayout({ children, }: Readonly<{ children: React.ReactNode }>) { @@ -22,10 +23,11 @@ export default function RootLayout({ - {children} + + {children} + ); diff --git a/src/app/page.tsx b/src/app/page.tsx index 773fef1..5ea57b9 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,37 +1,21 @@ -import Link from "next/link"; +import { auth } from "~/auth"; +import { db } from "~/server/db"; +import No_Session from "~/components/auth/No_Session"; -export default function HomePage() { - return ( -
-
-

- Create T3 App -

-
- -

First Steps →

-
- Just the basics - Everything you need to know to set up your - database and authentication. -
- - -

Documentation →

-
- Learn more about Create T3 App, the libraries it uses, and how to - deploy it. -
- -
-
-
+export default async function HomePage() { + const user = await auth(); + const employees = await db.query.users.findMany({ + orderBy: (model, {desc}) => desc(model.id), + }); + if (!user) { + return ( + ); + } else { + return ( +
+

Welcome!

+
+ ); + } } diff --git a/src/components/auth/No_Session.tsx b/src/components/auth/No_Session.tsx new file mode 100644 index 0000000..7c00543 --- /dev/null +++ b/src/components/auth/No_Session.tsx @@ -0,0 +1,10 @@ +import Sign_In from "./Sign_In"; + +export default function No_Session() { + return ( +
+

Unauthorized. Please sign in first.

+ < Sign_In /> +
+ ); +}; diff --git a/src/components/auth/Sign_In.tsx b/src/components/auth/Sign_In.tsx new file mode 100644 index 0000000..0fb280a --- /dev/null +++ b/src/components/auth/Sign_In.tsx @@ -0,0 +1,13 @@ +import { signIn } from "~/auth"; + +export default async function Sign_In() { + return ( +
{ + "use server"; + await signIn("microsoft-entra-id"); + }}> + +
+ ); +} diff --git a/src/env.js b/src/env.js index 305f22d..636d9e8 100644 --- a/src/env.js +++ b/src/env.js @@ -12,13 +12,13 @@ export const env = createEnv({ .enum(["development", "test", "production"]) .default("development"), API_KEY: z.string(), - AUTH_SECRET: + AUTH_SECRET: process.env.NODE_ENV === "production" ? z.string() : z.string().optional(), - AUTH_MICROSOFT_ENTRA_ID: z.string(), - AUTH_MICROSOFT_ENTRA_SECRET: z.string(), - AUTH_MICROSOFT_ENTRA_TENANT_ID: z.string(), + AUTH_MICROSOFT_ENTRA_ID_ID: z.string(), + AUTH_MICROSOFT_ENTRA_ID_SECRET: z.string(), + AUTH_MICROSOFT_ENTRA_ID_TENANT_ID: z.string(), }, /** @@ -38,10 +38,10 @@ export const env = createEnv({ DATABASE_URL: process.env.DATABASE_URL, NODE_ENV: process.env.NODE_ENV, API_KEY: process.env.API_KEY, - AUTH_SECRET: process.env.AUTH_SECRET, - AUTH_MICROSOFT_ENTRA_ID: process.env.AUTH_MICROSOFT_ENTRA_ID, - AUTH_MICROSOFT_ENTRA_SECRET: process.env.AUTH_MICROSOFT_ENTRA_SECRET, - AUTH_MICROSOFT_ENTRA_TENANT_ID: process.env.AUTH_MICROSOFT_ENTRA_TENANT_ID, + AUTH_SECRET: process.env.NEXTAUTH_SECRET, + AUTH_MICROSOFT_ENTRA_ID_ID: process.env.AUTH_MICROSOFT_ENTRA_ID_ID, + AUTH_MICROSOFT_ENTRA_ID_SECRET: process.env.AUTH_MICROSOFT_ENTRA_ID_SECRET, + AUTH_MICROSOFT_ENTRA_ID_TENANT_ID: process.env.AUTH_MICROSOFT_ENTRA_ID_TENANT_ID, }, /** * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially diff --git a/src/server/db/schema.ts b/src/server/db/schema.ts index a0d14bb..5357f8b 100644 --- a/src/server/db/schema.ts +++ b/src/server/db/schema.ts @@ -1,34 +1,32 @@ -// Example model schema from the Drizzle docs // https://orm.drizzle.team/docs/sql-schema-declaration - import { sql } from "drizzle-orm"; import { bigint, - index, mysqlTableCreator, timestamp, varchar, } from "drizzle-orm/mysql-core"; -/** - * This is an example of how to use the multi-project schema feature of Drizzle ORM. Use the same - * database instance for multiple projects. - * - * @see https://orm.drizzle.team/docs/goodies#multi-project-schema - */ -export const createTable = mysqlTableCreator((name) => `tech_tracker_web_${name}`); +export const createTable = mysqlTableCreator((name) => `${name}`); -export const posts = createTable( - "post", +export const users = createTable( + "users", { - id: bigint("id", { mode: "number" }).primaryKey().autoincrement(), + id: bigint("id", {mode: "number"}).primaryKey().autoincrement(), name: varchar("name", { length: 256 }), - createdAt: timestamp("created_at") + status: varchar("status", { length: 256 }), + updatedAt: timestamp("updated_at") .default(sql`CURRENT_TIMESTAMP`) .notNull(), - updatedAt: timestamp("updated_at").onUpdateNow(), }, - (example) => ({ - nameIndex: index("name_idx").on(example.name), - }) +); + +export const history = createTable( + "history", + { + id: bigint("id", {mode: "number"}).primaryKey().autoincrement(), + user_id: bigint("user_id", {mode: "number"}).references(() => users.id), + status: varchar("status", { length: 256 }), + updatedAt: timestamp("updated_at").notNull(), + }, ); diff --git a/src/styles/globals.css b/src/styles/globals.css index 89f6093..d8fb6d9 100644 --- a/src/styles/globals.css +++ b/src/styles/globals.css @@ -4,6 +4,33 @@ @layer base { :root { + --background: 240 10% 3.9%; + --foreground: 0 0% 98%; + --card: 240 10% 3.9%; + --card-foreground: 0 0% 98%; + --popover: 240 10% 3.9%; + --popover-foreground: 0 0% 98%; + --primary: 0 0% 98%; + --primary-foreground: 240 5.9% 10%; + --secondary: 240 3.7% 15.9%; + --secondary-foreground: 0 0% 98%; + --muted: 240 3.7% 15.9%; + --muted-foreground: 240 5% 64.9%; + --accent: 240 3.7% 15.9%; + --accent-foreground: 0 0% 98%; + --destructive: 0 62.8% 30.6%; + --destructive-foreground: 0 0% 98%; + --border: 240 3.7% 15.9%; + --input: 240 3.7% 15.9%; + --ring: 240 4.9% 83.9%; + --chart-1: 220 70% 50%; + --chart-2: 160 60% 45%; + --chart-3: 30 80% 55%; + --chart-4: 280 65% 60%; + --chart-5: 340 75% 55%; + } + + .dark { --background: 0 0% 100%; --foreground: 240 10% 3.9%; --card: 0 0% 100%; @@ -30,33 +57,6 @@ --chart-4: 43 74% 66%; --chart-5: 27 87% 67%; } - - .dark { - --background: 240 10% 3.9%; - --foreground: 0 0% 98%; - --card: 240 10% 3.9%; - --card-foreground: 0 0% 98%; - --popover: 240 10% 3.9%; - --popover-foreground: 0 0% 98%; - --primary: 0 0% 98%; - --primary-foreground: 240 5.9% 10%; - --secondary: 240 3.7% 15.9%; - --secondary-foreground: 0 0% 98%; - --muted: 240 3.7% 15.9%; - --muted-foreground: 240 5% 64.9%; - --accent: 240 3.7% 15.9%; - --accent-foreground: 0 0% 98%; - --destructive: 0 62.8% 30.6%; - --destructive-foreground: 0 0% 98%; - --border: 240 3.7% 15.9%; - --input: 240 3.7% 15.9%; - --ring: 240 4.9% 83.9%; - --chart-1: 220 70% 50%; - --chart-2: 160 60% 45%; - --chart-3: 30 80% 55%; - --chart-4: 280 65% 60%; - --chart-5: 340 75% 55%; - } } @layer base { @@ -66,4 +66,4 @@ body { @apply bg-background text-foreground; } -} \ No newline at end of file +}