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
Binary file added src/assets/booth_stamp_success.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 20 additions & 14 deletions src/components/stamp/BoothStamp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import QrScanner from 'qr-scanner'
import StampImg from '../../assets/duksung_fantasy_transparent.png'
import ComputerIcon from '../../assets/booth_stamp_computer.svg'
import ComputerSuccessIcon from '../../assets/booth_stamp_computer_success.svg'
import StampIcon from '../../assets/booth_stamp_success.svg'
import StampIcon from '../../assets/booth_stamp_success.png'
import ScanModal from './ScanModal'
import Modal from '../Modal'
import BoothData from '../../data/boothData.json'
Expand All @@ -18,27 +18,33 @@ const BoothStamp = () => {
}>({})

const [showModal, setShowModal] = useState(false)
const [isValidQR, setIsValidQR] = useState<boolean>(false)
const [content, setContent] = useState<string>('')

const videoRef = useRef<HTMLVideoElement | null>(null)
const scannerRef = useRef<QrScanner | null>(null)

const handleScan = (result: QrScanner.ScanResult) => {
if (result) {
console.log(result)

scannerRef.current?.stop()

const boothId = result.data

const content = BoothData.find((booth) => String(booth.id) === boothId)
setContent(content?.content ?? '')

const updatedBooths = { ...scannedBooth, [boothId]: true }

setScannedBooth(updatedBooths)

localStorage.setItem('scannedBooths', JSON.stringify(updatedBooths))
const booth = BoothData.find((booth) => String(booth.id) === boothId) // 해당 부스 객체

if (!booth) {
setIsValidQR(false)
setContent(
'유효하지 않은 QR입니다. 올바른 코드를 스캔했는지 확인해주세요.',
)
} else {
setIsValidQR(true)
setContent(booth?.content ?? '')

const updatedBooths = { ...scannedBooth, [boothId]: true }
setScannedBooth(updatedBooths)
localStorage.setItem('scannedBooths', JSON.stringify(updatedBooths))
}
}

setTimeout(() => {
Expand Down Expand Up @@ -96,7 +102,7 @@ const BoothStamp = () => {
/>
</div>

<div className="grid grid-cols-3 gap-[24px] px-[35px] place-items-center mb-[36px]">
<div className="grid grid-cols-3 gap-[24px] px-[35px] place-items-center mb-[36px] mt-[16px]">
{Array.from({ length: 17 }).map((_, idx) => (
<div
key={idx}
Expand Down Expand Up @@ -147,7 +153,7 @@ const BoothStamp = () => {
<ScanModal videoRef={videoRef} setIsScanning={setIsScanning} />
)}

<div className="sticky bottom-[32px] px-[16px] w-full mb-[32px]">
<div className="sticky bottom-[32px] pointer-coarse:bottom-[10px] px-[16px] w-full mb-[32px]">
<button
onClick={() => setIsScanning(true)}
className="w-full bg-[#56493A] rounded-[40px] h-[48px] text-[#fff] text-[20px] font-bold leading-[24px] font-['Butler'] cursor-pointer"
Expand All @@ -160,7 +166,7 @@ const BoothStamp = () => {
{/* 스캔 이후 모달 */}
{showModal && (
<Modal
title={'스탬프 수집 완료'}
title={isValidQR ? '스탬프 수집 완료' : '스탬프 수집 실패'}
content={content}
setShowModal={setShowModal}
/>
Expand Down
8 changes: 4 additions & 4 deletions src/layout/RootLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const RootLayout = () => {

return (
<div
className="relative min-h-screen w-full flex items-center justify-center font-[Pretendard] bg-cover bg-center"
className="relative min-h-dvh w-full flex items-center justify-center font-[Pretendard] bg-cover bg-center"
style={{ backgroundImage: `url(${backgroundImg})` }}
>
<div
Expand All @@ -20,7 +20,7 @@ const RootLayout = () => {
/>

<div
className={`relative z-10 w-full max-w-[402px] h-[min(874px,100vh)] flex flex-col ${isMain ? 'bg-[#292a2c]' : 'bg-[#F5F3F0]'} overflow-hidden shadow-lg`}
className={`relative z-10 w-full max-w-[402px] h-[min(874px,100dvh)] pointer-coarse:h-dvh pointer-coarse:max-w-full flex flex-col ${isMain ? 'bg-[#292a2c]' : 'bg-[#F5F3F0]'} overflow-hidden shadow-lg`}
id="app-container"
>
{/* 헤더 */}
Expand All @@ -42,9 +42,9 @@ const RootLayout = () => {
</main>
</div>

{/* 화면 높이가 700px 이상일 때만 라운드 적용 */}
{/* 화면 높이가 700px 이상일 때, PC 환경일 때만 라운드 적용 */}
<style>{`
@media (min-height: 874px) {
@media (min-height: 874px) and (hover:hover) and (pointer:fine) {
#app-container {
border-radius: 0.75rem; /* rounded-xl */
}
Expand Down