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

jc - Patch form that creates commons to supply startingDate to POST. #50

Closed
wants to merge 14 commits into from

Conversation

jacksoncooper
Copy link
Contributor

@jacksoncooper jacksoncooper commented Mar 9, 2022

The Commons type was expanded in #30 to include a startingDate member. The form dumps its elements into the body of a POST request to /api/commons/new, so we need to make sure the elements have the correct id (?) property. I'm struggling to figure out the internals of react-hook-form, and which values it uses for the POST.

Forked from @Jacqueskim's branch that implements the page that lists commons for ease of testing. So we should merge #40 first.

Addresses #36.

@codecov
Copy link

codecov bot commented Mar 9, 2022

Codecov Report

Merging #50 (ceba6f5) into main (7431e39) will decrease coverage by 23.65%.
The diff coverage is n/a.

Impacted file tree graph

@@              Coverage Diff              @@
##               main      #50       +/-   ##
=============================================
- Coverage     67.40%   43.75%   -23.66%     
  Complexity       42       42               
=============================================
  Files            47       20       -27     
  Lines           359      208      -151     
  Branches          9        9               
=============================================
- Hits            242       91      -151     
  Misses          116      116               
  Partials          1        1               
Impacted Files Coverage Δ
...d/src/main/components/Commons/CreateCommonsForm.js
frontend/src/main/components/Nav/AppNavbar.js
frontend/src/main/components/OurTable.js
frontend/src/main/utils/users.js
frontend/src/main/components/Commons/ManageCows.js
frontend/src/main/pages/AdminCreateCommonsPage.js
frontend/src/main/utils/useBackend.js
frontend/src/main/utils/minMax_NoStryker.js
frontend/src/main/components/Commons/FarmStats.js
...tend/src/main/components/Nav/AppNavbarLocalhost.js
... and 17 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7431e39...ceba6f5. Read the comment docs.

@jacksoncooper jacksoncooper added Attn-peer-CR At least one team member should do a code review before the staff w22-6pm-4 labels Mar 9, 2022
import BasicLayout from "main/layouts/BasicLayout/BasicLayout";
import CommonsTable from 'main/components/Commons/CommonsTable';
import { useBackend } from 'main/utils/useBackend';
//import { useCurrentUser } from 'main/utils/currentUser'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove this commented import?

Comment on lines +68 to +70
// Stryker disable next-line ArrayDeclaration : [columns] is a performance optimization
const memoizedColumns = React.useMemo(() => columns, [columns]);
const memoizedCommons = React.useMemo(() => commons, [commons]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't actually memoize the columns or commons variables. The reference returned by memoizedColumns and memoizedCommons will change whenever the reference to columns or commons changes, which defeats the point of trying to memoize these fields.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shoot, sorry! Shouldn't have requested review, I forked and got a bunch of redundant files.

Comment on lines +72 to +74
for (let readable of commons) {
readable.startingDate = new Date(readable.startingDate).toLocaleString();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be cleaner to do this formatting in the accessor rather than modifying the input data.

@@ -1,5 +1,6 @@
import { render, waitFor, fireEvent } from "@testing-library/react";
import OurTable from "main/components/OurTable";
//import OurTable from "main/components/OurTable";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented import

@jacksoncooper jacksoncooper removed the request for review from kheff16 March 9, 2022 23:05
@jacksoncooper
Copy link
Contributor Author

Closing, adding to #40.

@jacksoncooper jacksoncooper removed the Attn-peer-CR At least one team member should do a code review before the staff label Mar 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants