grant ready-only Information, Battery , PV, Log and Report to Partner role in Sodistore Home and Report to Customer role
This commit is contained in:
parent
d464c9cd71
commit
075624717d
|
|
@ -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 }}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
|
|
@ -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 }}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
|
|
@ -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 }}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
|
|
@ -319,11 +325,13 @@ function InformationSodistorehome(props: InformationSodistorehomeProps) {
|
|||
onChange={handleChange}
|
||||
variant="outlined"
|
||||
fullWidth
|
||||
required
|
||||
error={formValues.country === ''}
|
||||
required={canEdit}
|
||||
error={canEdit && formValues.country === ''}
|
||||
inputProps={{ readOnly: !canEdit }}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{canEdit && (
|
||||
<div>
|
||||
<TextField
|
||||
label={
|
||||
|
|
@ -336,6 +344,7 @@ function InformationSodistorehome(props: InformationSodistorehomeProps) {
|
|||
fullWidth
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div>
|
||||
<FormControl
|
||||
|
|
@ -362,6 +371,7 @@ function InformationSodistorehome(props: InformationSodistorehomeProps) {
|
|||
name="device"
|
||||
value={formValues.device}
|
||||
onChange={handleChange}
|
||||
inputProps={{ readOnly: !canEdit }}
|
||||
>
|
||||
{DeviceTypes.map((device) => (
|
||||
<MenuItem key={device.id} value={device.id}>
|
||||
|
|
@ -372,6 +382,8 @@ function InformationSodistorehome(props: InformationSodistorehomeProps) {
|
|||
</FormControl>
|
||||
</div>
|
||||
|
||||
{(canEdit || isPartner) && (
|
||||
<>
|
||||
<div>
|
||||
<TextField
|
||||
label={
|
||||
|
|
@ -385,6 +397,7 @@ function InformationSodistorehome(props: InformationSodistorehomeProps) {
|
|||
onChange={handleChange}
|
||||
variant="outlined"
|
||||
fullWidth
|
||||
inputProps={{ readOnly: !canEdit }}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
|
@ -401,6 +414,7 @@ function InformationSodistorehome(props: InformationSodistorehomeProps) {
|
|||
onChange={handleChange}
|
||||
variant="outlined"
|
||||
fullWidth
|
||||
inputProps={{ readOnly: !canEdit }}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
|
@ -417,6 +431,7 @@ function InformationSodistorehome(props: InformationSodistorehomeProps) {
|
|||
onChange={handleChange}
|
||||
variant="outlined"
|
||||
fullWidth
|
||||
inputProps={{ readOnly: !canEdit }}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
|
@ -433,6 +448,7 @@ function InformationSodistorehome(props: InformationSodistorehomeProps) {
|
|||
onChange={handleChange}
|
||||
variant="outlined"
|
||||
fullWidth
|
||||
inputProps={{ readOnly: !canEdit }}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
|
@ -450,7 +466,8 @@ function InformationSodistorehome(props: InformationSodistorehomeProps) {
|
|||
onChange={handleBatteryNumberChange}
|
||||
variant="outlined"
|
||||
fullWidth
|
||||
placeholder="Enter number of batteries"
|
||||
placeholder={canEdit ? 'Enter number of batteries' : ''}
|
||||
inputProps={{ readOnly: !canEdit }}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
|
@ -468,10 +485,13 @@ function InformationSodistorehome(props: InformationSodistorehomeProps) {
|
|||
inputRef={(el) => (batterySnRefs.current[index] = el)}
|
||||
variant="outlined"
|
||||
fullWidth
|
||||
placeholder="Scan or enter serial number"
|
||||
placeholder={canEdit ? 'Scan or enter serial number' : ''}
|
||||
inputProps={{ readOnly: !canEdit }}
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
</>
|
||||
)}
|
||||
|
||||
<div>
|
||||
<TextField
|
||||
|
|
@ -486,10 +506,11 @@ function InformationSodistorehome(props: InformationSodistorehomeProps) {
|
|||
onChange={handleChange}
|
||||
variant="outlined"
|
||||
fullWidth
|
||||
inputProps={{ readOnly: !canEdit }}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{currentUser.userType == UserType.admin && (
|
||||
{canEdit && (
|
||||
<>
|
||||
<div>
|
||||
<TextField
|
||||
|
|
@ -533,6 +554,7 @@ function InformationSodistorehome(props: InformationSodistorehomeProps) {
|
|||
marginTop: 10
|
||||
}}
|
||||
>
|
||||
{canEdit && (
|
||||
<Button
|
||||
variant="contained"
|
||||
onClick={handleSubmit}
|
||||
|
|
@ -546,8 +568,9 @@ function InformationSodistorehome(props: InformationSodistorehomeProps) {
|
|||
defaultMessage="Apply Changes"
|
||||
/>
|
||||
</Button>
|
||||
)}
|
||||
|
||||
{currentUser.userType == UserType.admin && (
|
||||
{canEdit && (
|
||||
<Button
|
||||
variant="contained"
|
||||
onClick={handleDelete}
|
||||
|
|
|
|||
|
|
@ -474,6 +474,7 @@ function SodioHomeInstallation(props: singleInstallationProps) {
|
|||
}
|
||||
/>
|
||||
|
||||
{currentUser.userType !== UserType.client && (
|
||||
<Route
|
||||
path={routes.log}
|
||||
element={
|
||||
|
|
@ -484,6 +485,7 @@ function SodioHomeInstallation(props: singleInstallationProps) {
|
|||
></Log>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
|
||||
<Route
|
||||
path={routes.live}
|
||||
|
|
@ -497,6 +499,7 @@ function SodioHomeInstallation(props: singleInstallationProps) {
|
|||
}
|
||||
/>
|
||||
|
||||
{currentUser.userType !== UserType.client && (
|
||||
<Route
|
||||
path={routes.batteryview + '/*'}
|
||||
element={
|
||||
|
|
@ -508,7 +511,8 @@ function SodioHomeInstallation(props: singleInstallationProps) {
|
|||
connected={connected}
|
||||
></BatteryViewSodioHome>
|
||||
}
|
||||
></Route>
|
||||
/>
|
||||
)}
|
||||
|
||||
{currentUser.userType == UserType.admin && (
|
||||
<Route
|
||||
|
|
@ -559,7 +563,6 @@ function SodioHomeInstallation(props: singleInstallationProps) {
|
|||
}
|
||||
/>
|
||||
|
||||
{currentUser.userType == UserType.admin && (
|
||||
<Route
|
||||
path={routes.report}
|
||||
element={
|
||||
|
|
@ -568,7 +571,6 @@ function SodioHomeInstallation(props: singleInstallationProps) {
|
|||
/>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
|
||||
<Route
|
||||
path={'*'}
|
||||
|
|
|
|||
|
|
@ -118,7 +118,6 @@ function SodioHomeInstallationTabs(props: SodioHomeInstallationTabsProps) {
|
|||
value: 'log',
|
||||
label: <FormattedMessage id="log" defaultMessage="Log" />
|
||||
},
|
||||
|
||||
{
|
||||
value: 'manage',
|
||||
label: (
|
||||
|
|
@ -128,14 +127,12 @@ function SodioHomeInstallationTabs(props: SodioHomeInstallationTabsProps) {
|
|||
/>
|
||||
)
|
||||
},
|
||||
|
||||
{
|
||||
value: 'information',
|
||||
label: (
|
||||
<FormattedMessage id="information" defaultMessage="Information" />
|
||||
)
|
||||
},
|
||||
|
||||
{
|
||||
value: 'configuration',
|
||||
label: (
|
||||
|
|
@ -164,6 +161,45 @@ function SodioHomeInstallationTabs(props: SodioHomeInstallationTabsProps) {
|
|||
)
|
||||
}
|
||||
]
|
||||
: currentUser.userType == UserType.partner
|
||||
? [
|
||||
{
|
||||
value: 'live',
|
||||
label: <FormattedMessage id="live" defaultMessage="Live" />
|
||||
},
|
||||
{
|
||||
value: 'overview',
|
||||
label: <FormattedMessage id="overview" defaultMessage="Overview" />
|
||||
},
|
||||
{
|
||||
value: 'batteryview',
|
||||
label: (
|
||||
<FormattedMessage
|
||||
id="batteryview"
|
||||
defaultMessage="Battery View"
|
||||
/>
|
||||
)
|
||||
},
|
||||
{
|
||||
value: 'log',
|
||||
label: <FormattedMessage id="log" defaultMessage="Log" />
|
||||
},
|
||||
{
|
||||
value: 'information',
|
||||
label: (
|
||||
<FormattedMessage id="information" defaultMessage="Information" />
|
||||
)
|
||||
},
|
||||
{
|
||||
value: 'report',
|
||||
label: (
|
||||
<FormattedMessage
|
||||
id="report"
|
||||
defaultMessage="Report"
|
||||
/>
|
||||
)
|
||||
}
|
||||
]
|
||||
: [
|
||||
{
|
||||
value: 'live',
|
||||
|
|
@ -178,14 +214,24 @@ function SodioHomeInstallationTabs(props: SodioHomeInstallationTabsProps) {
|
|||
label: (
|
||||
<FormattedMessage id="information" defaultMessage="Information" />
|
||||
)
|
||||
},
|
||||
{
|
||||
value: 'report',
|
||||
label: (
|
||||
<FormattedMessage
|
||||
id="report"
|
||||
defaultMessage="Report"
|
||||
/>
|
||||
)
|
||||
}
|
||||
];
|
||||
|
||||
const tabs =
|
||||
const inInstallationView =
|
||||
currentTab != 'list' &&
|
||||
currentTab != 'tree' &&
|
||||
!location.pathname.includes('folder') &&
|
||||
currentUser.userType == UserType.admin
|
||||
!location.pathname.includes('folder');
|
||||
|
||||
const tabs = inInstallationView && currentUser.userType == UserType.admin
|
||||
? [
|
||||
{
|
||||
value: 'list',
|
||||
|
|
@ -216,7 +262,6 @@ function SodioHomeInstallationTabs(props: SodioHomeInstallationTabsProps) {
|
|||
value: 'log',
|
||||
label: <FormattedMessage id="log" defaultMessage="Log" />
|
||||
},
|
||||
|
||||
{
|
||||
value: 'manage',
|
||||
label: (
|
||||
|
|
@ -226,7 +271,6 @@ function SodioHomeInstallationTabs(props: SodioHomeInstallationTabsProps) {
|
|||
/>
|
||||
)
|
||||
},
|
||||
|
||||
{
|
||||
value: 'information',
|
||||
label: (
|
||||
|
|
@ -261,10 +305,7 @@ function SodioHomeInstallationTabs(props: SodioHomeInstallationTabsProps) {
|
|||
)
|
||||
}
|
||||
]
|
||||
: currentTab != 'list' &&
|
||||
currentTab != 'tree' &&
|
||||
!location.pathname.includes('folder') &&
|
||||
currentUser.userType == UserType.client
|
||||
: inInstallationView && currentUser.userType == UserType.partner
|
||||
? [
|
||||
{
|
||||
value: 'list',
|
||||
|
|
@ -282,12 +323,67 @@ function SodioHomeInstallationTabs(props: SodioHomeInstallationTabsProps) {
|
|||
value: 'overview',
|
||||
label: <FormattedMessage id="overview" defaultMessage="Overview" />
|
||||
},
|
||||
|
||||
{
|
||||
value: 'batteryview',
|
||||
label: (
|
||||
<FormattedMessage
|
||||
id="batteryview"
|
||||
defaultMessage="Battery View"
|
||||
/>
|
||||
)
|
||||
},
|
||||
{
|
||||
value: 'log',
|
||||
label: <FormattedMessage id="log" defaultMessage="Log" />
|
||||
},
|
||||
{
|
||||
value: 'information',
|
||||
label: (
|
||||
<FormattedMessage id="information" defaultMessage="Information" />
|
||||
)
|
||||
},
|
||||
{
|
||||
value: 'report',
|
||||
label: (
|
||||
<FormattedMessage
|
||||
id="report"
|
||||
defaultMessage="Report"
|
||||
/>
|
||||
)
|
||||
}
|
||||
]
|
||||
: inInstallationView && currentUser.userType == UserType.client
|
||||
? [
|
||||
{
|
||||
value: 'list',
|
||||
icon: <ListIcon id="mode-toggle-button-list-icon" />
|
||||
},
|
||||
{
|
||||
value: 'tree',
|
||||
icon: <AccountTreeIcon id="mode-toggle-button-tree-icon" />
|
||||
},
|
||||
{
|
||||
value: 'live',
|
||||
label: <FormattedMessage id="live" defaultMessage="Live" />
|
||||
},
|
||||
{
|
||||
value: 'overview',
|
||||
label: <FormattedMessage id="overview" defaultMessage="Overview" />
|
||||
},
|
||||
{
|
||||
value: 'information',
|
||||
label: (
|
||||
<FormattedMessage id="information" defaultMessage="Information" />
|
||||
)
|
||||
},
|
||||
{
|
||||
value: 'report',
|
||||
label: (
|
||||
<FormattedMessage
|
||||
id="report"
|
||||
defaultMessage="Report"
|
||||
/>
|
||||
)
|
||||
}
|
||||
]
|
||||
: [
|
||||
|
|
|
|||
Loading…
Reference in New Issue