Skip to content

Commit

Permalink
feat: align to new backend responses
Browse files Browse the repository at this point in the history
  • Loading branch information
dominik-stumpf committed Nov 27, 2024
1 parent e0444fa commit e68b835
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 24 deletions.
10 changes: 6 additions & 4 deletions src/app/(dashboard)/[guildId]/[roleGroupId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import type { RoleGroup } from "@/lib/schemas/roleGroup";
import type { DynamicRoute, PaginatedResponse } from "@/lib/types";
import { Lock } from "@phosphor-icons/react/dist/ssr";
import { ScrollArea } from "@radix-ui/react-scroll-area";
import { Fragment } from "react";

const RoleGroupPage = async ({
params,
Expand All @@ -22,7 +21,10 @@ const RoleGroupPage = async ({
)
).json()) as PaginatedResponse<RoleGroup>;
const roleGroups = paginatedRoleGroup.items;
const roleGroup = roleGroups.find((rg) => rg.urlName === roleGroupIdParam)!;
const roleGroup = roleGroups.find(
// @ts-expect-error
(rg) => rg.urlName === roleGroupIdParam || rg.id === guild.homeRoleGroupId,
)!;

Check warning on line 27 in src/app/(dashboard)/[guildId]/[roleGroupId]/page.tsx

View workflow job for this annotation

GitHub Actions / quality-assurance

lint/style/noNonNullAssertion

Forbidden non-null assertion.
const paginatedRole = (await (
await fetch(
`${env.NEXT_PUBLIC_API}/role/search?customQuery=@guildId:{${guild.id}}&pageSize=${Number.MAX_SAFE_INTEGER}`,
Expand Down Expand Up @@ -57,7 +59,7 @@ const RoleGroupPage = async ({
</div>
<ScrollArea className="mt-6 h-32">
<div className="flex flex-col gap-6">
{Array.from({ length: 16 }, (_, i) => (
{/*Array.from({ length: 16 }, (_, i) => (
<Fragment key={i}>
{i > 0 && <div className="h-px w-full bg-border" />}
<div className="flex items-center gap-3">
Expand All @@ -70,7 +72,7 @@ const RoleGroupPage = async ({
</div>
</div>
</Fragment>
))}
))*/}
</div>
</ScrollArea>
</div>
Expand Down
11 changes: 5 additions & 6 deletions src/app/(dashboard)/[guildId]/components/GuildTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Skeleton } from "@/components/ui/Skeleton";
import { cn } from "@/lib/cssUtils";
import type { Guild } from "@/lib/schemas/guild";
import { getRoleGroups } from "../fetchers";
import { CreateRoleGroup } from "./CreateRoleGroup";
import { RoleGroupNavLink } from "./RoleGroupNavLink";

type Props = {
Expand All @@ -23,16 +22,17 @@ export const GuildTabs = async ({ guild }: Props) => {
}}
>
<div className="my-4 flex gap-3 px-8">
<RoleGroupNavLink href={`/${guild.urlName}`}>Home</RoleGroupNavLink>
{roleGroups.map((rg) => (
<RoleGroupNavLink
key={rg.id}
href={`/${guild.urlName}/${rg.urlName}`}
href={[guild.urlName, rg.urlName]
.filter(Boolean)
.map((s) => `/${s}`)
.join()}
>
{rg.name}
</RoleGroupNavLink>
))}
<CreateRoleGroup guildId={guild.id} />
</div>
<ScrollBar orientation="horizontal" className="hidden" />
</ScrollArea>
Expand All @@ -44,8 +44,7 @@ export const GuildTabsSkeleton = () => (
<div className="my-4 flex gap-3">
{[...Array(3)].map((_, i) => (
<Card
// biome-ignore lint: it's safe to use index as key in this case
key={i}
key={`${SKELETON_SIZES[i]}${i}`}
className={cn("flex h-11 items-center px-4", SKELETON_SIZES[i])}
>
<Skeleton className="h-4 w-full" />
Expand Down
2 changes: 1 addition & 1 deletion src/app/(dashboard)/[guildId]/fetchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const getGuild = async (urlName: string) => {

export const getRoleGroups = async (guildId: string) => {
const res = await fetch(
`${env.NEXT_PUBLIC_API}/role-group/search?customQuery=@guildId:{${guildId}}`,
`${env.NEXT_PUBLIC_API}/role-group/search?customQuery=@guildId:{${guildId}}&pageSize=${Number.MAX_SAFE_INTEGER}`,
{
next: {
tags: [`role-groups-${guildId}`],
Expand Down
17 changes: 4 additions & 13 deletions src/app/(dashboard)/[guildId]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
import type { DynamicRoute } from "@/lib/types";
import { getGuild } from "./fetchers";
import GuildPage from "./[roleGroupId]/page";

const DefaultGuildPage = async ({
params,
}: DynamicRoute<{ guildId: string }>) => {
const { guildId: urlName } = await params;
const guild = await getGuild(urlName);
// const paginatedRoleGroup = (await (
// await fetch(
// `${env.NEXT_PUBLIC_API}/role-group/search?customQuery=@guildId:{${guild.id}}`,
// )
// ).json()) as PaginatedResponse<RoleGroup>;
// const roleGroups = paginatedRoleGroup.items;
// const roleGroup = roleGroups.at(0);
// if (roleGroup) {
// redirect(`/${guildIdParam}/${roleGroup.urlName}`);
// }
return `Default guild page - ${guild.name}`;
//const guild = await getGuild(urlName);
//return `Default guild page - ${guild.name}`;
return <GuildPage params={{ guildId: urlName, roleGroupId: "" }} />;
};

export default DefaultGuildPage;

0 comments on commit e68b835

Please sign in to comment.