From b8e12cd83a9d945ef4501ad485dfd9170527b4c3 Mon Sep 17 00:00:00 2001 From: Dominik Stumpf Date: Wed, 4 Dec 2024 09:39:53 +0100 Subject: [PATCH] chore: update types package --- package.json | 2 +- .../[guildUrlName]/[pageUrlName]/page.tsx | 29 +++++++++---------- src/app/(dashboard)/[guildUrlName]/actions.ts | 6 ++-- .../[guildUrlName]/components/GuildTabs.tsx | 2 +- src/app/(dashboard)/explorer/actions.ts | 2 +- .../explorer/components/GuildCard.tsx | 2 +- src/app/(dashboard)/explorer/page.tsx | 4 +-- src/lib/fetchers.ts | 6 ++-- src/lib/options.ts | 4 +-- 9 files changed, 27 insertions(+), 30 deletions(-) diff --git a/package.json b/package.json index b8bf563ff6..e55151a33d 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "build-storybook": "storybook build" }, "dependencies": { - "@guildxyz/types": "^3.0.8", + "@guildxyz/types": "^3.0.9", "@hookform/resolvers": "^3.9.1", "@phosphor-icons/react": "^2.1.7", "@radix-ui/react-avatar": "^1.1.1", diff --git a/src/app/(dashboard)/[guildUrlName]/[pageUrlName]/page.tsx b/src/app/(dashboard)/[guildUrlName]/[pageUrlName]/page.tsx index 7883680487..ac2b9d02f0 100644 --- a/src/app/(dashboard)/[guildUrlName]/[pageUrlName]/page.tsx +++ b/src/app/(dashboard)/[guildUrlName]/[pageUrlName]/page.tsx @@ -10,15 +10,15 @@ const GuildPage = async ({ params, }: DynamicRoute<{ pageUrlName: string; guildUrlName: string }>) => { const { pageUrlName, guildUrlName } = await params; - const guild = await fetchGuildApiData( + const guild = await fetchGuildApiData( `guild/urlName/${guildUrlName}`, ); - const pages = await fetchGuildApiData("page/batch", { + const pages = await fetchGuildApiData("page/batch", { method: "POST", body: JSON.stringify({ ids: guild.pages?.map((p) => p.pageId!) ?? [] }), }); const page = pages.find((p) => p.urlName === pageUrlName)!; - const roles = await fetchGuildApiData("role/batch", { + const roles = await fetchGuildApiData("role/batch", { method: "POST", body: JSON.stringify({ ids: page.roles?.map((r) => r.roleId!) ?? [], @@ -34,19 +34,16 @@ const GuildPage = async ({ ); }; -const RoleCard = async ({ role }: { role: Schemas["RoleFull"] }) => { - const rewards = await fetchGuildApiData( - "reward/batch", - { - method: "POST", - body: JSON.stringify({ - ids: role.rewards?.map((r) => r.rewardId!) ?? [], - }), - headers: { - "Content-Type": "application/json", - }, +const RoleCard = async ({ role }: { role: Schemas["Role"] }) => { + const rewards = await fetchGuildApiData("reward/batch", { + method: "POST", + body: JSON.stringify({ + ids: role.rewards?.map((r) => r.rewardId!) ?? [], + }), + headers: { + "Content-Type": "application/json", }, - ); + }); return ( @@ -89,7 +86,7 @@ const RoleCard = async ({ role }: { role: Schemas["RoleFull"] }) => { ); }; -const Reward = ({ reward }: { reward: Schemas["RewardFull"] }) => { +const Reward = ({ reward }: { reward: Schemas["Reward"] }) => { return (
{reward.name}
diff --git a/src/app/(dashboard)/[guildUrlName]/actions.ts b/src/app/(dashboard)/[guildUrlName]/actions.ts index 5247218483..6f15e7399e 100644 --- a/src/app/(dashboard)/[guildUrlName]/actions.ts +++ b/src/app/(dashboard)/[guildUrlName]/actions.ts @@ -11,7 +11,7 @@ export const fetchGuildLeave = async ({ guildId }: { guildId: string }) => { }; export const fetchGuild = async ({ idLike }: WithIdLike) => { - return fetchGuildApiData( + return fetchGuildApiData( `guild/${resolveIdLikeRequest(idLike)}`, ); }; @@ -31,7 +31,7 @@ export const fetchEntity = async ({ export const fetchUser = async () => { const { userId } = await tryGetParsedToken(); - return fetchEntity({ + return fetchEntity({ entity: "user", idLike: userId, }); @@ -39,7 +39,7 @@ export const fetchUser = async () => { export const fetchPages = async ({ guildId }: { guildId: string }) => { const guild = await fetchGuild({ idLike: guildId }); - return fetchGuildApiData("page/batch", { + return fetchGuildApiData("page/batch", { method: "POST", body: JSON.stringify({ ids: guild.pages?.map((p) => p.pageId!) ?? [] }), }); diff --git a/src/app/(dashboard)/[guildUrlName]/components/GuildTabs.tsx b/src/app/(dashboard)/[guildUrlName]/components/GuildTabs.tsx index d4b918f9ac..6245a41ed8 100644 --- a/src/app/(dashboard)/[guildUrlName]/components/GuildTabs.tsx +++ b/src/app/(dashboard)/[guildUrlName]/components/GuildTabs.tsx @@ -6,7 +6,7 @@ import { fetchPages } from "@/lib/fetchers"; import type { Schemas } from "@guildxyz/types"; import { PageNavLink } from "./RoleGroupNavLink"; -export const GuildTabs = async ({ guild }: { guild: Schemas["GuildFull"] }) => { +export const GuildTabs = async ({ guild }: { guild: Schemas["Guild"] }) => { const pages = await fetchPages({ guildId: guild.id }); return ( diff --git a/src/app/(dashboard)/explorer/actions.ts b/src/app/(dashboard)/explorer/actions.ts index 0714e4e668..c7f1184f5b 100644 --- a/src/app/(dashboard)/explorer/actions.ts +++ b/src/app/(dashboard)/explorer/actions.ts @@ -7,7 +7,7 @@ export const getGuildSearch = async ({ pageParam, search, }: { pageParam: number; search: string }) => { - return fetchGuildApiData>( + return fetchGuildApiData>( `guild/search?page=${pageParam}&pageSize=${PAGE_SIZE}&search=${search}`, ); }; diff --git a/src/app/(dashboard)/explorer/components/GuildCard.tsx b/src/app/(dashboard)/explorer/components/GuildCard.tsx index 344e8d60a9..7f2901b4ed 100644 --- a/src/app/(dashboard)/explorer/components/GuildCard.tsx +++ b/src/app/(dashboard)/explorer/components/GuildCard.tsx @@ -8,7 +8,7 @@ import { Users } from "@phosphor-icons/react/dist/ssr"; import Link from "next/link"; import type { FunctionComponent } from "react"; -export const GuildCard: FunctionComponent<{ guild: Schemas["GuildFull"] }> = ({ +export const GuildCard: FunctionComponent<{ guild: Schemas["Guild"] }> = ({ guild, }) => { return ( diff --git a/src/app/(dashboard)/explorer/page.tsx b/src/app/(dashboard)/explorer/page.tsx index 24825f186f..e429bbab0e 100644 --- a/src/app/(dashboard)/explorer/page.tsx +++ b/src/app/(dashboard)/explorer/page.tsx @@ -19,7 +19,7 @@ import { ACTIVE_SECTION } from "./constants"; const getAssociatedGuilds = async () => { const { userId } = await tryGetParsedToken(); - return fetchGuildApiData>( + return fetchGuildApiData>( `guild/search?page=1&pageSize=${Number.MAX_SAFE_INTEGER}&sortBy=name&reverse=false&customQuery=@owner:{${userId}}`, ); }; @@ -108,7 +108,7 @@ async function AssociatedGuildsSection() { } async function AssociatedGuilds() { - let associatedGuilds: Schemas["GuildFull"][]; + let associatedGuilds: Schemas["Guild"][]; try { associatedGuilds = (await getAssociatedGuilds()).items; } catch { diff --git a/src/lib/fetchers.ts b/src/lib/fetchers.ts index 5247218483..6f15e7399e 100644 --- a/src/lib/fetchers.ts +++ b/src/lib/fetchers.ts @@ -11,7 +11,7 @@ export const fetchGuildLeave = async ({ guildId }: { guildId: string }) => { }; export const fetchGuild = async ({ idLike }: WithIdLike) => { - return fetchGuildApiData( + return fetchGuildApiData( `guild/${resolveIdLikeRequest(idLike)}`, ); }; @@ -31,7 +31,7 @@ export const fetchEntity = async ({ export const fetchUser = async () => { const { userId } = await tryGetParsedToken(); - return fetchEntity({ + return fetchEntity({ entity: "user", idLike: userId, }); @@ -39,7 +39,7 @@ export const fetchUser = async () => { export const fetchPages = async ({ guildId }: { guildId: string }) => { const guild = await fetchGuild({ idLike: guildId }); - return fetchGuildApiData("page/batch", { + return fetchGuildApiData("page/batch", { method: "POST", body: JSON.stringify({ ids: guild.pages?.map((p) => p.pageId!) ?? [] }), }); diff --git a/src/lib/options.ts b/src/lib/options.ts index 1901a057d0..4ac8c44e38 100644 --- a/src/lib/options.ts +++ b/src/lib/options.ts @@ -15,14 +15,14 @@ export const entityOptions = ({ }; export const guildOptions = ({ idLike }: { idLike: string }) => { - return entityOptions({ + return entityOptions({ entity: "guild", idLike, }); }; export const userOptions = () => { - return queryOptions({ + return queryOptions({ queryKey: ["user"], queryFn: () => fetchUser(), });