Skip to content

Commit

Permalink
Feat: Add response when user can't add card
Browse files Browse the repository at this point in the history
  • Loading branch information
SaltySalt77 committed Feb 14, 2024
1 parent ebeff9f commit d9f4c4c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/app/hitchhiking/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import * as style from './hitchhiking.style'
import ArrowDown from '@/icons/ArrowDown'
import useAxiosWithAuth from '@/api/config'
import { getUniqueArray } from '@/utils/getUniqueArray'
import useToast from '@/states/useToast'

const Hitchhiking = () => {
const [page, setPage] = useState<number>(1)
Expand All @@ -20,6 +21,8 @@ const Hitchhiking = () => {
IPostCardHitchhiking[]
>([])

const { openToast } = useToast()

const axiosWithAuth = useAxiosWithAuth()

const { isPc } = useMedia()
Expand Down Expand Up @@ -65,7 +68,13 @@ const Hitchhiking = () => {
}

const addCard = () => {
if (draggedCardList.length === 0) return
if (draggedCardList.length === 0) {
openToast({
message: '되돌아 갈 수 있는 마지막 카드예요.',
severity: 'info',
})
return
}
setCardList((prev: IPostCardHitchhiking[]) => {
prev.push(draggedCardList[draggedCardList.length - 1])
if (cardList.length > 1) prev[prev.length - 2].hasBeenRemoved = false
Expand Down
11 changes: 10 additions & 1 deletion src/app/showcase/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { ICardData } from './panel/types'
import useAuthStore from '@/states/useAuthStore'
import CardContainer from './panel/CardContainer'
import ShowcasePCLayout from './panel/ShowcasePc/ShowcasePcLayout'
import useToast from '@/states/useToast'

const Showcase = () => {
const [page, setPage] = useState<number>(1)
Expand All @@ -26,6 +27,8 @@ const Showcase = () => {
: defaultGetFetcher,
)

const { openToast } = useToast()

useEffect(() => {
if (!isLoading && data?.content) {
setCardList((prev) => {
Expand All @@ -50,7 +53,13 @@ const Showcase = () => {
}

const addCard = () => {
if (draggedCardList.length === 0) return
if (draggedCardList.length === 0) {
openToast({
message: '되돌아 갈 수 있는 마지막 카드예요.',
severity: 'info',
})
return
}
setCardList((prev: ICardData[]) => {
prev.push(draggedCardList[draggedCardList.length - 1])
if (cardList.length > 1) prev[prev.length - 2].hasBeenRemoved = false
Expand Down

0 comments on commit d9f4c4c

Please sign in to comment.