Skip to content

Commit

Permalink
✨ Feat : 로그인 상태일 때 마이팀 자동 선택 기능 추가
Browse files Browse the repository at this point in the history
✨ Feat : 로그인 상태일 때 마이팀 자동 선택 기능 추가
  • Loading branch information
june960427 authored Dec 9, 2024
2 parents b0e4235 + 4897baa commit 874cdbd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
9 changes: 8 additions & 1 deletion src/pages/GoodsListPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@ import { QUERY_KEY } from '@apis/queryClient'
import PillButton from '@components/PillButton'
import { useInView } from 'react-intersection-observer'
import { useTopRef } from '@hooks/useTopRef'
import { kboTeamList } from '@constants/kboInfo'

const CATEGORY_LIST = ['전체', '유니폼', '모자', '의류', '잡화', '기념상품']

const GoodsListPage = () => {
const [selectedTeam, setSelectedTeam] = useState(0)
const initialTeam = () => {
const token = localStorage.getItem('token')
const teamId = localStorage.getItem('teamId')
return token && teamId ? Number(teamId) : kboTeamList[0].id
}

const [selectedTeam, setSelectedTeam] = useState<number>(initialTeam)
const [selectedCategory, setSelectedCategory] = useState('전체')

const { data, fetchNextPage, hasNextPage, isFetchingNextPage } =
Expand Down
8 changes: 7 additions & 1 deletion src/pages/MainPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ import TeamSelectSection from '@components/TeamSelectSection'
import { kboTeamList } from '@constants/kboInfo'

const MainPage = () => {
const [selectedTeam, setSelectedTeam] = useState<number>(kboTeamList[0].id)
const initialTeam = () => {
const token = localStorage.getItem('token')
const teamId = localStorage.getItem('teamId')
return token && teamId ? Number(teamId) : kboTeamList[0].id
}

const [selectedTeam, setSelectedTeam] = useState<number>(initialTeam)

const handleTeamSelect = (team: number) => {
setSelectedTeam(team)
Expand Down
13 changes: 9 additions & 4 deletions src/pages/MateListPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
FilterSelectOptionWrap,
FilterWrap,
TeamSelectWrap,
FilteredMateList
FilteredMateList,
} from './style'

import PillButton from '@components/PillButton'
Expand All @@ -26,9 +26,14 @@ import { useInView } from 'react-intersection-observer'
import MainMateCard from '@components/MainMateCard'

const MateListPage = () => {
const [selectedTeam, setSelectedTeam] = useState<number | null>(
kboTeamList[0].id,
) // 팀 선택 상태
const initialTeam = () => {
const token = localStorage.getItem('token')
const teamId = localStorage.getItem('teamId')
return token && teamId ? Number(teamId) : kboTeamList[0].id
}

const [selectedTeam, setSelectedTeam] = useState<number | null>(initialTeam)

const { bottomModalRef, handleOpenBottomModal, handleCloseBottomModal } =
useModal()

Expand Down

0 comments on commit 874cdbd

Please sign in to comment.