Skip to content

Commit

Permalink
[Fix] #14 상세 페이지 코드 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
hyeiis committed Feb 3, 2024
1 parent 3e9cfd5 commit 2f1d0b2
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ export default function DetailContent(boardId: BOARDID) {
const hashTagRegex = /#[^\s#]+/g
const splitContent = content.split(hashTagRegex)
const matchedHashTags = content.match(hashTagRegex) || []
// -> 3줄 util로 빼주기

const result: (string | JSX.Element)[] = []
const result: JSX.Element[] = []

splitContent.forEach((current, index) => {
const replacedContent = current
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { usePathname, useRouter } from 'next/navigation'
import DetailEtc from '../Molecules/DetailEtc'
import DetailProfile from '../Molecules/DetailProfile'
import Swal from 'sweetalert2'
import { deleteAlert } from '@/utils/function/utilFunction'

export default function DetailProfileOrganism({ boardId }: BOARDID) {
const router = useRouter()
Expand All @@ -14,21 +15,7 @@ export default function DetailProfileOrganism({ boardId }: BOARDID) {
}

const handleDelete = () => {
Swal.fire({
title: '게시물 삭제',
text: '게시물을 삭제하시겠습니까?',
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: '삭제',
cancelButtonText: '취소',
customClass: {
popup: 'w-[275px] font-NanumSquareRound',
icon: 'size-13',
title: 'text-xl',
},
}).then(async result => {
deleteAlert().then(async result => {
if (result.isConfirmed) {
try {
const response = await fetch(
Expand Down
3 changes: 3 additions & 0 deletions weatherfit_refactoring/src/app/not-found.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function NotFound() {
return <div>잘못된 접근입니다.</div>
}
20 changes: 20 additions & 0 deletions weatherfit_refactoring/src/utils/function/utilFunction.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import Swal from 'sweetalert2'

export const extractHashtags = (content: string): string[] => {
const regex = /#(\S+)/g // # 다음에 공백이 아닌 모든 문자를 해시태그로 간주하는 정규식
const matches = content.match(regex)
Expand Down Expand Up @@ -27,3 +29,21 @@ export const handleNext = (
else return prevIndex + 1
})
}

export const deleteAlert = () => {
return Swal.fire({
title: '게시물 삭제',
text: '게시물을 삭제하시겠습니까?',
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: '삭제',
cancelButtonText: '취소',
customClass: {
popup: 'w-[275px] font-NanumSquareRound',
icon: 'size-13',
title: 'text-xl',
},
})
}

0 comments on commit 2f1d0b2

Please sign in to comment.