Skip to content

Commit

Permalink
maige biome refactor, bleed
Browse files Browse the repository at this point in the history
  • Loading branch information
DexterStorey committed Oct 3, 2024
1 parent ec77f6d commit bcb8c15
Show file tree
Hide file tree
Showing 190 changed files with 3,852 additions and 4,387 deletions.
4 changes: 0 additions & 4 deletions .eslintrc.js

This file was deleted.

21 changes: 13 additions & 8 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
{
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"json"
],
"editor.defaultFormatter": "biomejs.biome",
"editor.formatOnSave": true,
"editor.formatOnType": true,
"[typescript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[typescriptreact]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[json]": {
"editor.defaultFormatter": "biomejs.biome"
},
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
"quickfix.biome": "explicit",
"source.organizeImports.biome": "explicit"
},
"[prisma]": {
"editor.defaultFormatter": "Prisma.prisma"
Expand Down
4 changes: 2 additions & 2 deletions app/[slug]/(base)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ export default async function RootLayout({
children: React.ReactNode
}) {
return (
<div className='space-y-4'>
<div className="space-y-4">
<TeamNav />
<div className='z-10 h-full w-full'>{children}</div>
<div className="z-10 h-full w-full">{children}</div>
</div>
)
}
44 changes: 23 additions & 21 deletions app/[slug]/(base)/page.tsx
Original file line number Diff line number Diff line change
@@ -1,46 +1,48 @@
import {Suspense} from 'react'
import {ProjectsList} from '~/components/dashboard/Projects/ProjectsList'
import prisma from '~/prisma'
import {getCurrentUser} from '~/utils/session'
import { Suspense } from "react";
import { ProjectsList } from "~/components/dashboard/Projects/ProjectsList";
import prisma from "~/prisma";
import { getCurrentUser } from "~/utils/session";

export default async function Dashboard({params}: {params: {slug: string}}) {
const user = await getCurrentUser()
export default async function Dashboard({
params,
}: { params: { slug: string } }) {
const user = await getCurrentUser();

const memberships = await prisma.membership.findFirst({
where: {
userId: user.id,
team: {
slug: params.slug
}
slug: params.slug,
},
},
select: {
team: {
include: {
Project: {
include: {
instructions: true,
organization: true
}
}
}
}
}
})
organization: true,
},
},
},
},
},
});

if (!memberships) return <p>Could not find team {params.slug}</p>
if (!memberships) return <p>Could not find team {params.slug}</p>;

const {team} = memberships
const {Project: projects} = team
const { team } = memberships;
const { Project: projects } = team;

return (
<div className='flex flex-col items-center'>
<div className="flex flex-col items-center">
<Suspense fallback={<p>Loading...</p>}>
<ProjectsList
username={user.userName}
username={user.userName as string}
teamSlug={params.slug}
projects={projects}
/>
</Suspense>
</div>
)
);
}
4 changes: 2 additions & 2 deletions app/[slug]/(base)/settings/advanced/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {DeleteTeam} from '~/components/dashboard/Settings'
import { DeleteTeam } from '~/components/dashboard/Settings'

export default function AdvancedSettings() {
return (
<div className='flex flex-col gap-4'>
<div className="flex flex-col gap-4">
<h3>Advanced</h3>
<DeleteTeam />
</div>
Expand Down
35 changes: 16 additions & 19 deletions app/[slug]/(base)/settings/billing/page.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
import Link from 'next/link'
import {UpgradeForm} from '~/components/dashboard/Billing/UpgradeForm'
import {Button} from '~/components/ui/button'
import {STRIPE} from '~/constants'
import prisma from '~/prisma'
import {getCurrentUser} from '~/utils/session'
import Link from "next/link";
import { UpgradeForm } from "~/components/dashboard/Billing/UpgradeForm";
import { Button } from "~/components/ui/button";
import { STRIPE } from "~/constants";
import prisma from "~/prisma";
import { getCurrentUser } from "~/utils/session";

function ManageButton() {
return (
<Link
target='_blank'
className='w-fit'
href={STRIPE.MANAGE_LINK}>
<Button variant='outline'>Manage Subscription</Button>
<Link target="_blank" className="w-fit" href={STRIPE.MANAGE_LINK}>
<Button variant="outline">Manage Subscription</Button>
</Link>
)
);
}

export default async function Billing() {
const {id} = await getCurrentUser()
const { id } = await getCurrentUser();
const user = await prisma.user.findUnique({
where: {id},
select: {stripeCustomerId: true}
})
where: { id },
select: { stripeCustomerId: true },
});

return (
<div className='flex flex-col gap-4'>
<div className="flex flex-col gap-4">
<h3>Billing</h3>
{user.stripeCustomerId ? <ManageButton /> : <UpgradeForm />}
{user?.stripeCustomerId ? <ManageButton /> : <UpgradeForm />}
</div>
)
);
}
17 changes: 10 additions & 7 deletions app/[slug]/(base)/settings/general/page.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import TeamDetailsForm from '~/components/dashboard/Settings/TeamDetailsForm'
import prisma from '~/prisma'
import type { Team } from "@prisma/client";
import TeamDetailsForm from "~/components/dashboard/Settings/TeamDetailsForm";
import prisma from "~/prisma";

