Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function DeleteModal({ isDelete, onCancel }: Props) {

if (mainData?.is_main === true) {
showSnackbar({
text: '대표 가계부는 삭제할 수 없어요.\n다른 가계부를 먼저 대표로 지정하세요.',
text: '대표 가계부는 삭제할 수 없습니다 \n다른 가계부를 먼저 대표로 지정하시길 바랍니다',
type: 'error'
})
onCancel() // ConfirmModal 닫기
Expand Down
4 changes: 2 additions & 2 deletions src/features/accountbook/setting/utils/exportExcel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function getMappingData(
showSnackbar: ExcelOptions['showSnackbar']
) {
if (!data || data.length === 0) {
showSnackbar({ text: '데이터가 없습니다.', type: 'error' })
showSnackbar({ text: '데이터가 없습니다', type: 'error' })
return []
}

Expand Down Expand Up @@ -99,7 +99,7 @@ export function downloadExcel(
window.location.href = serverUrlFallback
} else {
showSnackbar({
text: '앱 WebView에서는 직접 다운로드가 지원되지 않습니다. 서버 URL을 제공해주세요',
text: '앱 WebView에서는 직접 다운로드가 지원되지 않습니다',
type: 'error'
})
}
Expand Down
2 changes: 1 addition & 1 deletion src/features/detail/service/deleteComment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ export async function deleteComment(deletedId: string) {
const { error } = await supabase.from('comments').delete().eq('id', deletedId)

if (error) {
alert(`삭제 실패: ${error.message}`)
console.error(`삭제 실패: ${error.message}`)
}
}
12 changes: 10 additions & 2 deletions src/features/detail/ui/DetailContents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import ToggleMoreButton from './ToggleMoreButton'
import { useNavigate } from 'react-router'
import { deleteAccountItem } from '@/pages/item/delete/deleteAccountItem'
import { useEffect, useRef } from 'react'
import { useSnackbarStore } from '@/shared/stores/useSnackbarStore'

interface Props {
isArticleToggleOn: boolean
Expand Down Expand Up @@ -43,6 +44,7 @@ export function DetailContents({
}: Props) {
const navigate = useNavigate()
const toggleRef = useRef<HTMLDivElement>(null)
const showSnackbar = useSnackbarStore(state => state.showSnackbar)

useEffect(() => {
const handleClickOutside = (e: MouseEvent) => {
Expand All @@ -61,14 +63,20 @@ export function DetailContents({
const handleDelete = async (id: string) => {
try {
if (noDeleteItem) {
alert('할부 또는 반복 일정은 삭제할 수 없어요.')
showSnackbar({
type: 'error',
text: '할부 또는 반복 일정은 삭제할 수 없습니다'
})
return
}
await deleteAccountItem(id)
navigate(-1)
} catch (error) {
console.error('삭제 에러:', error)
alert('삭제 중 오류가 발생했습니다.')
showSnackbar({
type: 'error',
text: '삭제 중 오류가 발생했습니다'
})
}
}

Expand Down
17 changes: 7 additions & 10 deletions src/features/group/create/hook/useCreateGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,22 @@ export function useCreateGroup() {
if (!user) return

if (isMain === null) {
showSnackbar({ text: '잠시만 기다려주세요...', type: 'info' })
showSnackbar({ text: '잠시만 기다려 주시길 바랍니다', type: 'info' })
return
}

const finalIsMain =
initialIsMain ? true : isMain

const finalIsMain = initialIsMain ? true : isMain

try {

if (!nameInputRef.current?.value || mascot === null) {
showSnackbar({ text: '모든 필드를 입력해주세요', type: 'warning' })
showSnackbar({ text: '모든 필드를 입력해야 합니다', type: 'warning' })
return
}

if (!isPersonal && invitedUsers.length === 0) {
showSnackbar({ text: '초대한 유저가 없습니다.', type: 'warning' })
return
}
showSnackbar({ text: '초대한 유저가 없습니다', type: 'warning' })
return
}

// 기존 대표 가계부 초기화
if (isMain) {
Expand Down Expand Up @@ -99,7 +96,7 @@ export function useCreateGroup() {

// 초기화
if (nameInputRef.current) {
nameInputRef.current.value = ''
nameInputRef.current.value = ''
}

setMascot(1)
Expand Down
7 changes: 5 additions & 2 deletions src/features/group/edit/EditGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,14 @@ function EditGroup() {
}

await fetchGroups(user.id)
showSnackbar({ text: '가계부가 수정되었습니다.', type: 'success' })
showSnackbar({ text: '가계부가 수정되었습니다', type: 'success' })
navigate(`/accountBook/${groupId}/settings`)
} catch (err) {
console.error(err)
alert('수정 중 오류가 발생했습니다.')
showSnackbar({
text: '수정 중 오류가 발생했습니다',
type: 'error'
})
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/features/group/edit/invitation/InviteCompleteBtn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function InviteCompleteBtn({ personal, invitedUsers, groupId, user }: Props) {

if (filteredUsers.length === 0) {
showSnackbar({
text: '이미 초대된 유저입니다.',
text: '이미 초대된 유저입니다',
type: 'warning'
})
return
Expand All @@ -82,7 +82,7 @@ function InviteCompleteBtn({ personal, invitedUsers, groupId, user }: Props) {
}

navigate(`/accountBook/${groupId}/settings`)
showSnackbar({ text: '초대가 완료되었습니다!', type: 'success' })
showSnackbar({ text: '초대가 완료되었습니다', type: 'success' })
}

return (
Expand Down
2 changes: 1 addition & 1 deletion src/features/vote/service/updateVote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export async function getUserVoteData(vote_id: string) {
)
.eq('id', vote_id)
if (error) {
alert(`데이터 불러오기 실패: ${error.message}`)
console.error(`데이터 불러오기 실패: ${error.message}`)
}
return data
}
Expand Down
8 changes: 7 additions & 1 deletion src/features/vote/ui/ResultOption.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import inactiveCharacter from '@/shared/assets/vote/inactiveCharacter.png'
import activeCharacter from '@/shared/assets/vote/activeCharacter.png'
import { motion } from 'framer-motion'
import { tw } from '@/shared/utils/tw'
import { useSnackbarStore } from '@/shared/stores/useSnackbarStore'

interface Props {
selectionText: string
Expand All @@ -26,11 +27,16 @@ export function ResultOption({
optionParticipants,
onSelect
}: Props) {
const showSnackbar = useSnackbarStore(state => state.showSnackbar)

const handleSelect = (voteId: string, optionId: string) => {
if (!isDisabled) {
onSelect(voteId, optionId)
} else {
alert('투표 기간이 종료되어 현재는 참여가 불가능합니다.')
showSnackbar({
type: 'warning',
text: '투표 기간이 종료되어 현재 참여가 불가능합니다'
})
}
}
const percentage =
Expand Down
6 changes: 2 additions & 4 deletions src/features/vote/ui/VoteCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,15 @@ wrap-break-word">
<p>{question}</p>
</div>
{voteOptions &&
voteOptions.map(({ content, id }) => {
voteOptions.map(({ content, id, vote_id }) => {
const isSelected = mySelect?.some(
sel => sel.option_id === id && sel.user_id === userId
)
const optionParticipants =
voteSelections?.filter(sel => sel.option_id === id).length ?? 0
const isDisabled = deadline === '투표 마감'
const isParticipant =
mySelect?.some(sel =>
voteSelections?.some(vs => vs.vote_id === sel.vote_id)
) ?? false
mySelect?.some(sel => vote_id === sel.vote_id) ?? false

return (
<ResultOption
Expand Down
4 changes: 3 additions & 1 deletion src/features/vote/ui/form/VoteQuestion.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useSnackbarStore } from '@/shared/stores/useSnackbarStore'
import { useEffect, useState } from 'react'

interface Props {
Expand All @@ -6,6 +7,7 @@ interface Props {

export function VoteQuestion({ questionRef }: Props) {
const [textLength, setTextLength] = useState(0)
const showSnackbar = useSnackbarStore(state => state.showSnackbar)

useEffect(() => {
if (questionRef.current) {
Expand All @@ -21,7 +23,7 @@ export function VoteQuestion({ questionRef }: Props) {
if (value.length > 50) {
value = value.slice(0, 50)
questionRef.current.value = value
alert('50글자만 작성 가능합니다!')
showSnackbar({ type: 'warning', text: '50글자만 작성 가능합니다' })
}

setTextLength(value.length)
Expand Down
8 changes: 4 additions & 4 deletions src/features/vote/utils/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ export function validateAddVote({
firstOption,
secondOption
}: Props): string | null {
if (!userId) return '사용자 정보가 없습니다.'
if (!userId) return '사용자 정보가 없습니다'
if (!voteTime || !voteTime.starts_at || !voteTime.ends_at)
return '투표 시간을 설정해주세요.'
if (!title || title.trim() === '') return '투표 질문을 입력해야 합니다.'
if (!firstOption || !secondOption) return '모든 선택지를 입력해야 합니다!'
return '투표 시간을 설정해야 합니다'
if (!title || title.trim() === '') return '투표 질문을 입력해야 합니다'
if (!firstOption || !secondOption) return '모든 선택지를 입력해야 합니다'
return null
}
4 changes: 2 additions & 2 deletions src/pages/plan/PlansOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,9 @@ export const PlansOverview = () => {
)
setUpcomingRows(prev => prev.filter(p => p.id !== target.id))
setPastRows(prev => prev.filter(p => p.id !== target.id))
showSnackbar({ text: '삭제됐어요', type: 'success' })
showSnackbar({ text: '삭제 되었습니다', type: 'success' })
} catch {
showSnackbar({ text: '삭제 중 오류가 발생했어요', type: 'error' })
showSnackbar({ text: '삭제 중 오류가 발생했습니다', type: 'error' })
} finally {
setConfirmOpen(false)
setTarget(null)
Expand Down
2 changes: 1 addition & 1 deletion src/shared/components/nav/Nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function Nav() {
? e => {
e.preventDefault()
showSnackbar({
text: '그룹을 먼저 선택해 주세요',
text: '그룹을 먼저 선택해야 합니다',
type: 'error'
})
}
Expand Down
Loading