Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: observation_level table order working #1014

Merged
merged 3 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions next/components/atoms/ObservationLevelTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,25 @@ export default function ObservationLevel({ resource }) {

const headers = [t('observationLevelTable.entityHeader'), t('observationLevelTable.columnsHeader')];

let array = []
const keys = Object.keys(resource?.observationLevels)
function sortElements(a, b) {
if (a.order < b.order) {
return -1;
}
if (a.order > b.order) {
return 1;
}
return 0;
}

keys.forEach((elm) => {
const value = resource?.observationLevels[elm]
let array = [];
const keys = Object.keys(resource?.observationLevels);
const sortedLevels = Object.values(resource?.observationLevels).sort(sortElements);

sortedLevels.forEach((value) => {
const valueEntity = () => {
if(value.entity[`name${capitalize(locale)}`]) return value.entity[`name${capitalize(locale)}`]
if(value.entity.name) return value.entity.name
return t('observationLevelTable.notProvided')
if(value.entity[`name${capitalize(locale)}`]) return value.entity[`name${capitalize(locale)}`];
if(value.entity.name) return value.entity.name;
return t('observationLevelTable.notProvided');
}

const valueColumns = () => {
Expand Down
1 change: 1 addition & 0 deletions next/pages/api/rawDataSources/getRawDataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ async function getRawDataSource(id, locale = 'pt') {
edges {
node {
_id
order
columns {
edges {
node {
Expand Down
1 change: 1 addition & 0 deletions next/pages/api/tables/getTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ async function getTable(id, locale='pt') {
edges {
node {
_id
order
columns {
edges {
node {
Expand Down