update all page to refresh immidiately without clicking sync button or refreshing the whole page
This commit is contained in:
1 parent
d5b0c12c40
commit
83a41fbbcb
15 files changed
+490
-151
No files matched your search
@@ -11,6 +11,7 @@ type Props = {
|
||||
cycleId: number;
|
||||
currentDay: number;
|
||||
readOnly?: boolean;
|
||||
onSaved?: (savedRow: ManualInput) => void | Promise<void>;
|
||||
};
|
||||
|
||||
type FormState = {
|
||||
@@ -52,7 +53,12 @@ function toForm(row: ManualInput): FormState {
|
||||
};
|
||||
}
|
||||
|
||||
const DashboardManualInputForm: React.FC<Props> = ({ cycleId, currentDay, readOnly = false }) => {
|
||||
const DashboardManualInputForm: React.FC<Props> = ({
|
||||
cycleId,
|
||||
currentDay,
|
||||
readOnly = false,
|
||||
onSaved,
|
||||
}) => {
|
||||
const [form, setForm] = useState<FormState>(() => emptyForm(currentDay));
|
||||
const [saved, setSaved] = useState<ManualInput | null>(null);
|
||||
const [rows, setRows] = useState<ManualInput[]>([]);
|
||||
@@ -138,6 +144,13 @@ const DashboardManualInputForm: React.FC<Props> = ({ cycleId, currentDay, readOn
|
||||
return [row, ...others];
|
||||
});
|
||||
setNotice('Input manual tersimpan.');
|
||||
if (onSaved) {
|
||||
try {
|
||||
await onSaved(row);
|
||||
} catch {
|
||||
// Non-blocking if parent refresh fails
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
setError(errorMessage(err));
|
||||
} finally {
|
||||
|
||||
Reference in new issue
Block a user