Skip to content
This repository has been archived by the owner on Oct 27, 2024. It is now read-only.

Commit

Permalink
Fix tailwind class sorting, add basic guild list page
Browse files Browse the repository at this point in the history
  • Loading branch information
nint8835 committed Dec 27, 2023
1 parent ca94fed commit ffa1d12
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 5 deletions.
3 changes: 2 additions & 1 deletion prettier.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ module.exports = {
singleQuote: true,
printWidth: 120,
tabWidth: 4,
plugins: ['prettier-plugin-tailwindcss', '@trivago/prettier-plugin-sort-imports'],
plugins: ['@trivago/prettier-plugin-sort-imports', 'prettier-plugin-tailwindcss'],
importOrder: ['^@/components/(.*)$', '^@/(.*)$', '^[./]'],
importOrderSeparation: true,
importOrderSortSpecifiers: true,
tailwindFunctions: ['cva', 'cn'],
};
39 changes: 36 additions & 3 deletions src/app/guilds/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { and, eq, getTableColumns } from 'drizzle-orm';
import { Plus } from 'lucide-react';
import Link from 'next/link';
import { redirect } from 'next/navigation';

import { Button } from '@/components/ui/button';

import db from '@/db';
import { guildMemberships, guilds } from '@/db/schema';
import { ssrGetCurrentUser } from '@/lib/auth';
Expand All @@ -21,16 +25,45 @@ export default async function GuildsPage() {
const currentUser = (await ssrGetCurrentUser())!;

const currentUserGuilds = await db
.select({ ...getTableColumns(guilds) })
.select({ ...getTableColumns(guilds), admin: guildMemberships.admin })
.from(guilds)
.innerJoin(
guildMemberships,
and(eq(guilds.id, guildMemberships.guildId), eq(guildMemberships.userId, currentUser.id)),
);

return (
<div>
<pre>{JSON.stringify(currentUserGuilds, null, 2)}</pre>
<div className="space-y-4 p-4">
<div className="flex flex-row items-center justify-between">
<h2 className="text-2xl font-bold">Guilds</h2>
<Button className="flex flex-row items-center justify-between" variant="secondary" asChild>
<a href="/guilds/begin-registration">
<Plus className="mr-2 h-4 w-4" /> Add Guild
</a>
</Button>
</div>
<div>
{currentUserGuilds.length !== 0 ? (
<ul className="list-inside list-disc">
{currentUserGuilds.map(({ id, name, admin }) => (
<li key={id}>
<Link href={`/guilds/${id}`} className="rounded-md p-2 transition-all hover:bg-accent">
{name}
</Link>
{admin && (
<span className="ml-2 text-sm text-muted-foreground" title="Guild Administrator">
(Admin)
</span>
)}
</li>
))}
</ul>
) : (
<div className="text-center italic text-muted-foreground">
You are not a member of any registered guilds.
</div>
)}
</div>
</div>
);
}
2 changes: 1 addition & 1 deletion src/components/ui/sheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const SheetOverlay = React.forwardRef<
SheetOverlay.displayName = SheetPrimitive.Overlay.displayName;

const sheetVariants = cva(
'fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500',
'fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500 data-[state=open]:animate-in data-[state=closed]:animate-out',
{
variants: {
side: {
Expand Down

0 comments on commit ffa1d12

Please sign in to comment.