import Image from 'next/image' import { useRouter } from 'next/router' import { useState } from 'react' import useTranslation from 'next-translate/useTranslation' import classNames from 'classnames' import axios from 'axios' import { Emoji } from '../../../Emoji' import { ConfirmGuildJoin } from '../../ConfirmGuildJoin' import { GuildPublic as GuildPublicType, GuildWithDefaultChannelId } from '../../../../models/Guild' import { useAuthentication } from '../../../../tools/authentication' export interface GuildPublicProps { guild: GuildPublicType } export const GuildPublic: React.FC = (props) => { const { guild } = props const router = useRouter() const { authentication } = useAuthentication() const [isConfirmed, setIsConfirmed] = useState(false) const { t } = useTranslation() const handleIsConfirmed = (): void => { setIsConfirmed((isConfirmed) => !isConfirmed) } const handleYes = async (): Promise => { try { const { data } = await authentication.api.post<{ guild: GuildWithDefaultChannelId }>(`/guilds/${guild.id}/members/join`) await router.push( `/application/${guild.id}/${data.guild.defaultChannelId}` ) } catch (error) { if ( axios.isAxiosError(error) && error.response?.status === 400 && typeof error.response?.data.defaultChannelId === 'number' ) { const defaultChannelId = error.response.data.defaultChannelId as number await router.push(`/application/${guild.id}/${defaultChannelId}`) } else { await router.push('/application') } } } return (
logo

{guild.name}

{guild.description != null ? ( guild.description ) : ( {t('application:nothing-here')} )}

{guild.membersCount} {t('application:members')}

) }