Skip to content

Commit

Permalink
fix React Component's id naming style
Browse files Browse the repository at this point in the history
  • Loading branch information
brianchennn committed Sep 23, 2023
1 parent df73b55 commit 336fee0
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions frontend/src/pages/SubscriberCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1116,6 +1116,7 @@ export default function SubscriberCreate() {
const flowKey = toHex(snssai.sst) + snssai.sd;
for (let i = 0; i < data.ChargingDatas!.length; i++) {
const chargingData = data.ChargingDatas![i]
const idPrefix = snssai + "-" + dnn + "-" + chargingData.qosRef + "-"
if (chargingData.snssai === flowKey && chargingData.dnn === dnn && chargingData.qosRef === flow.qosRef) {
return (
<Box sx={{ m: 2 }}>
Expand All @@ -1125,7 +1126,7 @@ export default function SubscriberCreate() {
</Grid>
</Grid>
<Table>
<TableBody id={flowKey + dnn + chargingData.qosRef + "Charging Method"}>
<TableBody id={idPrefix + "ChargingMethod"}>
<TableCell>
<FormControl variant="outlined" fullWidth>
<InputLabel>Charging Method</InputLabel>
Expand Down Expand Up @@ -1157,7 +1158,7 @@ export default function SubscriberCreate() {
</TableCell>
</TableBody>
*/}
<TableBody id="Quota">
<TableBody id={idPrefix + "Quota"}>
<TableCell>
<TextField
label="Quota (monetary)"
Expand All @@ -1169,7 +1170,7 @@ export default function SubscriberCreate() {
/>
</TableCell>
</TableBody>
<TableBody id="Unit Cost">
<TableBody id={idPrefix + "UnitCost"}>
<TableCell>
<TextField
label="Unit Cost (money per byte)"
Expand All @@ -1190,13 +1191,14 @@ export default function SubscriberCreate() {

const flowRule = (dnn: string, snssai: Nssai) => {
const flowKey = toHex(snssai.sst) + snssai.sd;
const idPrefix = flowKey + "-" + dnn + "-"
if (data.FlowRules !== undefined) {
return (
data.FlowRules
.filter((flow) => flow.dnn === dnn && flow.snssai === flowKey)
.map((flow) => (
<div key={flow.snssai}>
<Box sx={{ m: 2 }} id={dnn+flowKey+flow.qosRef}>
<Box sx={{ m: 2 }} id={idPrefix + flow.qosRef}>
<Grid container spacing={2}>
<Grid item xs={10}>
<h4>Flow Rules {flow.qosRef}</h4>
Expand All @@ -1216,7 +1218,7 @@ export default function SubscriberCreate() {
</Grid>
<Card variant="outlined">
<Table>
<TableBody id="IP Filter">
<TableBody id={idPrefix + flow.qosRef + "-IpFilter"}>
<TableRow>
<TableCell>
<TextField
Expand All @@ -1230,7 +1232,7 @@ export default function SubscriberCreate() {
</TableCell>
</TableRow>
</TableBody>
<TableBody id="Precedence">
<TableBody id={idPrefix + flow.qosRef + "-Precedence"}>
<TableRow>
<TableCell>
<TextField
Expand All @@ -1245,7 +1247,7 @@ export default function SubscriberCreate() {
</TableCell>
</TableRow>
</TableBody>
<TableBody id="5QI">
<TableBody id={idPrefix + flow.qosRef +"-5QI"}>
<TableRow>
<TableCell>
<TextField
Expand All @@ -1260,7 +1262,7 @@ export default function SubscriberCreate() {
</TableCell>
</TableRow>
</TableBody>
<TableBody id="Uplink GBR">
<TableBody id={idPrefix + flow.qosRef +"-UlGBR"}>
<TableRow>
<TableCell>
<TextField
Expand All @@ -1274,7 +1276,7 @@ export default function SubscriberCreate() {
</TableCell>
</TableRow>
</TableBody>
<TableBody id="Downlink GBR">
<TableBody id={idPrefix + flow.qosRef + "-DlGBR"}>
<TableRow>
<TableCell>
<TextField
Expand All @@ -1288,7 +1290,7 @@ export default function SubscriberCreate() {
</TableCell>
</TableRow>
</TableBody>
<TableBody id="Uplink MBR">
<TableBody id={idPrefix + flow.qosRef + "-UlMBR"}>
<TableRow>
<TableCell>
<TextField
Expand All @@ -1302,7 +1304,7 @@ export default function SubscriberCreate() {
</TableCell>
</TableRow>
</TableBody>
<TableBody id="Downlink MBR">
<TableBody id={idPrefix + flow.qosRef + "-DlMBR"}>
<TableRow>
<TableCell>
<TextField
Expand Down Expand Up @@ -1637,7 +1639,7 @@ export default function SubscriberCreate() {
</Grid>
<Card variant="outlined">
<Table>
<TableBody id="SST">
<TableBody id={toHex(row.singleNssai!.sst)+row.singleNssai!.sd! + "-SST"}>
<TableRow>
<TableCell>
<TextField
Expand All @@ -1646,13 +1648,13 @@ export default function SubscriberCreate() {
required
fullWidth
type="number"
value={row.singleNssai?.sst}
value={row.singleNssai!.sst!}
onChange={(ev) => handleChangeSST(ev, index)}
/>
</TableCell>
</TableRow>
</TableBody>
<TableBody id="SD">
<TableBody id={toHex(row.singleNssai!.sst)+row.singleNssai!.sd! + "-SD"}>
<TableRow>
<TableCell>
<TextField
Expand All @@ -1666,7 +1668,7 @@ export default function SubscriberCreate() {
</TableCell>
</TableRow>
</TableBody>
<TableBody id="Default S-NSSAI">
<TableBody id={toHex(row.singleNssai!.sst)+row.singleNssai!.sd! + "-Default S-NSSAI"}>
<TableRow>
<TableCell style={{ width: "83%" }}>Default S-NSSAI</TableCell>
<TableCell align="right">
Expand All @@ -1680,7 +1682,7 @@ export default function SubscriberCreate() {
</Table>
{row.dnnConfigurations &&
Object.keys(row.dnnConfigurations!).map((dnn) => (
<div key={dnn}>
<div key={dnn} id={toHex(row.singleNssai!.sst!) + row.singleNssai!.sd! + '-' + dnn!}>
<Box sx={{ m: 2 }}>
<Grid container spacing={2}>
<Grid item xs={10}>
Expand All @@ -1703,7 +1705,7 @@ export default function SubscriberCreate() {
</Box>
</Grid>
</Grid>
<Card variant="outlined">
<Card variant="outlined" id={toHex(row.singleNssai!.sst!) + row.singleNssai!.sd! + '-' + dnn! + "-AddFlowRuleArea"}>
<Table>
<TableBody>
<TableRow>
Expand All @@ -1712,7 +1714,7 @@ export default function SubscriberCreate() {
</TableCell>
</TableRow>
</TableBody>
<TableBody id="Uplink AMBR">
<TableBody id={toHex(row.singleNssai!.sst!) + row.singleNssai!.sd! + '-' + dnn! + "-UlAMBR"}>
<TableRow>
<TableCell>
<TextField
Expand All @@ -1726,7 +1728,7 @@ export default function SubscriberCreate() {
</TableCell>
</TableRow>
</TableBody>
<TableBody id="Downlink AMBR">
<TableBody id={toHex(row.singleNssai!.sst!) + row.singleNssai!.sd! + '-' + dnn! + "-DlAMBR"}>
<TableRow>
<TableCell>
<TextField
Expand All @@ -1740,7 +1742,7 @@ export default function SubscriberCreate() {
</TableCell>
</TableRow>
</TableBody>
<TableBody id="Default 5QI">
<TableBody id={toHex(row.singleNssai!.sst!) + row.singleNssai!.sd! + '-' + dnn! + "-Default5QI"}>
<TableRow>
<TableCell>
<TextField
Expand Down Expand Up @@ -1771,7 +1773,7 @@ export default function SubscriberCreate() {
</div>
))}
<Grid container spacing={2}>
<Grid item xs={10}>
<Grid item xs={10} id={toHex(row.singleNssai!.sst) + row.singleNssai!.sd! + '-AddDNNInputArea'}>
<Box sx={{ m: 2 }}>
<TextField
label="Data Network Name"
Expand All @@ -1783,7 +1785,7 @@ export default function SubscriberCreate() {
/>
</Box>
</Grid>
<Grid item xs={2}>
<Grid item xs={2} id={toHex(row.singleNssai!.sst) + row.singleNssai!.sd! + '-AddDNNButtonArea'}>
<Box display="flex" justifyContent="flex-end">
<Button
color="secondary"
Expand Down

0 comments on commit 336fee0

Please sign in to comment.