refactor(alert-settings): integrate AppShell layout and update cache version
Some checks failed
Deploy MyApp on Same Server / build-and-deploy (push) Has been cancelled

- Replace custom page layout with AppShell component for consistent UI
- Remove unused PageHeader and UpdateAlertConditionDto imports
- Update service worker cache names and version.json to new timestamp
This commit is contained in:
2026-05-11 22:19:30 +03:30
parent 676f1373c1
commit 9da69c96b1
20 changed files with 1025 additions and 172 deletions

View File

@@ -6,6 +6,7 @@ import { Smartphone, ArrowLeft } from 'lucide-react'
import Loading from '@/components/Loading'
import { MobileInput } from '@/components/forms'
import { ErrorMessage } from '@/components/common'
import { getCurrentPersianYear, getCurrentPersianMonth, getCurrentPersianDay } from '@/lib/date/persian-date'
export default function Home() {
const router = useRouter()
@@ -20,9 +21,35 @@ export default function Home() {
if (token && userStr) {
try {
JSON.parse(userStr)
// Redirect to devices check
router.push('/devices')
const user = JSON.parse(userStr)
// Try to use the saved device from localStorage first
const savedDeviceId = localStorage.getItem('selectedDeviceId')
if (savedDeviceId) {
const today = `${getCurrentPersianYear()}/${String(getCurrentPersianMonth()).padStart(2, '0')}/${String(getCurrentPersianDay()).padStart(2, '0')}`
router.push(`/daily-report?deviceId=${savedDeviceId}&date=${encodeURIComponent(today)}`)
return
}
// No saved device — fetch user devices and auto-select the first one
api.getUserDevices(user.id)
.then((devices) => {
if (devices.length > 0) {
const firstDevice = devices[0]
// Save to localStorage
localStorage.setItem('selectedDeviceId', String(firstDevice.id))
localStorage.setItem('selectedDeviceName', firstDevice.deviceName)
const today = `${getCurrentPersianYear()}/${String(getCurrentPersianMonth()).padStart(2, '0')}/${String(getCurrentPersianDay()).padStart(2, '0')}`
router.push(`/daily-report?deviceId=${firstDevice.id}&date=${encodeURIComponent(today)}`)
} else {
// No devices — go to devices page to show the error
router.push('/devices')
}
})
.catch(() => {
// On error, fall back to devices page
router.push('/devices')
})
} catch {
// Invalid user data, go to login
}