Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeyAlmighty committed Mar 31, 2024
1 parent 14a8bb4 commit ca10c1f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
3 changes: 2 additions & 1 deletion new-york-babies-web/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import * as React from "react"
import {useEffect} from "react";
import "./styles.css"
import {Table} from "./components/Table";
import {TableProvider} from "./stores/TableContext";
import {useEffect} from "react";

export const App = () => {
useEffect(() => {
document.title = "New york | Baby Name Index"
}, []);

return (
<div style={{ textAlign: "center" }}>
<h1>New York Baby Name Index</h1>
Expand Down
1 change: 1 addition & 0 deletions new-york-babies-web/src/components/table.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ button {
border: .125em solid #313131;
cursor: pointer;
color: white;

&:disabled {
border: .125em solid darkgray;
background-color: darkgray;
Expand Down
12 changes: 3 additions & 9 deletions new-york-babies-web/src/stores/TableContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,11 @@ export const TableProvider: FC<any> = ({ children }) => {
const [pageSize, setPageSize] = useState<number>(10);
const [offset, setOffset] = useState<number>(0);

const updateSortingField = (field: string) => {
setSortingField(field);
};
const updateSortingField = (field: string) => setSortingField(field);;

const updatePageSize = (field: number) => {
setPageSize(field);
};
const updatePageSize = (field: number) => setPageSize(field);;

const updateOffset = (field: number) => {
setOffset(field);
};
const updateOffset = (field: number) => setOffset(field);;

return (
<TableContext.Provider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ public APIResponse<Page<Baby>> getBabiesWithPagination(@PathVariable int offset,

// SORTING AND PAGINATING
@GetMapping("/pagination/{offset}/{pageSize}/{field}/{direction}")
public APIResponse<Page<Baby>> getBabiesWithPaginationAndSorting(@PathVariable int offset, @PathVariable int pageSize, @PathVariable String field, @PathVariable String direction) {
public APIResponse<Page<Baby>> getBabiesWithPaginationAndSorting(
@PathVariable int offset,
@PathVariable int pageSize,
@PathVariable String field,
@PathVariable String direction
) {
Page<Baby> allBabiesWithPaginationAndSorting = babyService.findAllBabiesWithPaginationAndSorting(offset, pageSize, field, direction);
return new APIResponse<>(allBabiesWithPaginationAndSorting.getSize(), allBabiesWithPaginationAndSorting);
}
Expand All @@ -57,4 +62,4 @@ public APIResponse<Page<Baby>> getBabiesLikeSearch(
Page<Baby> babies = babyService.findBabiesLike(offset, pageSize, field, direction, term);
return new APIResponse<>(babies.getSize(), babies);
}
}
}

0 comments on commit ca10c1f

Please sign in to comment.