refactor: rename and remove default data
This commit is contained in:
@ -45,7 +45,7 @@ const defaultOrderBy = [
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const reduceSortsToGqlSorts = (sorts: Array<SortType>): OrderBy[] => {
|
const reduceSortsToOrderBy = (sorts: Array<SortType>): OrderBy[] => {
|
||||||
const mappedSorts = sorts.reduce((acc, sort) => {
|
const mappedSorts = sorts.reduce((acc, sort) => {
|
||||||
acc[sort.id] = sort.order;
|
acc[sort.id] = sort.order;
|
||||||
return acc;
|
return acc;
|
||||||
@ -55,19 +55,17 @@ const reduceSortsToGqlSorts = (sorts: Array<SortType>): OrderBy[] => {
|
|||||||
|
|
||||||
function People() {
|
function People() {
|
||||||
const [sorts, setSorts] = useState([] as Array<SortType>);
|
const [sorts, setSorts] = useState([] as Array<SortType>);
|
||||||
const orderBy = sorts.length ? reduceSortsToGqlSorts(sorts) : defaultOrderBy;
|
const orderBy = sorts.length ? reduceSortsToOrderBy(sorts) : defaultOrderBy;
|
||||||
const { data } = useQuery<{ person: GraphqlPerson[] }>(GET_PEOPLE, {
|
const { data } = useQuery<{ person: GraphqlPerson[] }>(GET_PEOPLE, {
|
||||||
variables: { orderBy: orderBy },
|
variables: { orderBy: orderBy },
|
||||||
});
|
});
|
||||||
|
|
||||||
const mydata: Person[] = data ? data.person.map(mapPerson) : defaultData;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<WithTopBarContainer title="People" icon={faUser}>
|
<WithTopBarContainer title="People" icon={faUser}>
|
||||||
<StyledPeopleContainer>
|
<StyledPeopleContainer>
|
||||||
{mydata && (
|
{data && (
|
||||||
<Table
|
<Table
|
||||||
data={mydata}
|
data={data.person.map(mapPerson)}
|
||||||
columns={peopleColumns}
|
columns={peopleColumns}
|
||||||
viewName="All People"
|
viewName="All People"
|
||||||
viewIcon={faList}
|
viewIcon={faList}
|
||||||
|
|||||||
Reference in New Issue
Block a user