Skip to content

Commit

Permalink
chore: update types package
Browse files Browse the repository at this point in the history
  • Loading branch information
dominik-stumpf committed Dec 4, 2024
1 parent 34a9177 commit b8e12cd
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 30 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
29 changes: 13 additions & 16 deletions src/app/(dashboard)/[guildUrlName]/[pageUrlName]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ const GuildPage = async ({
params,
}: DynamicRoute<{ pageUrlName: string; guildUrlName: string }>) => {
const { pageUrlName, guildUrlName } = await params;
const guild = await fetchGuildApiData<Schemas["GuildFull"]>(
const guild = await fetchGuildApiData<Schemas["Guild"]>(
`guild/urlName/${guildUrlName}`,
);
const pages = await fetchGuildApiData<Schemas["PageFull"][]>("page/batch", {
const pages = await fetchGuildApiData<Schemas["Page"][]>("page/batch", {
method: "POST",
body: JSON.stringify({ ids: guild.pages?.map((p) => p.pageId!) ?? [] }),

Check warning on line 18 in src/app/(dashboard)/[guildUrlName]/[pageUrlName]/page.tsx

View workflow job for this annotation

GitHub Actions / quality-assurance

lint/style/noNonNullAssertion

Forbidden non-null assertion.
});
const page = pages.find((p) => p.urlName === pageUrlName)!;

Check warning on line 20 in src/app/(dashboard)/[guildUrlName]/[pageUrlName]/page.tsx

View workflow job for this annotation

GitHub Actions / quality-assurance

lint/style/noNonNullAssertion

Forbidden non-null assertion.
const roles = await fetchGuildApiData<Schemas["RoleFull"][]>("role/batch", {
const roles = await fetchGuildApiData<Schemas["Role"][]>("role/batch", {
method: "POST",
body: JSON.stringify({
ids: page.roles?.map((r) => r.roleId!) ?? [],

Check warning on line 24 in src/app/(dashboard)/[guildUrlName]/[pageUrlName]/page.tsx

View workflow job for this annotation

GitHub Actions / quality-assurance

lint/style/noNonNullAssertion

Forbidden non-null assertion.
Expand All @@ -34,19 +34,16 @@ const GuildPage = async ({
);
};

const RoleCard = async ({ role }: { role: Schemas["RoleFull"] }) => {
const rewards = await fetchGuildApiData<Schemas["RewardFull"][]>(
"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<Schemas["Reward"][]>("reward/batch", {
method: "POST",
body: JSON.stringify({
ids: role.rewards?.map((r) => r.rewardId!) ?? [],

Check warning on line 41 in src/app/(dashboard)/[guildUrlName]/[pageUrlName]/page.tsx

View workflow job for this annotation

GitHub Actions / quality-assurance

lint/style/noNonNullAssertion

Forbidden non-null assertion.
}),
headers: {
"Content-Type": "application/json",
},
);
});

return (
<Card className="flex flex-col md:flex-row" key={role.id}>
Expand Down Expand Up @@ -89,7 +86,7 @@ const RoleCard = async ({ role }: { role: Schemas["RoleFull"] }) => {
);
};

const Reward = ({ reward }: { reward: Schemas["RewardFull"] }) => {
const Reward = ({ reward }: { reward: Schemas["Reward"] }) => {
return (
<div className="border-b p-4 last:border-b-0">
<div className="mb-2 font-medium">{reward.name}</div>
Expand Down
6 changes: 3 additions & 3 deletions src/app/(dashboard)/[guildUrlName]/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const fetchGuildLeave = async ({ guildId }: { guildId: string }) => {
};

export const fetchGuild = async ({ idLike }: WithIdLike) => {
return fetchGuildApiData<Schemas["GuildFull"]>(
return fetchGuildApiData<Schemas["Guild"]>(
`guild/${resolveIdLikeRequest(idLike)}`,
);
};
Expand All @@ -31,15 +31,15 @@ export const fetchEntity = async <Data = object, Error = ErrorLike>({

export const fetchUser = async () => {
const { userId } = await tryGetParsedToken();
return fetchEntity<Schemas["UserFull"]>({
return fetchEntity<Schemas["User"]>({
entity: "user",
idLike: userId,
});
};

export const fetchPages = async ({ guildId }: { guildId: string }) => {
const guild = await fetchGuild({ idLike: guildId });
return fetchGuildApiData<Schemas["PageFull"][]>("page/batch", {
return fetchGuildApiData<Schemas["Page"][]>("page/batch", {
method: "POST",
body: JSON.stringify({ ids: guild.pages?.map((p) => p.pageId!) ?? [] }),

Check warning on line 44 in src/app/(dashboard)/[guildUrlName]/actions.ts

View workflow job for this annotation

GitHub Actions / quality-assurance

lint/style/noNonNullAssertion

Forbidden non-null assertion.
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
2 changes: 1 addition & 1 deletion src/app/(dashboard)/explorer/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const getGuildSearch = async ({
pageParam,
search,
}: { pageParam: number; search: string }) => {
return fetchGuildApiData<PaginatedResponse<Schemas["GuildFull"]>>(
return fetchGuildApiData<PaginatedResponse<Schemas["Guild"]>>(
`guild/search?page=${pageParam}&pageSize=${PAGE_SIZE}&search=${search}`,
);
};
2 changes: 1 addition & 1 deletion src/app/(dashboard)/explorer/components/GuildCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
4 changes: 2 additions & 2 deletions src/app/(dashboard)/explorer/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { ACTIVE_SECTION } from "./constants";
const getAssociatedGuilds = async () => {
const { userId } = await tryGetParsedToken();

return fetchGuildApiData<PaginatedResponse<Schemas["GuildFull"]>>(
return fetchGuildApiData<PaginatedResponse<Schemas["Guild"]>>(
`guild/search?page=1&pageSize=${Number.MAX_SAFE_INTEGER}&sortBy=name&reverse=false&customQuery=@owner:{${userId}}`,
);
};
Expand Down Expand Up @@ -108,7 +108,7 @@ async function AssociatedGuildsSection() {
}

async function AssociatedGuilds() {
let associatedGuilds: Schemas["GuildFull"][];
let associatedGuilds: Schemas["Guild"][];
try {
associatedGuilds = (await getAssociatedGuilds()).items;
} catch {
Expand Down
6 changes: 3 additions & 3 deletions src/lib/fetchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const fetchGuildLeave = async ({ guildId }: { guildId: string }) => {
};

export const fetchGuild = async ({ idLike }: WithIdLike) => {
return fetchGuildApiData<Schemas["GuildFull"]>(
return fetchGuildApiData<Schemas["Guild"]>(
`guild/${resolveIdLikeRequest(idLike)}`,
);
};
Expand All @@ -31,15 +31,15 @@ export const fetchEntity = async <Data = object, Error = ErrorLike>({

export const fetchUser = async () => {
const { userId } = await tryGetParsedToken();
return fetchEntity<Schemas["UserFull"]>({
return fetchEntity<Schemas["User"]>({
entity: "user",
idLike: userId,
});
};

export const fetchPages = async ({ guildId }: { guildId: string }) => {
const guild = await fetchGuild({ idLike: guildId });
return fetchGuildApiData<Schemas["PageFull"][]>("page/batch", {
return fetchGuildApiData<Schemas["Page"][]>("page/batch", {
method: "POST",
body: JSON.stringify({ ids: guild.pages?.map((p) => p.pageId!) ?? [] }),

Check warning on line 44 in src/lib/fetchers.ts

View workflow job for this annotation

GitHub Actions / quality-assurance

lint/style/noNonNullAssertion

Forbidden non-null assertion.
});
Expand Down
4 changes: 2 additions & 2 deletions src/lib/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ export const entityOptions = <Data = object, Error = ErrorLike>({
};

export const guildOptions = ({ idLike }: { idLike: string }) => {
return entityOptions<Schemas["GuildFull"]>({
return entityOptions<Schemas["Guild"]>({
entity: "guild",
idLike,
});
};

export const userOptions = () => {
return queryOptions<Schemas["UserFull"]>({
return queryOptions<Schemas["User"]>({
queryKey: ["user"],
queryFn: () => fetchUser(),
});
Expand Down

0 comments on commit b8e12cd

Please sign in to comment.