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;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const canEdit = currentUser.userType === UserType.admin;
|
||||||
|
const isPartner = currentUser.userType === UserType.partner;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{openModalDeleteInstallation && (
|
{openModalDeleteInstallation && (
|
||||||
|
|
@ -276,6 +279,7 @@ function InformationSodistorehome(props: InformationSodistorehomeProps) {
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
fullWidth
|
fullWidth
|
||||||
|
inputProps={{ readOnly: !canEdit }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
|
@ -288,8 +292,9 @@ function InformationSodistorehome(props: InformationSodistorehomeProps) {
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
fullWidth
|
fullWidth
|
||||||
required
|
required={canEdit}
|
||||||
error={formValues.region === ''}
|
error={canEdit && formValues.region === ''}
|
||||||
|
inputProps={{ readOnly: !canEdit }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
|
@ -305,8 +310,9 @@ function InformationSodistorehome(props: InformationSodistorehomeProps) {
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
fullWidth
|
fullWidth
|
||||||
required
|
required={canEdit}
|
||||||
error={formValues.location === ''}
|
error={canEdit && formValues.location === ''}
|
||||||
|
inputProps={{ readOnly: !canEdit }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
|
@ -319,11 +325,13 @@ function InformationSodistorehome(props: InformationSodistorehomeProps) {
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
fullWidth
|
fullWidth
|
||||||
required
|
required={canEdit}
|
||||||
error={formValues.country === ''}
|
error={canEdit && formValues.country === ''}
|
||||||
|
inputProps={{ readOnly: !canEdit }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{canEdit && (
|
||||||
<div>
|
<div>
|
||||||
<TextField
|
<TextField
|
||||||
label={
|
label={
|
||||||
|
|
@ -336,6 +344,7 @@ function InformationSodistorehome(props: InformationSodistorehomeProps) {
|
||||||
fullWidth
|
fullWidth
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<FormControl
|
<FormControl
|
||||||
|
|
@ -362,6 +371,7 @@ function InformationSodistorehome(props: InformationSodistorehomeProps) {
|
||||||
name="device"
|
name="device"
|
||||||
value={formValues.device}
|
value={formValues.device}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
|
inputProps={{ readOnly: !canEdit }}
|
||||||
>
|
>
|
||||||
{DeviceTypes.map((device) => (
|
{DeviceTypes.map((device) => (
|
||||||
<MenuItem key={device.id} value={device.id}>
|
<MenuItem key={device.id} value={device.id}>
|
||||||
|
|
@ -372,6 +382,8 @@ function InformationSodistorehome(props: InformationSodistorehomeProps) {
|
||||||
</FormControl>
|
</FormControl>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{(canEdit || isPartner) && (
|
||||||
|
<>
|
||||||
<div>
|
<div>
|
||||||
<TextField
|
<TextField
|
||||||
label={
|
label={
|
||||||
|
|
@ -385,6 +397,7 @@ function InformationSodistorehome(props: InformationSodistorehomeProps) {
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
fullWidth
|
fullWidth
|
||||||
|
inputProps={{ readOnly: !canEdit }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -401,6 +414,7 @@ function InformationSodistorehome(props: InformationSodistorehomeProps) {
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
fullWidth
|
fullWidth
|
||||||
|
inputProps={{ readOnly: !canEdit }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -417,6 +431,7 @@ function InformationSodistorehome(props: InformationSodistorehomeProps) {
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
fullWidth
|
fullWidth
|
||||||
|
inputProps={{ readOnly: !canEdit }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -433,6 +448,7 @@ function InformationSodistorehome(props: InformationSodistorehomeProps) {
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
fullWidth
|
fullWidth
|
||||||
|
inputProps={{ readOnly: !canEdit }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -450,7 +466,8 @@ function InformationSodistorehome(props: InformationSodistorehomeProps) {
|
||||||
onChange={handleBatteryNumberChange}
|
onChange={handleBatteryNumberChange}
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
fullWidth
|
fullWidth
|
||||||
placeholder="Enter number of batteries"
|
placeholder={canEdit ? 'Enter number of batteries' : ''}
|
||||||
|
inputProps={{ readOnly: !canEdit }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -468,10 +485,13 @@ function InformationSodistorehome(props: InformationSodistorehomeProps) {
|
||||||
inputRef={(el) => (batterySnRefs.current[index] = el)}
|
inputRef={(el) => (batterySnRefs.current[index] = el)}
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
fullWidth
|
fullWidth
|
||||||
placeholder="Scan or enter serial number"
|
placeholder={canEdit ? 'Scan or enter serial number' : ''}
|
||||||
|
inputProps={{ readOnly: !canEdit }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<TextField
|
<TextField
|
||||||
|
|
@ -486,10 +506,11 @@ function InformationSodistorehome(props: InformationSodistorehomeProps) {
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
fullWidth
|
fullWidth
|
||||||
|
inputProps={{ readOnly: !canEdit }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{currentUser.userType == UserType.admin && (
|
{canEdit && (
|
||||||
<>
|
<>
|
||||||
<div>
|
<div>
|
||||||
<TextField
|
<TextField
|
||||||
|
|
@ -533,6 +554,7 @@ function InformationSodistorehome(props: InformationSodistorehomeProps) {
|
||||||
marginTop: 10
|
marginTop: 10
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
{canEdit && (
|
||||||
<Button
|
<Button
|
||||||
variant="contained"
|
variant="contained"
|
||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
|
|
@ -546,8 +568,9 @@ function InformationSodistorehome(props: InformationSodistorehomeProps) {
|
||||||
defaultMessage="Apply Changes"
|
defaultMessage="Apply Changes"
|
||||||
/>
|
/>
|
||||||
</Button>
|
</Button>
|
||||||
|
)}
|
||||||
|
|
||||||
{currentUser.userType == UserType.admin && (
|
{canEdit && (
|
||||||
<Button
|
<Button
|
||||||
variant="contained"
|
variant="contained"
|
||||||
onClick={handleDelete}
|
onClick={handleDelete}
|
||||||
|
|
|
||||||
|
|
@ -474,6 +474,7 @@ function SodioHomeInstallation(props: singleInstallationProps) {
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
{currentUser.userType !== UserType.client && (
|
||||||
<Route
|
<Route
|
||||||
path={routes.log}
|
path={routes.log}
|
||||||
element={
|
element={
|
||||||
|
|
@ -484,6 +485,7 @@ function SodioHomeInstallation(props: singleInstallationProps) {
|
||||||
></Log>
|
></Log>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
<Route
|
<Route
|
||||||
path={routes.live}
|
path={routes.live}
|
||||||
|
|
@ -497,6 +499,7 @@ function SodioHomeInstallation(props: singleInstallationProps) {
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
{currentUser.userType !== UserType.client && (
|
||||||
<Route
|
<Route
|
||||||
path={routes.batteryview + '/*'}
|
path={routes.batteryview + '/*'}
|
||||||
element={
|
element={
|
||||||
|
|
@ -508,7 +511,8 @@ function SodioHomeInstallation(props: singleInstallationProps) {
|
||||||
connected={connected}
|
connected={connected}
|
||||||
></BatteryViewSodioHome>
|
></BatteryViewSodioHome>
|
||||||
}
|
}
|
||||||
></Route>
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
{currentUser.userType == UserType.admin && (
|
{currentUser.userType == UserType.admin && (
|
||||||
<Route
|
<Route
|
||||||
|
|
@ -559,7 +563,6 @@ function SodioHomeInstallation(props: singleInstallationProps) {
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{currentUser.userType == UserType.admin && (
|
|
||||||
<Route
|
<Route
|
||||||
path={routes.report}
|
path={routes.report}
|
||||||
element={
|
element={
|
||||||
|
|
@ -568,7 +571,6 @@ function SodioHomeInstallation(props: singleInstallationProps) {
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
)}
|
|
||||||
|
|
||||||
<Route
|
<Route
|
||||||
path={'*'}
|
path={'*'}
|
||||||
|
|
|
||||||
|
|
@ -118,7 +118,6 @@ function SodioHomeInstallationTabs(props: SodioHomeInstallationTabsProps) {
|
||||||
value: 'log',
|
value: 'log',
|
||||||
label: <FormattedMessage id="log" defaultMessage="Log" />
|
label: <FormattedMessage id="log" defaultMessage="Log" />
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
value: 'manage',
|
value: 'manage',
|
||||||
label: (
|
label: (
|
||||||
|
|
@ -128,14 +127,12 @@ function SodioHomeInstallationTabs(props: SodioHomeInstallationTabsProps) {
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
value: 'information',
|
value: 'information',
|
||||||
label: (
|
label: (
|
||||||
<FormattedMessage id="information" defaultMessage="Information" />
|
<FormattedMessage id="information" defaultMessage="Information" />
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
value: 'configuration',
|
value: 'configuration',
|
||||||
label: (
|
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',
|
value: 'live',
|
||||||
|
|
@ -178,14 +214,24 @@ function SodioHomeInstallationTabs(props: SodioHomeInstallationTabsProps) {
|
||||||
label: (
|
label: (
|
||||||
<FormattedMessage id="information" defaultMessage="Information" />
|
<FormattedMessage id="information" defaultMessage="Information" />
|
||||||
)
|
)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'report',
|
||||||
|
label: (
|
||||||
|
<FormattedMessage
|
||||||
|
id="report"
|
||||||
|
defaultMessage="Report"
|
||||||
|
/>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
const tabs =
|
const inInstallationView =
|
||||||
currentTab != 'list' &&
|
currentTab != 'list' &&
|
||||||
currentTab != 'tree' &&
|
currentTab != 'tree' &&
|
||||||
!location.pathname.includes('folder') &&
|
!location.pathname.includes('folder');
|
||||||
currentUser.userType == UserType.admin
|
|
||||||
|
const tabs = inInstallationView && currentUser.userType == UserType.admin
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
value: 'list',
|
value: 'list',
|
||||||
|
|
@ -216,7 +262,6 @@ function SodioHomeInstallationTabs(props: SodioHomeInstallationTabsProps) {
|
||||||
value: 'log',
|
value: 'log',
|
||||||
label: <FormattedMessage id="log" defaultMessage="Log" />
|
label: <FormattedMessage id="log" defaultMessage="Log" />
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
value: 'manage',
|
value: 'manage',
|
||||||
label: (
|
label: (
|
||||||
|
|
@ -226,7 +271,6 @@ function SodioHomeInstallationTabs(props: SodioHomeInstallationTabsProps) {
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
value: 'information',
|
value: 'information',
|
||||||
label: (
|
label: (
|
||||||
|
|
@ -261,10 +305,7 @@ function SodioHomeInstallationTabs(props: SodioHomeInstallationTabsProps) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
: currentTab != 'list' &&
|
: inInstallationView && currentUser.userType == UserType.partner
|
||||||
currentTab != 'tree' &&
|
|
||||||
!location.pathname.includes('folder') &&
|
|
||||||
currentUser.userType == UserType.client
|
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
value: 'list',
|
value: 'list',
|
||||||
|
|
@ -282,12 +323,67 @@ function SodioHomeInstallationTabs(props: SodioHomeInstallationTabsProps) {
|
||||||
value: 'overview',
|
value: 'overview',
|
||||||
label: <FormattedMessage id="overview" defaultMessage="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',
|
value: 'information',
|
||||||
label: (
|
label: (
|
||||||
<FormattedMessage id="information" defaultMessage="Information" />
|
<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