optimize
Some checks failed
Deploy MyApp on Same Server / build-and-deploy (push) Failing after 1s

This commit is contained in:
2025-12-20 01:50:14 +03:30
parent 618960bb5c
commit 3644d57206
10 changed files with 299 additions and 208 deletions

View File

@@ -29,6 +29,32 @@ function DailyReportContent() {
const [forecastWeather, setForecastWeather] = useState<WeatherData | null>(null)
const [forecastWeatherLoading, setForecastWeatherLoading] = useState(false)
// Map summary param to chart key
const paramToChartKey = useCallback((param: string): string => {
const mapping: Record<string, string> = {
temperature: 'temp',
humidity: 'hum',
gas: 'gas',
soil: 'soil',
lux: 'lux',
}
return mapping[param] || param
}, [])
// Handle card click: switch to charts tab and scroll to chart
const handleCardClick = useCallback((param: string) => {
const chartKey = paramToChartKey(param)
setActiveTab('charts')
// Wait for tab to switch and chart to render, then scroll
setTimeout(() => {
const chartElement = document.getElementById(`chart-${chartKey}`)
if (chartElement) {
chartElement.scrollIntoView({ behavior: 'smooth', block: 'start' })
}
}, 100)
}, [paramToChartKey])
const deviceId = Number(searchParams.get('deviceId') ?? '1')
const dateParam = searchParams.get('date') ?? formatPersianDate(getCurrentPersianYear(), getCurrentPersianMonth(), getCurrentPersianDay())
@@ -217,7 +243,7 @@ function DailyReportContent() {
className="md:mx-0 mx-[-1rem] md:rounded-xl rounded-none"
>
{{
summary: <SummaryTab temperature={temp} humidity={hum} soil={soil} gas={gas} lux={lux} forecastWeather={forecastWeather} forecastWeatherLoading={forecastWeatherLoading} />,
summary: <SummaryTab temperature={temp} humidity={hum} soil={soil} gas={gas} lux={lux} forecastWeather={forecastWeather} forecastWeatherLoading={forecastWeatherLoading} onCardClick={handleCardClick} />,
charts: (
<Suspense fallback={<Loading message="در حال بارگذاری نمودارها..." />}>
<ChartsTab sortedTelemetry={sortedTelemetry} dataGaps={dataGaps} />