mirror of
https://github.com/MetaFam/TheGame.git
synced 2026-04-24 03:00:09 -04:00
Addressed dan's suggestions
This commit is contained in:
@@ -5,7 +5,7 @@ import { ProfileSection } from 'components/Profile/ProfileSection';
|
||||
import { GuildFragment } from 'graphql/autogen/types';
|
||||
import React, { useMemo } from 'react';
|
||||
import { FaDiscord, FaGithub, FaGlobe, FaTwitter } from 'react-icons/fa';
|
||||
import { getDaoLink } from 'utils/daoHelpers';
|
||||
import { getDAOLink } from 'utils/daoHelpers';
|
||||
|
||||
type Props = {
|
||||
guild: GuildFragment;
|
||||
@@ -15,7 +15,7 @@ export const GuildLinks: React.FC<Props> = ({ guild }) => {
|
||||
const daoHrefs = useMemo(
|
||||
() =>
|
||||
guild.daos.map(
|
||||
(dao) => dao.url || getDaoLink(dao.network, dao.contractAddress),
|
||||
(dao) => dao.url || getDAOLink(dao.network, dao.contractAddress),
|
||||
),
|
||||
[guild],
|
||||
);
|
||||
@@ -89,8 +89,8 @@ export const GuildLinks: React.FC<Props> = ({ guild }) => {
|
||||
<WrapItem key={index}>
|
||||
<PlayerHeroTile title={dao.label || 'DAO'}>
|
||||
<ExternalDaoLink
|
||||
daoUrl={daoHrefs[index]}
|
||||
linkProps={{ _hover: { textDecoration: 'underline' } }}
|
||||
daoURL={daoHrefs[index]}
|
||||
_hover={{ textDecoration: 'underline' }}
|
||||
>
|
||||
<Text fontSize="sm">{dao.contractAddress}</Text>
|
||||
</ExternalDaoLink>
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
GetAdministeredGuildsQuery,
|
||||
GetAdministeredGuildsQueryVariables,
|
||||
GetGuildMetadataQuery,
|
||||
GetGuildMetadataQueryVariables,
|
||||
GetGuildnamesQuery,
|
||||
@@ -65,7 +63,7 @@ export const getGuildMetadata = async (id: string) => {
|
||||
return data?.guild_metadata[0];
|
||||
};
|
||||
|
||||
const getAdministeredGuildsQuery = /* GraphQL */ `
|
||||
export const getAdministeredGuildsQuery = /* GraphQL */ `
|
||||
query GetAdministeredGuilds($id: uuid!) {
|
||||
guild_metadata(where: { creatorId: { _eq: $id } }) {
|
||||
guildId
|
||||
@@ -76,24 +74,6 @@ const getAdministeredGuildsQuery = /* GraphQL */ `
|
||||
}
|
||||
`;
|
||||
|
||||
export const getAdministeredGuilds = async (playerId: string) => {
|
||||
const { data, error } = await client
|
||||
.query<GetAdministeredGuildsQuery, GetAdministeredGuildsQueryVariables>(
|
||||
getAdministeredGuildsQuery,
|
||||
{ id: playerId },
|
||||
)
|
||||
.toPromise();
|
||||
|
||||
if (!data) {
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
return data.guild_metadata.map((gm) => gm.guild);
|
||||
};
|
||||
|
||||
const guildsQuery = /* GraphQL */ `
|
||||
query GetGuilds($limit: Int) {
|
||||
guild(where: { status: { _eq: ACTIVE } }, limit: $limit) {
|
||||
|
||||
@@ -20,7 +20,7 @@ import {
|
||||
} from 'next';
|
||||
import { useRouter } from 'next/router';
|
||||
import Page404 from 'pages/404';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import React, { useEffect, useMemo } from 'react';
|
||||
import { BoxTypes } from 'utils/boxTypes';
|
||||
import { getGuildCoverImageFull } from 'utils/playerHelpers';
|
||||
|
||||
@@ -30,7 +30,6 @@ const GuildPage: React.FC<Props> = ({ guild }) => {
|
||||
const router = useRouter();
|
||||
const { user, fetching } = useUser();
|
||||
const [getGuildsResult, getGuilds] = useGetAdministeredGuildsQuery();
|
||||
const [canEdit, setCanEdit] = useState<boolean>(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (!fetching && user) {
|
||||
@@ -38,16 +37,14 @@ const GuildPage: React.FC<Props> = ({ guild }) => {
|
||||
}
|
||||
}, [fetching, user, getGuilds]);
|
||||
|
||||
useEffect(() => {
|
||||
if (
|
||||
const canEdit = useMemo(
|
||||
() =>
|
||||
user?.id ===
|
||||
getGuildsResult?.data?.guild_metadata.some(
|
||||
(gm) => gm.guildId === guild?.id,
|
||||
)
|
||||
) {
|
||||
setCanEdit(true);
|
||||
}
|
||||
}, [user, getGuildsResult, guild]);
|
||||
),
|
||||
[user, getGuildsResult, guild],
|
||||
);
|
||||
|
||||
// Hidden until implemented
|
||||
// BoxType.GUILD_SKILLS,
|
||||
|
||||
Reference in New Issue
Block a user