Skip to content

Commit

Permalink
fix: change variabel name
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikmv committed Jan 13, 2025
1 parent 70cc6d4 commit 750c0de
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ export const ChangelogComponent = ({
pager,
columnToSortBy,
setColumnToSortBy,
fieldToFilterBy,
setfieldToFilterBy,
attributeToFilterBy,
setAttributeToFilterBy,
filterValue,
setFilterValue,
setPage,
Expand All @@ -45,8 +45,8 @@ export const ChangelogComponent = ({
<ModalTitle>{i18n.t('Changelog')}</ModalTitle>
<ModalContent>
<ChangelogFilterBar
fieldToFilterBy={fieldToFilterBy}
setfieldToFilterBy={setfieldToFilterBy}
attributeToFilterBy={attributeToFilterBy}
setAttributeToFilterBy={setAttributeToFilterBy}
filterValue={filterValue}
setFilterValue={setFilterValue}
dataItemDefinitions={dataItemDefinitions}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ export const Changelog = ({
setSortDirection,
filterValue,
setFilterValue,
fieldToFilterBy,
setfieldToFilterBy,
attributeToFilterBy,
setAttributeToFilterBy,
} = useChangelogData({ entityId, entityType, programId });

const {
Expand Down Expand Up @@ -81,8 +81,8 @@ export const Changelog = ({
setSortDirection={setSortDirection}
filterValue={filterValue}
setFilterValue={setFilterValue}
fieldToFilterBy={fieldToFilterBy}
setfieldToFilterBy={setfieldToFilterBy}
attributeToFilterBy={attributeToFilterBy}
setAttributeToFilterBy={setAttributeToFilterBy}
dataItemDefinitions={dataItemDefinitions}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ export type ChangelogProps = {
setColumnToSortBy: (string) => void,
sortDirection: SortDirection,
setSortDirection: SetSortDirection,
fieldToFilterBy?: string | null,
setfieldToFilterBy: (string | null) => void,
attributeToFilterBy?: string | null,
setAttributeToFilterBy: (string | null) => void,
filterValue: any,
setFilterValue: (any) => void,
dataItemDefinitions: ItemDefinitions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export type ChangelogFilterProps = {
classes: { container: string },
filterValue: FilterValueType,
setFilterValue: (value: FilterValueType) => void,
fieldToFilterBy: string | null,
setfieldToFilterBy: (value: string | null) => void,
attributeToFilterBy: string | null,
setAttributeToFilterBy: (value: string | null) => void,
dataItemDefinitions: DataItemDefinitions,
};
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ const ChangelogFilterBarPlain = ({
classes,
filterValue,
setFilterValue,
fieldToFilterBy,
setfieldToFilterBy,
attributeToFilterBy,
setAttributeToFilterBy,
dataItemDefinitions,
}: ChangelogFilterProps) => {
const [openMenu, setOpenMenu] = useState<string | null>(null);
Expand All @@ -36,14 +36,14 @@ const ChangelogFilterBarPlain = ({
setOpenMenu(null);
if (value === 'SHOW_ALL') {
setFilterValue('SHOW_ALL');
setfieldToFilterBy(null);
setAttributeToFilterBy(null);
} else {
const column = getFilterColumn(value.id);
setFilterValue(value);
setfieldToFilterBy(column);
setAttributeToFilterBy(column);
}
},
[setFilterValue, setfieldToFilterBy],
[setFilterValue, setAttributeToFilterBy],
);

const dataItems = useMemo(
Expand All @@ -55,7 +55,7 @@ const ChangelogFilterBarPlain = ({
[dataItemDefinitions],
);

const selectedFilterValue = fieldToFilterBy ? filterValue : 'SHOW_ALL';
const selectedFilterValue = attributeToFilterBy ? filterValue : 'SHOW_ALL';

return (
<div className={classes.container}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ type Props = {

export const useChangelogData = ({ entityId, entityType, programId }: Props) => {
const [columnToSortBy, setColumnToSortBy] = useState<string>(COLUMN_TO_SORT_BY.DATE);
console.log('columnToSortBy', columnToSortBy);
const [sortDirection, setSortDirection] = useState<SortDirection>(SORT_DIRECTION.DEFAULT);

const [fieldToFilterBy, setfieldToFilterBy] = useState<string | null>(null);
const [attributeToFilterBy, setAttributeToFilterBy] = useState<string | null>(null);
console.log('attributeToFilterBy', attributeToFilterBy);
const [filterValue, setFilterValue] = useState<Object>('Show all');

const [page, setPage] = useState<number>(1);
Expand All @@ -32,8 +34,8 @@ export const useChangelogData = ({ entityId, entityType, programId }: Props) =>
};

const filterParam =
filterValue !== 'Show all' && fieldToFilterBy
? `${fieldToFilterBy}:eq:${filterValue.id}`
filterValue !== 'Show all' && attributeToFilterBy
? `${attributeToFilterBy}:eq:${filterValue.id}`
: undefined;

const orderParam =
Expand Down Expand Up @@ -71,8 +73,8 @@ export const useChangelogData = ({ entityId, entityType, programId }: Props) =>
setSortDirection,
columnToSortBy,
setColumnToSortBy,
fieldToFilterBy,
setfieldToFilterBy,
attributeToFilterBy,
setAttributeToFilterBy,
filterValue,
setFilterValue,
page,
Expand Down

0 comments on commit 750c0de

Please sign in to comment.