From 075624717d546e43aa9fa5e65dd650c2e4677621 Mon Sep 17 00:00:00 2001 From: Yinyin Liu Date: Thu, 26 Feb 2026 14:52:29 +0100 Subject: [PATCH] grant ready-only Information, Battery , PV, Log and Report to Partner role in Sodistore Home and Report to Customer role --- .../Information/InformationSodistoreHome.tsx | 277 ++++++++++-------- .../SodiohomeInstallations/Installation.tsx | 66 +++-- .../SodiohomeInstallations/index.tsx | 122 +++++++- 3 files changed, 293 insertions(+), 172 deletions(-) diff --git a/typescript/frontend-marios2/src/content/dashboards/Information/InformationSodistoreHome.tsx b/typescript/frontend-marios2/src/content/dashboards/Information/InformationSodistoreHome.tsx index cebd9afbb..bc8f7ab75 100644 --- a/typescript/frontend-marios2/src/content/dashboards/Information/InformationSodistoreHome.tsx +++ b/typescript/frontend-marios2/src/content/dashboards/Information/InformationSodistoreHome.tsx @@ -175,6 +175,9 @@ function InformationSodistorehome(props: InformationSodistorehomeProps) { return true; }; + const canEdit = currentUser.userType === UserType.admin; + const isPartner = currentUser.userType === UserType.partner; + return ( <> {openModalDeleteInstallation && ( @@ -276,6 +279,7 @@ function InformationSodistorehome(props: InformationSodistorehomeProps) { onChange={handleChange} variant="outlined" fullWidth + inputProps={{ readOnly: !canEdit }} />
@@ -288,8 +292,9 @@ function InformationSodistorehome(props: InformationSodistorehomeProps) { onChange={handleChange} variant="outlined" fullWidth - required - error={formValues.region === ''} + required={canEdit} + error={canEdit && formValues.region === ''} + inputProps={{ readOnly: !canEdit }} />
@@ -305,8 +310,9 @@ function InformationSodistorehome(props: InformationSodistorehomeProps) { onChange={handleChange} variant="outlined" fullWidth - required - error={formValues.location === ''} + required={canEdit} + error={canEdit && formValues.location === ''} + inputProps={{ readOnly: !canEdit }} />
@@ -319,23 +325,26 @@ function InformationSodistorehome(props: InformationSodistorehomeProps) { onChange={handleChange} variant="outlined" fullWidth - required - error={formValues.country === ''} + required={canEdit} + error={canEdit && formValues.country === ''} + inputProps={{ readOnly: !canEdit }} />
-
- - } - name="vpnIp" - value={formValues.vpnIp} - onChange={handleChange} - variant="outlined" - fullWidth - /> -
+ {canEdit && ( +
+ + } + name="vpnIp" + value={formValues.vpnIp} + onChange={handleChange} + variant="outlined" + fullWidth + /> +
+ )}
{DeviceTypes.map((device) => ( @@ -372,106 +382,116 @@ function InformationSodistorehome(props: InformationSodistorehomeProps) {
-
- - } - name="serialNumber" - value={formValues.serialNumber} - onChange={handleChange} - variant="outlined" - fullWidth - /> -
- -
- - } - name="inverterSN" - value={formValues.inverterSN} - onChange={handleChange} - variant="outlined" - fullWidth - /> -
- -
- - } - name="dataloggerSN" - value={formValues.dataloggerSN} - onChange={handleChange} - variant="outlined" - fullWidth - /> -
- -
- - } - name="batteryClusterNumber" - value={formValues.batteryClusterNumber} - onChange={handleChange} - variant="outlined" - fullWidth - /> -
- -
- - } - name="batteryNumber" - type="text" - value={batteryNumber === 0 ? '' : batteryNumber} - onChange={handleBatteryNumberChange} - variant="outlined" - fullWidth - placeholder="Enter number of batteries" - /> -
- - {batteryNumber > 0 && - batterySerialNumbers.map((serialNumber, index) => ( -
+ {(canEdit || isPartner) && ( + <> +
- handleBatterySerialNumberChange(index, e.target.value) + label={ + } - onKeyDown={(e) => handleBatterySnKeyDown(e, index)} - inputRef={(el) => (batterySnRefs.current[index] = el)} + name="serialNumber" + value={formValues.serialNumber} + onChange={handleChange} variant="outlined" fullWidth - placeholder="Scan or enter serial number" + inputProps={{ readOnly: !canEdit }} />
- ))} + +
+ + } + name="inverterSN" + value={formValues.inverterSN} + onChange={handleChange} + variant="outlined" + fullWidth + inputProps={{ readOnly: !canEdit }} + /> +
+ +
+ + } + name="dataloggerSN" + value={formValues.dataloggerSN} + onChange={handleChange} + variant="outlined" + fullWidth + inputProps={{ readOnly: !canEdit }} + /> +
+ +
+ + } + name="batteryClusterNumber" + value={formValues.batteryClusterNumber} + onChange={handleChange} + variant="outlined" + fullWidth + inputProps={{ readOnly: !canEdit }} + /> +
+ +
+ + } + name="batteryNumber" + type="text" + value={batteryNumber === 0 ? '' : batteryNumber} + onChange={handleBatteryNumberChange} + variant="outlined" + fullWidth + placeholder={canEdit ? 'Enter number of batteries' : ''} + inputProps={{ readOnly: !canEdit }} + /> +
+ + {batteryNumber > 0 && + batterySerialNumbers.map((serialNumber, index) => ( +
+ + handleBatterySerialNumberChange(index, e.target.value) + } + onKeyDown={(e) => handleBatterySnKeyDown(e, index)} + inputRef={(el) => (batterySnRefs.current[index] = el)} + variant="outlined" + fullWidth + placeholder={canEdit ? 'Scan or enter serial number' : ''} + inputProps={{ readOnly: !canEdit }} + /> +
+ ))} + + )}
- {currentUser.userType == UserType.admin && ( + {canEdit && ( <>
- + {canEdit && ( + + )} - {currentUser.userType == UserType.admin && ( + {canEdit && (