export default async function General({params}: {params: {slug: string}}) {
const team = await prisma.team.findUnique({where: {slug: params.slug}})
export default async function General({
params,
}: { params: { slug: string } }) {
const team = await prisma.team.findUnique({ where: { slug: params.slug } });
return (
<div className='flex flex-col gap-6 py-0.5'>
<div className="flex flex-col gap-6 py-0.5">
<h3>General</h3>
<TeamDetailsForm team={team} />
<TeamDetailsForm team={team as Team} />
</div>
)
);
}
6 changes: 3 additions & 3 deletions app/[slug]/(base)/settings/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ export default async function Layout({
params,
children
}: {
params: {slug: string; projectId: string}
params: { slug: string; projectId: string }
children: React.ReactNode
}) {
return (
<div className='flex h-full w-full gap-4'>
<div className="flex h-full w-full gap-4">
<SettingsNav teamSlug={params.slug} />
<div className='h-full w-full max-w-2xl'>{children}</div>
<div className="h-full w-full max-w-2xl">{children}</div>
</div>
)
}
40 changes: 21 additions & 19 deletions app/[slug]/(base)/settings/members/page.tsx
Original file line number Diff line number Diff line change
@@ -1,41 +1,43 @@
import {redirect} from 'next/navigation'
import { redirect } from "next/navigation";
import {
ExistingMembers,
InviteDialog,
PendingInvitations
} from '~/components/dashboard/Settings'
import prisma from '~/prisma'
import {getCurrentUser} from '~/utils/session'
PendingInvitations,
} from "~/components/dashboard/Settings";
import prisma from "~/prisma";
import { getCurrentUser } from "~/utils/session";

export default async function Members({params}: {params: {slug: string}}) {
const user = await getCurrentUser()
export default async function Members({
params,
}: { params: { slug: string } }) {
const user = await getCurrentUser();
const team = await prisma.team.findFirst({
where: {slug: params.slug, memberships: {some: {userId: user.id}}},
where: { slug: params.slug, memberships: { some: { userId: user.id } } },
select: {
id: true,
memberships: {
select: {
id: true,
role: true,
user: {select: {id: true, email: true, createdAt: true}}
}
user: { select: { id: true, email: true, createdAt: true } },
},
},
invites: {
where: {acceptedBy: null},
select: {id: true, email: true, role: true, createdAt: true}
}
}
})
if (!team) redirect('/')
where: { acceptedBy: null },
select: { id: true, email: true, role: true, createdAt: true },
},
},
});
if (!team) redirect("/");

return (
<div className='flex flex-col gap-6 py-0.5'>
<div className='flex items-center justify-between gap-2'>
<div className="flex flex-col gap-6 py-0.5">
<div className="flex items-center justify-between gap-2">
<h3>Members</h3>
<InviteDialog teamId={team.id} />
</div>
<ExistingMembers members={team.memberships} />
{team.invites.length > 0 && <PendingInvitations invites={team.invites} />}
</div>
)
);
}
4 changes: 2 additions & 2 deletions app/[slug]/(base)/settings/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {redirect} from 'next/navigation'
import { redirect } from 'next/navigation'

export default async function Settings({params}: {params: {slug: string}}) {
export default async function Settings({ params }: { params: { slug: string } }) {
redirect(`/${params.slug}/settings/members`)
}
38 changes: 16 additions & 22 deletions app/[slug]/(base)/usage/[[...metric]]/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,41 +1,35 @@
import {notFound} from 'next/navigation'
import z from 'zod'
import {ChartsLinks, UsageCharts} from '~/components/dashboard/Metrics'
import { notFound } from "next/navigation";
import z from "zod";
import { ChartsLinks, UsageCharts } from "~/components/dashboard/Metrics";

const paramsSchema = z.enum(['runs', 'tokens'])
const paramsSchema = z.enum(["runs", "tokens"]);

export default async function RootLayout({
children,
params
params,
}: {
children: React.ReactNode
children: React.ReactNode;
params: {
slug: string
metric: string[] | undefined
}
slug: string;
metric: string[] | undefined;
};
}) {
if (
params.metric &&
(params.metric.length > 1 ||
!paramsSchema.safeParse(params?.metric[0]).success)
)
return notFound()
return notFound();

const route = params.metric ? params.metric[0] : ''
const route = params.metric ? params.metric[0] : "";

return (
<div className='space-y-2'>
<ChartsLinks
teamSlug={params.slug}
route={route}
/>
<div className='space-y-5'>
<UsageCharts
teamSlug={params.slug}
route={route}
/>
<div className="space-y-2">
<ChartsLinks teamSlug={params.slug} route={route as string} />
<div className="space-y-5">
<UsageCharts teamSlug={params.slug} route={route as string} />
{children}
</div>
</div>
)
);
}
10 changes: 6 additions & 4 deletions app/[slug]/(base)/usage/[[...metric]]/loading.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import {Skeleton} from '~/components/ui/skeleton'
import { Skeleton } from '~/components/ui/skeleton'

// biome-ignore lint/complexity/noBannedTypes: <explanation>
type Props = {}

// biome-ignore lint/correctness/noEmptyPattern: <explanation>
export default function Loading({}: Props) {
return (
<div className='space-y-2'>
<Skeleton className='h-10' />
<Skeleton className='h-56' />
<div className="space-y-2">
<Skeleton className="h-10" />
<Skeleton className="h-56" />
</div>
)
}
18 changes: 9 additions & 9 deletions app/[slug]/(base)/usage/[[...metric]]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import {UsageTable} from '~/components/dashboard/Metrics'
import { UsageTable } from "~/components/dashboard/Metrics";

export default async function Usage({
searchParams,
params
params,
}: {
searchParams: {[key: string]: string | string[] | undefined}
searchParams: { [key: string]: string | string[] | undefined };
params: {
slug: string
metric: string[] | undefined
}
slug: string;
metric: string[] | undefined;
};
}) {
const route = params.metric ? params.metric[0] : ''
const route = params.metric ? params.metric[0] : "";

return (
<UsageTable
teamSlug={params.slug}
route={route}
route={route as string}
searchParams={searchParams}
/>
)
);
}
Loading

0 comments on commit bcb8c15

Please sign in to comment.