Skip to content

Commit

Permalink
fix: verification gate error icon
Browse files Browse the repository at this point in the history
Signed-off-by: GitHub <[email protected]>
  • Loading branch information
virtual-designer authored Aug 27, 2024
1 parent 9b081d7 commit 4a496da
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
33 changes: 19 additions & 14 deletions src/app/(main)/verify/guilds/[id]/challenge/onboarding/page.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
import PageExpired from "@/app/page-expired";
import GuildVerificationGate from "@/components/GuildVerificationGate/GuildVerificationGate";
import { Guild } from "@/types/Guild";
import { ServerComponentProps } from "@/types/ServerComponentProps";
import axios from "axios";
import { Metadata } from "next";
import { notFound } from "next/navigation";
import { cache } from "react";

const getGuildCached = cache(async (id: string) => {
return [{ id: "01", name: "Test Server", icon: null }, null] as const;

// try {
// const guild = await getGuild(id);
// return [
// guild,
// guild === null ? new Error("404 Not Found") : null,
// ] as const;
// } catch (error) {
// return [null, error] as const;
// }
const getVerificationInfo = cache(async (guildId: string, memberId: string) => {
try {
const info = await axios.get(
`${process.env.NEXT_PUBLIC_API_URL}/guilds/${encodeURIComponent(guildId)}/members/${encodeURIComponent(memberId)}/verify`,
);
return [info.data?.guild as Guild, null] as const;
} catch (error) {
return [null, error] as const;
}
});

export async function generateMetadata({
Expand All @@ -33,7 +32,9 @@ export async function generateMetadata({
};
}

const [guild, error] = id ? await getGuildCached(id) : [null, true];
const [guild, error] = id
? await getVerificationInfo(id, userId)
: [null, true];

if (!guild || error) {
return {
Expand Down Expand Up @@ -62,7 +63,11 @@ export default async function VerifyOnboardingPage({
return <PageExpired />;
}

const [guild, error] = id ? await getGuildCached(id) : [null, true];
const [guild, error] = id
? await getVerificationInfo(id, userId)
: [null, true];

console.log(guild, error);

if (!guild || error) {
notFound();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { useMutation } from "@tanstack/react-query";
import { AxiosError } from "axios";
import { FC, ReactNode, useEffect, useRef, useState } from "react";
import { BsCheckCircle } from "react-icons/bs";
import { HiOutlineExclamationCircle } from "react-icons/hi2";

type GuildVerificationGateProps = {
guild: Guild;
Expand Down Expand Up @@ -122,7 +121,6 @@ const GuildVerificationGate: FC<GuildVerificationGateProps> = ({
)}
{isError && (
<div className="flex items-center gap-1 pb-2">
<HiOutlineExclamationCircle className="text-red-500 text-xl" />
<p className="text-red-500 text-sm text-center">
{(error instanceof AxiosError
? error?.response?.data?.error
Expand Down

0 comments on commit 4a496da

Please sign in to comment.