chore: better Prettier config for easier reviews
This commit is contained in:
@ -1,17 +1,17 @@
|
||||
import Image from 'next/image'
|
||||
import { useRouter } from 'next/router'
|
||||
import { useState } from 'react'
|
||||
import useTranslation from 'next-translate/useTranslation'
|
||||
import classNames from 'clsx'
|
||||
import axios from 'axios'
|
||||
import Image from "next/image"
|
||||
import { useRouter } from "next/router"
|
||||
import { useState } from "react"
|
||||
import useTranslation from "next-translate/useTranslation"
|
||||
import classNames from "clsx"
|
||||
import axios from "axios"
|
||||
|
||||
import { Emoji } from '../../Emoji'
|
||||
import { ConfirmPopup } from '../ConfirmPopup'
|
||||
import { Emoji } from "../../Emoji"
|
||||
import { ConfirmPopup } from "../ConfirmPopup"
|
||||
import type {
|
||||
GuildPublic as GuildPublicType,
|
||||
GuildWithDefaultChannelId
|
||||
} from '../../../models/Guild'
|
||||
import { useAuthentication } from '../../../tools/authentication'
|
||||
GuildWithDefaultChannelId,
|
||||
} from "../../../models/Guild"
|
||||
import { useAuthentication } from "../../../tools/authentication"
|
||||
|
||||
export interface GuildPublicProps {
|
||||
guild: GuildPublicType
|
||||
@ -36,70 +36,70 @@ export const GuildPublic: React.FC<GuildPublicProps> = (props) => {
|
||||
guild: GuildWithDefaultChannelId
|
||||
}>(`/guilds/${guild.id}/members/join`)
|
||||
await router.push(
|
||||
`/application/${guild.id}/${data.guild.defaultChannelId}`
|
||||
`/application/${guild.id}/${data.guild.defaultChannelId}`,
|
||||
)
|
||||
} catch (error) {
|
||||
if (
|
||||
axios.isAxiosError(error) &&
|
||||
error.response?.status === 400 &&
|
||||
typeof error?.response?.data.defaultChannelId === 'number'
|
||||
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')
|
||||
await router.push("/application")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className='relative h-80 overflow-hidden rounded border border-gray-500 shadow-lg transition duration-200 ease-in-out hover:-translate-y-2 hover:shadow-none dark:border-gray-700'>
|
||||
<div className="relative h-80 overflow-hidden rounded border border-gray-500 shadow-lg transition duration-200 ease-in-out hover:-translate-y-2 hover:shadow-none dark:border-gray-700">
|
||||
<div
|
||||
className={classNames(
|
||||
'flex h-full cursor-pointer flex-col items-center justify-center p-4 pt-8 transition duration-200 ease-in-out',
|
||||
{ '-translate-x-full': isConfirmed }
|
||||
"flex h-full cursor-pointer flex-col items-center justify-center p-4 pt-8 transition duration-200 ease-in-out",
|
||||
{ "-translate-x-full": isConfirmed },
|
||||
)}
|
||||
onClick={handleIsConfirmed}
|
||||
>
|
||||
<Image
|
||||
quality={100}
|
||||
className='rounded-full'
|
||||
className="rounded-full"
|
||||
src={
|
||||
guild.icon != null ? guild.icon : '/images/data/guild-default.png'
|
||||
guild.icon != null ? guild.icon : "/images/data/guild-default.png"
|
||||
}
|
||||
alt='logo'
|
||||
alt="logo"
|
||||
width={80}
|
||||
height={80}
|
||||
/>
|
||||
<div className='m-2 mt-6 w-full px-4 text-center'>
|
||||
<div className="m-2 mt-6 w-full px-4 text-center">
|
||||
<h3
|
||||
data-cy='guild-name'
|
||||
className='center mb-2 w-full truncate text-xl font-bold'
|
||||
data-cy="guild-name"
|
||||
className="center mb-2 w-full truncate text-xl font-bold"
|
||||
>
|
||||
{guild.name}
|
||||
</h3>
|
||||
<p className='break-words'>
|
||||
<p className="break-words">
|
||||
{guild.description != null ? (
|
||||
guild.description
|
||||
) : (
|
||||
<span className='flex h-full items-center justify-center opacity-40 dark:opacity-20'>
|
||||
<Emoji value=':eyes:' size={25} />
|
||||
<span className='ml-2'>{t('application:nothing-here')}</span>
|
||||
<span className="flex h-full items-center justify-center opacity-40 dark:opacity-20">
|
||||
<Emoji value=":eyes:" size={25} />
|
||||
<span className="ml-2">{t("application:nothing-here")}</span>
|
||||
</span>
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
<p className='mt-auto flex flex-col text-green-800 dark:text-green-400'>
|
||||
{guild.membersCount} {t('application:members')}
|
||||
<p className="mt-auto flex flex-col text-green-800 dark:text-green-400">
|
||||
{guild.membersCount} {t("application:members")}
|
||||
</p>
|
||||
</div>
|
||||
<ConfirmPopup
|
||||
title={`${t('application:join-the-guild')} ?`}
|
||||
title={`${t("application:join-the-guild")} ?`}
|
||||
className={classNames(
|
||||
'w-ful h-ful translate-x- absolute left-full top-1/2 flex h-full w-full -translate-y-1/2 flex-col items-center justify-center rounded-2xl transition-all',
|
||||
"w-ful h-ful translate-x- absolute left-full top-1/2 flex h-full w-full -translate-y-1/2 flex-col items-center justify-center rounded-2xl transition-all",
|
||||
{
|
||||
'!left-0': isConfirmed
|
||||
}
|
||||
"!left-0": isConfirmed,
|
||||
},
|
||||
)}
|
||||
handleYes={handleYes}
|
||||
handleNo={handleIsConfirmed}
|
||||
|
@ -1,17 +1,17 @@
|
||||
import useTranslation from 'next-translate/useTranslation'
|
||||
import { useEffect, useState } from 'react'
|
||||
import InfiniteScroll from 'react-infinite-scroll-component'
|
||||
import useTranslation from "next-translate/useTranslation"
|
||||
import { useEffect, useState } from "react"
|
||||
import InfiniteScroll from "react-infinite-scroll-component"
|
||||
|
||||
import { useAuthentication } from '../../../tools/authentication'
|
||||
import type { GuildPublic as GuildPublicType } from '../../../models/Guild'
|
||||
import { Loader } from '../../design/Loader'
|
||||
import { GuildPublic } from './GuildPublic'
|
||||
import { usePagination } from '../../../hooks/usePagination'
|
||||
import type { SocketData } from '../../../tools/handleSocketData'
|
||||
import { handleSocketData } from '../../../tools/handleSocketData'
|
||||
import { useAuthentication } from "../../../tools/authentication"
|
||||
import type { GuildPublic as GuildPublicType } from "../../../models/Guild"
|
||||
import { Loader } from "../../design/Loader"
|
||||
import { GuildPublic } from "./GuildPublic"
|
||||
import { usePagination } from "../../../hooks/usePagination"
|
||||
import type { SocketData } from "../../../tools/handleSocketData"
|
||||
import { handleSocketData } from "../../../tools/handleSocketData"
|
||||
|
||||
export const JoinGuildsPublic: React.FC = () => {
|
||||
const [search, setSearch] = useState('')
|
||||
const [search, setSearch] = useState("")
|
||||
|
||||
const { authentication } = useAuthentication()
|
||||
const { t } = useTranslation()
|
||||
@ -19,19 +19,19 @@ export const JoinGuildsPublic: React.FC = () => {
|
||||
const { items, hasMore, nextPage, resetPagination, setItems } =
|
||||
usePagination<GuildPublicType>({
|
||||
api: authentication.api,
|
||||
url: '/guilds/public'
|
||||
url: "/guilds/public",
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
authentication?.socket?.on(
|
||||
'guilds',
|
||||
"guilds",
|
||||
(data: SocketData<GuildPublicType>) => {
|
||||
handleSocketData({ data, setItems })
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
return () => {
|
||||
authentication?.socket?.off('guilds')
|
||||
authentication?.socket?.off("guilds")
|
||||
}
|
||||
}, [authentication.socket, setItems])
|
||||
|
||||
@ -45,23 +45,23 @@ export const JoinGuildsPublic: React.FC = () => {
|
||||
}
|
||||
|
||||
return (
|
||||
<div className='flex h-full w-full flex-col transition-all'>
|
||||
<div className="flex h-full w-full flex-col transition-all">
|
||||
<input
|
||||
data-cy='search-guild-input'
|
||||
data-cy="search-guild-input"
|
||||
onChange={handleChange}
|
||||
className='mx-auto my-6 mt-16 w-10/12 rounded-md border border-gray-500 bg-white p-3 dark:border-gray-700 dark:bg-[#3B3B3B] sm:w-8/12 md:w-6/12 lg:w-5/12'
|
||||
type='search'
|
||||
name='search-guild'
|
||||
placeholder={`🔎 ${t('application:search')}...`}
|
||||
className="mx-auto my-6 mt-16 w-10/12 rounded-md border border-gray-500 bg-white p-3 dark:border-gray-700 dark:bg-[#3B3B3B] sm:w-8/12 md:w-6/12 lg:w-5/12"
|
||||
type="search"
|
||||
name="search-guild"
|
||||
placeholder={`🔎 ${t("application:search")}...`}
|
||||
/>
|
||||
<div className='w-full p-12'>
|
||||
<div className="w-full p-12">
|
||||
<InfiniteScroll
|
||||
className='guilds-public-list relative mx-auto grid max-w-[1400px] grid-cols-[repeat(auto-fill,_minmax(20em,_1fr))] gap-8 !overflow-visible'
|
||||
className="guilds-public-list relative mx-auto grid max-w-[1400px] grid-cols-[repeat(auto-fill,_minmax(20em,_1fr))] gap-8 !overflow-visible"
|
||||
dataLength={items.length}
|
||||
next={nextPage}
|
||||
scrollableTarget='application-page-content'
|
||||
scrollableTarget="application-page-content"
|
||||
hasMore={hasMore}
|
||||
loader={<Loader className='absolute left-1/2 -translate-x-1/2' />}
|
||||
loader={<Loader className="absolute left-1/2 -translate-x-1/2" />}
|
||||
>
|
||||
{items.map((guild) => {
|
||||
return <GuildPublic guild={guild} key={guild.id} />
|
||||
|
@ -1 +1 @@
|
||||
export * from './JoinGuildsPublic'
|
||||
export * from "./JoinGuildsPublic"
|
||||
|
Reference in New Issue
Block a user