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
6 changes: 6 additions & 0 deletions src/app/(pages)/weather/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import { WeatherLocationTab } from './_components/weather-locaion-tab';
import { Suspense } from 'react';
import { WeatherSection } from './_components/weather-section';
import { NoticeDialog } from '@/components/notice-dialog';

export default function WeatherPage() {
return (
<div className='flex h-full w-full flex-col'>
<NoticeDialog
title='공지'
description={`현재 기상청 데이터 불안정으로,\n일부 지역의 날씨 정보가 정확하지 않음 수 있습니다.`}
storageKey='weather-notice-dismissed'
/>
<header className='flex-center text-title1 text-gray-bk border-gray-0 h-auto w-full border-b-8 py-3'>
날씨
</header>
Expand Down
72 changes: 72 additions & 0 deletions src/components/notice-dialog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
'use client';

import { useState, useEffect } from 'react';
import {
AlertDialog,
AlertDialogAction,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
} from '@/components/ui/alert-dialog';

interface NoticeDialogProps {
title: string;
description: string;
storageKey?: string;
}

export function NoticeDialog({
title,
description,
storageKey = 'notice-dismissed',
}: NoticeDialogProps) {
const [open, setOpen] = useState(false);

useEffect(() => {
const dismissedDate = localStorage.getItem(storageKey);
const today = new Date().toDateString();

if (dismissedDate !== today) {
setOpen(true);
}
}, [storageKey]);

const handleDismissToday = () => {
const today = new Date().toDateString();
localStorage.setItem(storageKey, today);
setOpen(false);
};

const handleClose = () => {
setOpen(false);
};

return (
<AlertDialog open={open} onOpenChange={setOpen}>
<AlertDialogContent className='rounded-3 max-w-[calc(100%-5rem)]'>
<AlertDialogHeader className='gap-4 sm:text-center'>
<AlertDialogTitle className='text-title1'>{title}</AlertDialogTitle>
<AlertDialogDescription className='text-body4 whitespace-pre-line'>
{description}
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter className='flex w-full flex-col gap-4 sm:flex-col'>
<AlertDialogAction
onClick={handleClose}
className='bg-point-400 text-title4 rounded-3 w-full text-white'
>
확인
</AlertDialogAction>
<button
onClick={handleDismissToday}
className='text-caption2 underline'
>
오늘은 그만보기
</button>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
);
}
Loading