-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(#85) π» INAE: μ€νλμ μ μ μν κ΄λ¦¬μ λν
μΌ λμμΈ μμ λ° λ¨Έμ§
(#82) π¨ design: λ λλ§ κ΄λ ¨ λν μΌ λμμΈ μμ Merge pull request #85 from KUSITMS-30th-TEAM-A/design/#82-detailDesignRendering
- Loading branch information
Showing
11 changed files
with
286 additions
and
264 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import React, { createContext, useEffect, useState, useContext, ReactNode } from "react"; | ||
import { StadiumType } from "@/src/constants/ZoneData"; | ||
import { ZoneGetResponseType } from "@/src/api/StadiumApiType"; | ||
|
||
// 1. Context νμ μ μ | ||
interface StadiumContextType { | ||
selectedStadium: StadiumType; | ||
setSelectedStadium: (stadium: StadiumType) => void; | ||
selectedSection: string; | ||
setSelectedSection: (section: string) => void; | ||
selectedSectionColor: string; | ||
setSelectedSectionColor: (color: string) => void; | ||
zoneNameList: string[]; | ||
setZoneNameList: (zones: string[]) => void; | ||
stadiumInfo: ZoneGetResponseType | undefined; | ||
setStadiumInfo: (info: ZoneGetResponseType | undefined) => void; | ||
} | ||
|
||
// 2. κΈ°λ³Έκ° μ€μ | ||
const StadiumContext = createContext<StadiumContextType | null>(null); | ||
|
||
// 3. Context Provider μ»΄ν¬λνΈ | ||
export const StadiumProvider: React.FC<{ children: ReactNode }> = ({ children }) => { | ||
// νλ‘ νΈμμ μ νν μ€νλμ κ° μ μ κ΄λ¦¬ λ³μ | ||
const [selectedStadium, setSelectedStadium] = useState<StadiumType>(StadiumType.JAMSIL); | ||
// νμ΄μ§ μ΄λ λ° μλ‘κ² λ λλ§νλλΌλ κΈ°μ‘΄μ μ νν selectedStadium κ°μ΄ μ΄κΈ°νλμ§ μκ³ μ μ§λλλ‘ λ‘컬 νμ€ν 리μ μ μ₯ | ||
useEffect(() => { | ||
// ν΄λΌμ΄μΈνΈ μ¬μ΄λμμλ§ localStorage μ¬μ© | ||
if (typeof window !== "undefined") { | ||
const savedStadium = localStorage.getItem('selectedStadium'); | ||
if (savedStadium) { | ||
setSelectedStadium(JSON.parse(savedStadium)); | ||
} | ||
} | ||
}, []); | ||
// μν μ λ°μ΄νΈ μ localStorageμ μ μ₯ | ||
useEffect(() => { | ||
if (typeof window !== "undefined") { | ||
localStorage.setItem('selectedStadium', JSON.stringify(selectedStadium)); | ||
} | ||
}, [selectedStadium]); | ||
|
||
|
||
// νλ‘ νΈμμ μ νν μ€νλμμ λ°λ₯Έ μ’μ(zone) 리μ€νΈ μ μ κ΄λ¦¬ λ³μ | ||
const [zoneNameList, setZoneNameList] = useState<string[]>([]); | ||
|
||
// νλ‘ νΈμμ μ νν μ€νλμμ λ°λ₯Έ μ’μ(zone) κ° μ μ κ΄λ¦¬ λ³μ | ||
const [selectedSection, setSelectedSection] = useState<string>(""); | ||
|
||
// μ’μ μμ, selectedSectionκ³Ό mapping | ||
const [selectedSectionColor, setSelectedSectionColor] = useState<string>(""); | ||
|
||
// λ°±μλλ‘λΆν° λ°μμ¨ μ€νλμ μ 보 κ° μ μ κ΄λ¦¬ λ³μ | ||
const [stadiumInfo, setStadiumInfo] = useState<ZoneGetResponseType>(); | ||
|
||
return ( | ||
<StadiumContext.Provider value={{ | ||
selectedStadium, setSelectedStadium, | ||
selectedSection, setSelectedSection, | ||
selectedSectionColor, setSelectedSectionColor, | ||
zoneNameList, setZoneNameList, | ||
stadiumInfo, setStadiumInfo | ||
}}> | ||
{children} | ||
</StadiumContext.Provider> | ||
); | ||
}; | ||
|
||
// 4. Context μ¬μ©μ μν 컀μ€ν ν | ||
export const useStadiumContext = () => useContext(StadiumContext); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.