-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* removed iterator * changes * EOD checkopoint * validation for user role * Response and user-employee validation working * Pull from console * console.log and debuggers removed * index path for response * Making some changes * console removed * random * user access roles working * localizations added * Removed debuggera dn console * Localizations * Changes * Delete package-lock.json --------- Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.org>
- Loading branch information
1 parent
1def20d
commit db1ff78
Showing
10 changed files
with
166 additions
and
117 deletions.
There are no files selected for viewing
89 changes: 42 additions & 47 deletions
89
...ro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/AssumptionsList.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,55 @@ | ||
import React from 'react' | ||
import React from 'react'; | ||
import { Card } from '@egovernments/digit-ui-components'; | ||
import HeaderComp from './HeaderComp'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
const AssumptionsList = ({ customProps }) => { | ||
const {t}=useTranslation(); | ||
const assumptionValues= customProps?.sessionData?.HYPOTHESIS.Assumptions?.assumptionValues | ||
const { t } = useTranslation(); | ||
|
||
// Safely access assumptionValues using optional chaining | ||
const assumptionValues = customProps?.sessionData?.HYPOTHESIS?.Assumptions?.assumptionValues || []; | ||
|
||
let dic = {}; | ||
|
||
// Iterate through assumptionValues and build the dictionary | ||
for (const ob of assumptionValues) { | ||
if (!(ob?.category in dic)) { | ||
dic[ob.category] = [{ [ob?.key]: ob.value }] | ||
}else{ | ||
dic[ob.category].push({ [ob?.key]: ob.value }) | ||
const category = ob?.category || 'NA'; | ||
const key = ob?.key || 'NA'; | ||
const value = ob?.value || 'NA'; | ||
|
||
if (!(category in dic)) { | ||
dic[category] = [{ [key]: value }]; | ||
} else { | ||
dic[category].push({ [key]: value }); | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
return ( | ||
<div> | ||
{ | ||
Object.keys(dic).map((item, ind) => { | ||
|
||
return ( | ||
< Card key={`card_${ind}`} style={{ padding: '20px', marginBottom: '15px' }}> | ||
<HeaderComp title={String(item)}/> | ||
<div className="as-table-like"> | ||
{dic[item].map((item1, index) => { | ||
// Since each item1 is an object with a single key-value pair | ||
const [key, value] = Object.entries(item1)[0]; // Destructure the first and only key-value pair | ||
return ( | ||
<div key={`pair_${index}`} className="as-table-row"> | ||
<span className="as-table-cell as-key-cell"> | ||
<strong>{t(key)}</strong> {/* Display key as label */} | ||
</span> | ||
<span className="as-table-cell as-value-cell"> | ||
{t(value)} {/* Display value */} | ||
</span> | ||
</div> | ||
); | ||
})} | ||
</div> | ||
</Card> | ||
); | ||
}) | ||
} | ||
|
||
|
||
</div > | ||
) | ||
} | ||
|
||
export default AssumptionsList | ||
{Object.keys(dic).map((item, ind) => ( | ||
<Card key={`card_${ind}`} style={{ padding: '20px', marginBottom: '15px' }}> | ||
<HeaderComp title={String(item)} /> | ||
<div className="as-table-like"> | ||
{dic[item].map((item1, index) => { | ||
// Safely destructure the key-value pair, with fallbacks for missing data | ||
const [key, value] = Object.entries(item1)[0] || ['NA', 'NA']; | ||
|
||
return ( | ||
<div key={`pair_${index}`} className="as-table-row"> | ||
<span className="as-table-cell as-key-cell"> | ||
<strong>{t(key)}</strong> {/* Display key as label */} | ||
</span> | ||
<span className="as-table-cell as-value-cell"> | ||
{t(value)} {/* Display value */} | ||
</span> | ||
</div> | ||
); | ||
})} | ||
</div> | ||
</Card> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
export default AssumptionsList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.