Skip to content

Commit

Permalink
Merge pull request #74 from dxc-technology/jialecl-halstackProvider-r…
Browse files Browse the repository at this point in the history
…emoved

HalstackProvider removed from the halTable
  • Loading branch information
jsuarezgonz authored Apr 25, 2024
2 parents 9a0711d + 39c0b88 commit 6e2a5ef
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 89 deletions.
160 changes: 78 additions & 82 deletions lib/src/components/HalTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,91 +117,87 @@ const HalTable = ({
const { onPageChange, sort } = navigationFunctions;

return (
<HalstackProvider>
<div>
<DxcTable>
<thead>
<tr>
{columns.map((column) => (
<th
key={`tableHeader_${column.header}`}
aria-sort={
column.sortProperty === sortColumn
? "ascending"
: `-${column.sortProperty}` === sortColumn
? "descending"
: "none"
}
<>
<DxcTable>
<thead>
<tr>
{columns.map((column) => (
<th
key={`tableHeader_${column.header}`}
aria-sort={
column.sortProperty === sortColumn
? "ascending"
: `-${column.sortProperty}` === sortColumn
? "descending"
: "none"
}
>
<HeaderContainer
role={column.sortProperty ? "button" : undefined}
onClick={() => sortByColumn(column.sortProperty, sort, sortColumn)}
tabIndex={column.sortProperty ? 0 : -1}
isSortable={column.sortProperty ? true : false}
>
<HeaderContainer
role={column.sortProperty ? "button" : undefined}
onClick={() => sortByColumn(column.sortProperty, sort, sortColumn)}
tabIndex={column.sortProperty ? 0 : -1}
isSortable={column.sortProperty ? true : false}
>
<span>{column.header}</span>
{column.sortProperty && (
<SortIcon>
{getIconForSortableColumn(column.sortProperty, sortColumn)}
</SortIcon>
<span>{column.header}</span>
{column.sortProperty && (
<SortIcon>{getIconForSortableColumn(column.sortProperty, sortColumn)}</SortIcon>
)}
</HeaderContainer>
</th>
))}
</tr>
</thead>
<tbody>
{!isLoading &&
collectionItems.length > 0 &&
collectionItems.map((collectionItem, i) => (
<tr key={`tr-${i}`}>
{columns.map((columnProperty) => (
<td key={`tr-${i}-${columnProperty.displayProperty}`}>
{columnProperty.onClickItemFunction ? (
<LinkRow
onClick={() => {
columnProperty.onClickItemFunction(collectionItem);
}}
>
{getCellInfo(collectionItem, columnProperty)}
</LinkRow>
) : (
getCellInfo(collectionItem, columnProperty)
)}
</HeaderContainer>
</th>
))}
</tr>
</thead>
<tbody>
{!isLoading &&
collectionItems.length > 0 &&
collectionItems.map((collectionItem, i) => (
<tr key={`tr-${i}`}>
{columns.map((columnProperty) => (
<td key={`tr-${i}-${columnProperty.displayProperty}`}>
{columnProperty.onClickItemFunction ? (
<LinkRow
onClick={() => {
columnProperty.onClickItemFunction(collectionItem);
}}
>
{getCellInfo(collectionItem, columnProperty)}
</LinkRow>
) : (
getCellInfo(collectionItem, columnProperty)
)}
</td>
))}
</tr>
))}
</tbody>
</DxcTable>
{isLoading ? (
<DxcFlex justifyContent="center">
<DxcSpinner margin="xxlarge" label="Fetching data" />
</DxcFlex>
) : (
!error &&
!collectionItems.length && (
<MessageContainer>
<DxcTypography color="#888888">There are no items in this list.</DxcTypography>
</MessageContainer>
)
)}
{!error && totalCollectionItems > 0 && (
<DxcPaginator
totalItems={totalCollectionItems}
itemsPerPage={itemsPerPage}
currentPage={page}
showGoToPage={true}
onPageChange={onPageChange}
/>
)}
{error && (
<MessageContainer hasError={true}>
<DxcTypography color="#d0011b">{error}</DxcTypography>
</td>
))}
</tr>
))}
</tbody>
</DxcTable>
{isLoading ? (
<DxcFlex justifyContent="center">
<DxcSpinner margin="xxlarge" label="Fetching data" />
</DxcFlex>
) : (
!error &&
!collectionItems.length && (
<MessageContainer>
<DxcTypography color="#888888">There are no items in this list.</DxcTypography>
</MessageContainer>
)}
</div>
</HalstackProvider>
)
)}
{!error && totalCollectionItems > 0 && (
<DxcPaginator
totalItems={totalCollectionItems}
itemsPerPage={itemsPerPage}
currentPage={page}
showGoToPage={true}
onPageChange={onPageChange}
/>
)}
{error && (
<MessageContainer hasError={true}>
<DxcTypography color="#d0011b">{error}</DxcTypography>
</MessageContainer>
)}
</>
);
};

Expand Down
11 changes: 5 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"devDependencies": {
"@babel/core": "^7.14.5",
"@babel/preset-react": "^7.14.5",
"@dxc-technology/halstack-react": "^12.0.0",
"@dxc-technology/halstack-react": "^12.0.2",
"@nx/cypress": "16.10.0",
"@nx/esbuild": "^16.10.0",
"@nx/eslint-plugin": "16.10.0",
Expand Down

0 comments on commit 6e2a5ef

Please sign in to comment.