Skip to content

Commit

Permalink
adapt to the @types/qs update
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikzogg committed May 9, 2020
1 parent 17c3a62 commit 92d980e
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 74 deletions.
154 changes: 96 additions & 58 deletions package-lock.json

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

14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,29 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.5.0",
"@testing-library/jest-dom": "^5.6.0",
"@testing-library/react": "^10.0.4",
"@testing-library/user-event": "^10.0.2",
"@types/jest": "^25.2.1",
"@types/node": "^13.13.4",
"@types/qs": "^6.9.1",
"@types/node": "^13.13.5",
"@types/qs": "^6.9.2",
"@types/react": "^16.9.34",
"@types/react-dom": "^16.9.7",
"@types/react-router-dom": "^5.1.5",
"coveralls": "^3.1.0",
"date-fns": "^2.12.0",
"fetch-mock": "^9.4.0",
"date-fns": "^2.13.0",
"fetch-mock": "^9.5.0",
"jest-environment-jsdom-sixteen": "^1.0.3",
"node-fetch": "^2.6.0",
"postcss-loader": "^3.0.0",
"qs": "^6.9.4",
"react": "^16.13.1",
"react-app-rewired": "^2.1.6",
"react-dom": "^16.13.1",
"react-hook-form": "^5.6.1",
"react-hook-form": "^5.6.2",
"react-router-dom": "^5.1.2",
"react-scripts": "3.4.1",
"tailwindcss": "^1.4.4",
"tailwindcss": "^1.4.5",
"typescript": "~3.8.3"
},
"browserslist": {
Expand Down
20 changes: 11 additions & 9 deletions src/Component/Page/Pet/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,25 @@ import { ListPets, DeletePet } from '../../../ApiClient/Pet';
import BadRequest from '../../../Model/Error/BadRequest';
import HttpError from '../../../Model/Error/HttpError';
import HttpErrorPartial from '../../Partial/HttpError';
import PetResponse from '../../../Model/Pet/PetResponse';
import PetList from '../../../Model/Pet/PetList';
import qs from 'qs';
import PetFilterForm from '../../Form/PetFilterForm';
import Pagination from '../../Partial/Pagination';
import PetFilterForm from '../../Form/PetFilterForm';
import PetFilters from '../../../Model/Pet/PetFilters';
import PetList from '../../../Model/Pet/PetList';
import PetResponse from '../../../Model/Pet/PetResponse';
import qs from 'qs';

const List: React.FC = () => {

const history = useHistory();
const location = useLocation();

const query = qs.parse(location.search.substr(1));
const parsedQuery = qs.parse(location.search.substr(1));

query.page = parseInt(query.page ?? '1');
query.filters = query.filters ?? {};
query.sort = query.sort ?? {};
const query = {
page: typeof parsedQuery.page === 'string' ? parseInt(parsedQuery.page) : 1,
filters: typeof parsedQuery.filters === 'object' && !(parsedQuery.filters instanceof Array) ? parsedQuery.filters : {},
sort: typeof parsedQuery.sort === 'object' && !(parsedQuery.sort instanceof Array) ? parsedQuery.sort : {},
};

const queryString = qs.stringify({
limit: 10,
Expand Down Expand Up @@ -65,7 +67,7 @@ const List: React.FC = () => {
fetchPetList(queryString);
};

const changePage = (page: number): void => {
const changePage = (page: number): void => {
history.push(`/pet?${qs.stringify({ ...query, page: page })}`);
};

Expand Down

0 comments on commit 92d980e

Please sign in to comment.