This commit is contained in:
2026-03-21 17:23:27 +03:30
parent 878d8fc544
commit 451a814347
17 changed files with 122 additions and 45 deletions
+12 -13
View File
@@ -83,7 +83,7 @@ const Calendar = (props: CalenderProps) => {
},
views: {
week: {
titleFormat(arg) {
titleFormat(arg: any) {
const start = arg.start
const end = arg.end
@@ -94,20 +94,21 @@ const Calendar = (props: CalenderProps) => {
})
if (!start && !end) {
return { text: '' }
return ''
}
if (start && !end) {
return { text: formatter.format(start) }
return formatter.format(start instanceof Date ? start : new Date(start.marker ?? start))
}
if (!start && end) {
return { text: formatter.format(end) }
return formatter.format(end instanceof Date ? end : new Date(end.marker ?? end))
}
return {
text: `${formatter.format(start)} - ${formatter.format(end)}`
}
const s = start instanceof Date ? start : new Date(start.marker ?? start)
const e = end instanceof Date ? end : new Date(end.marker ?? end)
return `${formatter.format(s)} - ${formatter.format(e)}`
}
}
},
@@ -116,7 +117,7 @@ const Calendar = (props: CalenderProps) => {
return formatter.format(arg.date)
},
titleFormat(arg) {
titleFormat(arg: any) {
const { start, end } = arg
const monthFormatter = new Intl.DateTimeFormat('fa-IR-u-ca-persian', {
@@ -129,18 +130,16 @@ const Calendar = (props: CalenderProps) => {
const target = start || end
if (!target) {
return { text: '' }
return ''
}
const asDate = target instanceof Date ? target : new Date(target as any)
if (Number.isNaN(asDate.getTime())) {
return { text: '' }
return ''
}
return {
text: monthFormatter.format(asDate)
}
return monthFormatter.format(asDate)
},
buttonText: {
today: 'امروز',
@@ -44,7 +44,7 @@ const FarmDashboardSettingsDrawer = (props: FarmDashboardSettingsDrawerProps) =>
<Drawer
open={open}
onClose={onClose}
anchor='end'
anchor='right'
variant='temporary'
ModalProps={{
disablePortal: true,
@@ -54,7 +54,7 @@ const cardRowSx = {
'& > *': { flex: 1, minHeight: 0 }
}
const CARD_COMPONENTS: Record<CardId, React.ComponentType> = {
const CARD_COMPONENTS: Record<CardId, React.ComponentType<{ data?: Record<string, unknown> }>> = {
farmOverviewKpis: FarmOverviewKPIs,
farmWeatherCard: FarmWeatherCard,
farmAlertsTracker: FarmAlertsTracker,
@@ -37,7 +37,7 @@ const FarmOverviewKPIs = ({ data }: FarmOverviewKPIsProps) => {
avatarIcon={kpi.avatarIcon ?? 'tabler-chart-bar'}
avatarSkin='light'
avatarSize={44}
chipText={kpi.chipText}
chipText={kpi.chipText ?? ''}
chipColor={(kpi.chipColor as 'success' | 'warning') ?? 'success'}
chipVariant='tonal'
/>
@@ -26,10 +26,10 @@ interface FarmWeatherCardProps {
const FarmWeatherCard = ({ data }: FarmWeatherCardProps) => {
const t = useTranslations('farmDashboard')
const temperature = data?.temperature ?? 24
const temperature = (data?.temperature as number | undefined) ?? 24
const condition = (data?.condition as string) ?? ''
const humidity = data?.humidity ?? 45
const windSpeed = data?.windSpeed ?? 12
const humidity = (data?.humidity as number | undefined) ?? 45
const windSpeed = (data?.windSpeed as number | undefined) ?? 12
const windUnit = (data?.windUnit as string) ?? 'km/h'
const unit = (data?.unit as string) ?? '°C'
const chartData = data?.chartData as { labels?: string[]; series?: number[][] } | undefined
@@ -27,7 +27,7 @@ const SensorComparisonChart = ({ data }: SensorComparisonChartProps) => {
const categories =
(data?.categories as string[]) ??
[t('fallback.mon'), t('fallback.tue'), t('fallback.wed'), t('fallback.thu'), t('fallback.fri'), t('fallback.sat'), t('fallback.sun')]
const currentValue = data?.currentValue ?? 48
const currentValue = (data?.currentValue as number | undefined) ?? 48
const vsLastWeek = (data?.vsLastWeek as string) ?? t('fallback.plusPercentVsLastWeek', { val: '5' })
const theme = useTheme()
if (series.length === 0) return null
@@ -128,7 +128,7 @@ export default function CropZoningWeatherSection() {
</Typography>
<Typography variant='h5'>
{temp}
{weatherData.unit ?? '°C'}
{(weatherData.unit as string) ?? '°C'}
</Typography>
</CardContent>
</Card>
@@ -67,7 +67,7 @@ export default function ZoneDetailPanel({
<Drawer
open={open}
onClose={onClose}
anchor='end'
anchor='right'
variant='temporary'
ModalProps={{
disablePortal: true,
@@ -68,11 +68,11 @@ export const CARD_GRID_SIZE: Record<CardId, { xs?: number; sm?: number; md?: num
farmAlertsTimeline: { xs: 12, lg: 4 },
waterNeedPrediction: { xs: 12, lg: 8 },
harvestPredictionCard: { xs: 12, md: 6, lg: 4 },
yieldPredictionChart: { xs: 12 },
soilMoistureHeatmap: { xs: 12 },
yieldPredictionChart: { xs: 12, lg: 12 },
soilMoistureHeatmap: { xs: 12, lg: 12 },
ndviHealthCard: { xs: 12, md: 6, lg: 4 },
recommendationsList: { xs: 12, md: 6, lg: 8 },
economicOverview: { xs: 12 }
economicOverview: { xs: 12, lg: 12 }
}
/** Display label for each card (for settings UI) */
+1 -1
View File
@@ -29,7 +29,7 @@ type OptionSensorHubProps = {
const formatLastUpdated = (dateStr: string | null | undefined): string => {
if (!dateStr) return '—'
try {
const d = new DateObject(new Date(dateStr)).convert('persian').setLocale('fa')
const d = new DateObject(new Date(dateStr)).convert('persian' as any).setLocale('fa' as any)
return d.format('YYYY/MM/DD')
} catch {
+1 -1
View File
@@ -23,7 +23,7 @@ import styles from '@core/styles/table.module.css'
const formatToShamsi = (dateStr: string | null | undefined): string => {
if (!dateStr) return '—'
try {
const d = new DateObject(new Date(dateStr)).convert('persian').setLocale('fa')
const d = new DateObject(new Date(dateStr)).convert('persian' as any).setLocale('fa' as any)
return d.format('YYYY/MM/DD')
} catch {