-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Guild Member Setting 페이지 #275
Changes from 30 commits
61d829f
fc9c338
3d8d475
27068ff
7f2a686
c67f5a6
205cdab
ee1e625
90ee5ba
76fddb8
0aa3543
cb9b5dd
5e2799e
9bb8712
40a80f6
9a3cfb9
315b3fe
7c7c3e1
b2fd77d
f47351f
caa8ca0
f98c850
c6fe182
724160f
9ad6531
104b2b0
f205dbf
4749ba6
7cecdf2
0cac774
91ca9e0
911b1b8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import GuildCreate from '../../_components/GuildCreate'; | ||
import GuildModal from '../GuildModal'; | ||
|
||
export default function GuildCreateModal() { | ||
return ( | ||
<GuildModal title="Create Guild"> | ||
<GuildCreate /> | ||
</GuildModal> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
'use client'; | ||
|
||
import { css } from '_panda/css'; | ||
import { inboxQueries } from '@gitanimals/react-query'; | ||
import { Dialog } from '@gitanimals/ui-panda'; | ||
import { useQueryClient } from '@tanstack/react-query'; | ||
|
||
import { useRouter } from '@/i18n/routing'; | ||
import { joinGuildAction } from '@/serverActions/guild'; | ||
|
||
import { GuildJoinPetSelectDialog } from '../../../../_components/GuildPetSelectDialog'; | ||
import GuildModal from '../../../GuildModal'; | ||
|
||
export default function GuildJoinModal({ params }: { params: { id: string } }) { | ||
const queryClient = useQueryClient(); | ||
const router = useRouter(); | ||
|
||
const submitJoinGuild = async (selectPersona: string) => { | ||
try { | ||
await joinGuildAction({ | ||
guildId: params.id, | ||
personaId: selectPersona, | ||
}); | ||
|
||
queryClient.invalidateQueries({ queryKey: inboxQueries.allKey() }); | ||
router.replace(`/guild`); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 에러 처리 및 사용자 피드백 개선 필요 현재 에러가 발생했을 때 콘솔에만 출력되고 있습니다. 사용자에게 적절한 피드백을 제공해야 합니다. + import { toast } from '@gitanimals/ui-panda';
const submitJoinGuild = async (selectPersona: string) => {
try {
await joinGuildAction({
guildId: params.id,
personaId: selectPersona,
});
queryClient.invalidateQueries({ queryKey: inboxQueries.allKey() });
+ toast.success('길드 가입이 완료되었습니다.');
router.replace(`/guild`);
} catch (error) {
- console.error(error);
+ toast.error('길드 가입 중 오류가 발생했습니다. 다시 시도해 주세요.');
+ throw error;
}
};
|
||
|
||
return ( | ||
<GuildModal> | ||
<div> | ||
<Dialog.Title className={dialogTitleStyle}>Choose your pet</Dialog.Title> | ||
<p className={dialogDescriptionStyle}>If you choose a pet, it will be shown in the guild image.</p> | ||
</div> | ||
<GuildJoinPetSelectDialog onSubmit={submitJoinGuild} /> | ||
</GuildModal> | ||
); | ||
} | ||
|
||
const dialogTitleStyle = css({}); | ||
|
||
const dialogDescriptionStyle = css({ | ||
textStyle: 'glyph20.regular', | ||
color: 'white.white_50', | ||
mt: 3, | ||
textAlign: 'center', | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Button } from '@gitanimals/ui-panda'; | ||
|
||
import { Link } from '@/i18n/routing'; | ||
|
||
import { GuildDetail } from '../../../_components/GuildDetail'; | ||
import GuildModal from '../../GuildModal'; | ||
|
||
export default function GuildDetailModal({ params }: { params: { id: string } }) { | ||
return ( | ||
<GuildModal> | ||
<GuildDetail guildId={params.id} /> | ||
<Link href={`/guild/detail/${params.id}/join`} style={{ margin: 'auto' }}> | ||
<Button w="100px">Join</Button> | ||
</Link> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Join 버튼 UX 개선 필요
다음과 같은 개선을 제안합니다: - <Link href={`/guild/detail/${params.id}/join`} style={{ margin: 'auto' }}>
- <Button w="100px">Join</Button>
+ <Link href={`/guild/detail/${params.id}/join`} style={{ margin: 'auto', width: 'fit-content' }}>
+ <Button
+ minW="100px"
+ isLoading={isLoading}
+ loadingText="Joining..."
+ >
+ {t('join')}
+ </Button>
</Link>
|
||
</GuildModal> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
'use client'; | ||
|
||
import { type PropsWithChildren, useEffect, useState } from 'react'; | ||
import { css, cx } from '_panda/css'; | ||
import { Dialog } from '@gitanimals/ui-panda'; | ||
|
||
import { usePathname, useRouter } from '@/i18n/routing'; | ||
import { customScrollHorizontalStyle } from '@/styles/scrollStyle'; | ||
|
||
export default function GuildModal({ children, title }: PropsWithChildren<{ title?: string }>) { | ||
const router = useRouter(); | ||
const pathname = usePathname(); | ||
|
||
const [isOpen, setIsOpen] = useState(false); | ||
|
||
const onClose = () => { | ||
router.back(); | ||
}; | ||
|
||
useEffect(() => { | ||
if (!isOpen) { | ||
setIsOpen(true); | ||
} else { | ||
setIsOpen(false); | ||
} | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [pathname]); | ||
|
||
return ( | ||
<Dialog open={isOpen} onOpenChange={onClose}> | ||
<Dialog.Content size="large" className={dialogContentStyle}> | ||
{title && <Dialog.Title>{title}</Dialog.Title>} | ||
{children} | ||
</Dialog.Content> | ||
</Dialog> | ||
); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion 베이스 모달 컴포넌트 추출 필요
베이스 모달 컴포넌트를 만들고 이를 상속받아 사용하는 구조로 변경을 제안드립니다. |
||
|
||
const dialogContentStyle = cx( | ||
css({ | ||
height: 'fit-content', | ||
gap: 8, | ||
overflowY: 'auto', | ||
}), | ||
customScrollHorizontalStyle, | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function GuildModal() { | ||
return null; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { redirect } from 'next/navigation'; | ||
import { checkIsLeader, getGuildBackgrounds, getGuildById, getGuildIcons } from '@gitanimals/api'; | ||
import { DialogTitle } from '@gitanimals/ui-panda'; | ||
|
||
import { InterceptingDialog } from '@/components/InterceptingDialog'; | ||
|
||
import { GuildSetting } from '../../setting/GuildSetting'; | ||
|
||
export default async function GuildSettingModal({ params }: { params: { id: string } }) { | ||
const isLeader = await checkIsLeader(params.id); | ||
|
||
const icons = await getGuildIcons(); | ||
const backgrounds = await getGuildBackgrounds(); | ||
const data = await getGuildById({ guildId: params.id }); | ||
|
||
if (!isLeader) { | ||
redirect(`/guild/${params.id}`); | ||
} | ||
|
||
return ( | ||
<InterceptingDialog> | ||
<DialogTitle>Guild Setting</DialogTitle> | ||
<GuildSetting icons={icons} backgrounds={backgrounds} guildId={params.id} initialData={data} /> | ||
</InterceptingDialog> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function GuildModal() { | ||
return null; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
제목을 국제화(i18n)하는 것이 좋겠습니다.
"Create Guild"와 같은 문자열은 국제화가 필요합니다. 다른 파일들에서 사용된 것처럼 메시지 파일을 통해 다국어를 지원하는 것이 좋겠습니다.
예시 구현:
그리고 메시지 파일에 다음 항목을 추가해주세요: