auto send frequence succeed message change
This commit is contained in:
parent
1e7c500f90
commit
a8ee946d02
|
|
@ -15,7 +15,6 @@ import {
|
||||||
MenuItem,
|
MenuItem,
|
||||||
Paper,
|
Paper,
|
||||||
Select,
|
Select,
|
||||||
Snackbar,
|
|
||||||
Tab,
|
Tab,
|
||||||
Tabs,
|
Tabs,
|
||||||
TextField,
|
TextField,
|
||||||
|
|
@ -286,7 +285,7 @@ function WeeklyReport({ installationId, installationName, installationEmail }: W
|
||||||
const [autoSend, setAutoSend] = useState({ sendWeekly: false, sendMonthly: false, sendYearly: false });
|
const [autoSend, setAutoSend] = useState({ sendWeekly: false, sendMonthly: false, sendYearly: false });
|
||||||
const [autoSendDirty, setAutoSendDirty] = useState(false);
|
const [autoSendDirty, setAutoSendDirty] = useState(false);
|
||||||
const [savingAutoSend, setSavingAutoSend] = useState(false);
|
const [savingAutoSend, setSavingAutoSend] = useState(false);
|
||||||
const [autoSendSnackbar, setAutoSendSnackbar] = useState<string | null>(null);
|
const [autoSendStatus, setAutoSendStatus] = useState<{ message: string; severity: 'success' | 'error' } | null>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
axiosConfig.get('/GetEmailPreference', { params: { installationId } })
|
axiosConfig.get('/GetEmailPreference', { params: { installationId } })
|
||||||
|
|
@ -309,9 +308,11 @@ function WeeklyReport({ installationId, installationName, installationEmail }: W
|
||||||
params: { installationId, ...autoSend }
|
params: { installationId, ...autoSend }
|
||||||
});
|
});
|
||||||
setAutoSendDirty(false);
|
setAutoSendDirty(false);
|
||||||
setAutoSendSnackbar(intl.formatMessage({ id: 'autoSendSaved', defaultMessage: 'Auto-send preferences saved.' }));
|
setAutoSendStatus({ message: intl.formatMessage({ id: 'autoSendSaved', defaultMessage: 'Auto-send preferences saved.' }), severity: 'success' });
|
||||||
|
setTimeout(() => setAutoSendStatus(null), 4000);
|
||||||
} catch {
|
} catch {
|
||||||
setAutoSendSnackbar(intl.formatMessage({ id: 'autoSendSaveFailed', defaultMessage: 'Failed to save auto-send preferences.' }));
|
setAutoSendStatus({ message: intl.formatMessage({ id: 'autoSendSaveFailed', defaultMessage: 'Failed to save auto-send preferences.' }), severity: 'error' });
|
||||||
|
setTimeout(() => setAutoSendStatus(null), 4000);
|
||||||
} finally {
|
} finally {
|
||||||
setSavingAutoSend(false);
|
setSavingAutoSend(false);
|
||||||
}
|
}
|
||||||
|
|
@ -527,15 +528,13 @@ function WeeklyReport({ installationId, installationName, installationEmail }: W
|
||||||
<FormattedMessage id="autoSendNoEmail" defaultMessage="Set email address in Information tab to enable auto-send" />
|
<FormattedMessage id="autoSendNoEmail" defaultMessage="Set email address in Information tab to enable auto-send" />
|
||||||
</Typography>
|
</Typography>
|
||||||
)}
|
)}
|
||||||
|
{autoSendStatus && (
|
||||||
|
<Typography variant="caption" sx={{ color: autoSendStatus.severity === 'success' ? '#27ae60' : '#e74c3c', ml: 1, textTransform: 'uppercase', fontWeight: 600 }}>
|
||||||
|
{autoSendStatus.message}
|
||||||
|
</Typography>
|
||||||
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
<Snackbar
|
|
||||||
open={!!autoSendSnackbar}
|
|
||||||
autoHideDuration={4000}
|
|
||||||
onClose={() => setAutoSendSnackbar(null)}
|
|
||||||
message={autoSendSnackbar}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Box sx={{ display: tabs[safeTab]?.key === 'daily' ? 'block' : 'none', minHeight: '50vh' }}>
|
<Box sx={{ display: tabs[safeTab]?.key === 'daily' ? 'block' : 'none', minHeight: '50vh' }}>
|
||||||
<DailySection installationId={installationId} onHasData={setDailyHasData} onPeriodChange={(date: string) => setReportPeriods(prev => ({ ...prev, daily: { start: date, end: date } }))} />
|
<DailySection installationId={installationId} onHasData={setDailyHasData} onPeriodChange={(date: string) => setReportPeriods(prev => ({ ...prev, daily: { start: date, end: date } }))} />
|
||||||
</Box>
|
</Box>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue