-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d5d3a57
commit 600ba3c
Showing
15 changed files
with
332 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import NextAuth from "next-auth"; | ||
import GithubProvider from "next-auth/providers/github"; | ||
import GoogleProvider from "next-auth/providers/google"; | ||
|
||
const handler = NextAuth({ | ||
// Configure one or more authentication providers | ||
providers: [ | ||
GoogleProvider({ | ||
clientId: process.env.GOOGLE_ID, | ||
clientSecret: process.env.GOOGLE_SECRET, | ||
}), | ||
// ...add more providers here | ||
], | ||
}); | ||
|
||
export { handler as GET, handler as POST }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
export default function ExpandingArrow({ className }: { className?: string }) { | ||
return ( | ||
<div className="group relative flex items-center"> | ||
<svg | ||
className={`${ | ||
className ? className : 'h-4 w-4' | ||
} absolute transition-all group-hover:translate-x-1 group-hover:opacity-0`} | ||
xmlns="http://www.w3.org/2000/svg" | ||
fill="currentColor" | ||
viewBox="0 0 16 16" | ||
width="16" | ||
height="16" | ||
> | ||
<path | ||
fillRule="evenodd" | ||
d="M6.22 3.22a.75.75 0 011.06 0l4.25 4.25a.75.75 0 010 1.06l-4.25 4.25a.75.75 0 01-1.06-1.06L9.94 8 6.22 4.28a.75.75 0 010-1.06z" | ||
></path> | ||
</svg> | ||
<svg | ||
className={`${ | ||
className ? className : 'h-4 w-4' | ||
} absolute opacity-0 transition-all group-hover:translate-x-1 group-hover:opacity-100`} | ||
xmlns="http://www.w3.org/2000/svg" | ||
fill="currentColor" | ||
viewBox="0 0 16 16" | ||
width="16" | ||
height="16" | ||
> | ||
<path | ||
fillRule="evenodd" | ||
d="M8.22 2.97a.75.75 0 011.06 0l4.25 4.25a.75.75 0 010 1.06l-4.25 4.25a.75.75 0 01-1.06-1.06l2.97-2.97H3.75a.75.75 0 010-1.5h7.44L8.22 4.03a.75.75 0 010-1.06z" | ||
></path> | ||
</svg> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Suspense } from "react"; | ||
import BotStatus from "./gated/bot-status"; | ||
import SendCoffeeChats from "./gated/send-coffee-chats"; | ||
import AddBirthday from "./gated/add-birthday"; | ||
|
||
const GatedComponents = () => { | ||
return ( | ||
<> | ||
<BotStatus /> | ||
<SendCoffeeChats /> | ||
<AddBirthday /> | ||
</> | ||
); | ||
}; | ||
|
||
export default GatedComponents; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { addUserOrUpdateBirthday } from "@/core/add-birthday"; | ||
|
||
const AddBirthday = () => { | ||
const action = async (formdata: FormData) => { | ||
"use server"; | ||
|
||
const email = formdata.get("email") as string | null; | ||
const date = formdata.get("date") as string | null; // format: YYYY-MM-DD | ||
|
||
if (!email || !date) { | ||
return; | ||
} | ||
|
||
await addUserOrUpdateBirthday(email, new Date(date)); | ||
}; | ||
|
||
return ( | ||
<form action={action}> | ||
<input type='email' name='email' required /> | ||
<input type='date' name='date' required /> | ||
<button type='submit'>Submit New Birthday</button> | ||
</form> | ||
); | ||
}; | ||
|
||
export default AddBirthday; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { toggleCurrentBotStatus } from "@/core/bot-status"; | ||
|
||
// Server action defined inside a Server Component | ||
const ToggleBotStatus = () => { | ||
const toggle = async () => { | ||
"use server"; | ||
await toggleCurrentBotStatus(); | ||
}; | ||
|
||
return ( | ||
// @ts-expect-error | ||
<form action={toggle}> | ||
<button type='submit'>Toggle Bot Enabled/Disabled</button> | ||
</form> | ||
); | ||
}; | ||
|
||
export default ToggleBotStatus; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { exec } from "@/core/send-coffee-chats"; | ||
|
||
const SendCoffeeChats = () => { | ||
const action = async () => { | ||
"use server"; | ||
await exec(); | ||
}; | ||
|
||
return ( | ||
// @ts-expect-error | ||
<form action={action}> | ||
<button type='submit'>Manually send a round of coffee chats</button> | ||
</form> | ||
); | ||
}; | ||
|
||
export default SendCoffeeChats; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Suspense } from "react"; | ||
import BotStatus from "./non-gated/bot-status"; | ||
import PopulateNewSemester from "./non-gated/new-semester"; | ||
|
||
const NonGatedComponents = () => { | ||
return ( | ||
<> | ||
<Suspense fallback={<div>Fetching Bot Status...</div>}> | ||
{/* @ts-expect-error Async Server Component */} | ||
<BotStatus /> | ||
</Suspense> | ||
<PopulateNewSemester /> | ||
</> | ||
); | ||
}; | ||
|
||
export default NonGatedComponents; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { exec } from "@/core/new-semester"; | ||
|
||
export default function PopulateNewSemester() { | ||
async function action() { | ||
"use server"; | ||
console.log("Populating new semester..."); | ||
await exec(); | ||
} | ||
|
||
return ( | ||
// @ts-expect-error | ||
<form action={action}> | ||
<button type='submit'>Populate Database</button> | ||
</form> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use client' | ||
|
||
import { useRouter } from 'next/navigation' | ||
import { useTransition } from 'react' | ||
|
||
export default function RefreshButton() { | ||
const router = useRouter() | ||
const [isPending, startTransition] = useTransition() | ||
|
||
return ( | ||
<button | ||
className={`${ | ||
isPending ? 'cursor-not-allowed text-gray-400' : '' | ||
} text-sm text-gray-500 hover:text-gray-900`} | ||
disabled={isPending} | ||
onClick={() => { | ||
startTransition(() => { | ||
router.refresh() | ||
}) | ||
}} | ||
> | ||
{isPending ? 'Refreshing...' : 'Refresh'} | ||
</button> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import RefreshButton from './refresh-button' | ||
|
||
export default function TablePlaceholder() { | ||
return ( | ||
<div className="bg-white/30 p-12 shadow-xl ring-1 ring-gray-900/5 rounded-lg backdrop-blur-lg max-w-xl mx-auto w-full"> | ||
<div className="flex justify-between items-center mb-4"> | ||
<div className="space-y-1"> | ||
<h2 className="text-xl font-semibold">Recent Users</h2> | ||
<p className="text-sm text-gray-500">Fetching users...</p> | ||
</div> | ||
<RefreshButton /> | ||
</div> | ||
<div className="divide-y divide-gray-900/5"> | ||
{[...Array(3)].map((_, i) => ( | ||
<div key={i} className="flex items-center justify-between py-3"> | ||
<div className="flex items-center space-x-4"> | ||
<div className="h-12 w-12 rounded-full bg-gray-200 animate-pulse" /> | ||
<div className="space-y-1"> | ||
<div className="h-6 w-28 rounded-md bg-gray-200 animate-pulse" /> | ||
<div className="h-4 w-24 rounded-md bg-gray-200 animate-pulse" /> | ||
</div> | ||
</div> | ||
<div className="h-4 w-12 rounded-md bg-gray-200 animate-pulse" /> | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import prisma from '@/lib/prisma' | ||
import { timeAgo } from '@/lib/utils' | ||
import Image from 'next/image' | ||
import RefreshButton from './refresh-button' | ||
|
||
export default async function Table() { | ||
const startTime = Date.now() | ||
const users = await prisma.users.findMany() | ||
const duration = Date.now() - startTime | ||
|
||
return ( | ||
<div className="bg-white/30 p-12 shadow-xl ring-1 ring-gray-900/5 rounded-lg backdrop-blur-lg max-w-xl mx-auto w-full"> | ||
<div className="flex justify-between items-center mb-4"> | ||
<div className="space-y-1"> | ||
<h2 className="text-xl font-semibold">Recent Users</h2> | ||
<p className="text-sm text-gray-500"> | ||
Fetched {users.length} users in {duration}ms | ||
</p> | ||
</div> | ||
<RefreshButton /> | ||
</div> | ||
<div className="divide-y divide-gray-900/5"> | ||
{users.map((user) => ( | ||
<div | ||
key={user.name} | ||
className="flex items-center justify-between py-3" | ||
> | ||
<div className="flex items-center space-x-4"> | ||
<Image | ||
src={user.image} | ||
alt={user.name} | ||
width={48} | ||
height={48} | ||
className="rounded-full ring-1 ring-gray-900/5" | ||
/> | ||
<div className="space-y-1"> | ||
<p className="font-medium leading-none">{user.name}</p> | ||
<p className="text-sm text-gray-500">{user.email}</p> | ||
</div> | ||
</div> | ||
<p className="text-sm text-gray-500">{timeAgo(user.createdAt)}</p> | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
type admin = { | ||
name?: string; | ||
email: string; | ||
}; | ||
|
||
const admins: admin[] = [ | ||
{ | ||
name: "Daniel Wei", | ||
email: "dlw266@cornell.edu", | ||
}, | ||
{ | ||
name: "Justin Kong", | ||
email: "jk2338@cornell.edu", | ||
}, | ||
{ | ||
name: "Julie Jeong", | ||
email: "sj598@cornell.edu", | ||
}, | ||
{ | ||
name: "Rohan Maheshwari", | ||
email: "rm697@cornell.edu", | ||
}, | ||
{ | ||
name: "Sarah Young", | ||
email: "sy398@cornell.edu", | ||
}, | ||
{ | ||
name: "Michelle Li", | ||
email: "myl39@cornell.edu", | ||
}, | ||
]; | ||
|
||
export default admins; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import prisma from "../lib/prisma"; | ||
|
||
export async function main() { | ||
const response = await Promise.all([ | ||
// Populate initial... | ||
]); | ||
console.log(response); | ||
} | ||
|
||
main() | ||
.then(async () => { | ||
await prisma.$disconnect(); | ||
}) | ||
.catch(async (e) => { | ||
console.error(e); | ||
await prisma.$disconnect(); | ||
process.exit(1); | ||
}); |