Persist project settings updates
This commit is contained in:
@@ -245,17 +245,21 @@ export default function ProjectDetailPage() {
|
||||
}
|
||||
|
||||
async function handleSaveProjectSettings() {
|
||||
if (!projectId) {
|
||||
if (!projectId || !project) {
|
||||
return;
|
||||
}
|
||||
setIsSaving(true);
|
||||
setError(null);
|
||||
try {
|
||||
const updated = await updateProjectSettings(projectId, {
|
||||
singlePhaseVoltageV: Number(singlePhaseVoltageV),
|
||||
threePhaseVoltageV: Number(threePhaseVoltageV),
|
||||
});
|
||||
setProject(updated);
|
||||
const result = await updateProjectSettings(
|
||||
projectId,
|
||||
project.currentRevision,
|
||||
{
|
||||
singlePhaseVoltageV: Number(singlePhaseVoltageV),
|
||||
threePhaseVoltageV: Number(threePhaseVoltageV),
|
||||
}
|
||||
);
|
||||
setProject(result.project);
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : "Projekteigenschaften konnten nicht gespeichert werden.");
|
||||
} finally {
|
||||
@@ -599,7 +603,14 @@ export default function ProjectDetailPage() {
|
||||
className="btn btn-primary w-100"
|
||||
type="button"
|
||||
onClick={handleSaveProjectSettings}
|
||||
disabled={isSaving}
|
||||
disabled={
|
||||
isSaving ||
|
||||
!project ||
|
||||
(Number(singlePhaseVoltageV) ===
|
||||
project.singlePhaseVoltageV &&
|
||||
Number(threePhaseVoltageV) ===
|
||||
project.threePhaseVoltageV)
|
||||
}
|
||||
>
|
||||
Projekteigenschaften speichern
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user