-
Notifications
You must be signed in to change notification settings - Fork 64
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
Added funded line, ability to edit groups, and fixed what was ailing … #619
Conversation
…volunteer selection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still lots of debugging code you left in, we'll need to have them removed. Can you also remove all the lint warnings before we move forward?
); | ||
|
||
const props = { classes, mission }; | ||
|
||
const volunteerEditable = volunteerStatus.includes(mission.status); | ||
|
||
useEffect(() => { | ||
document.getElementById("pickup-address-id").value = values.pickUpLocation?.address; | ||
document.getElementById("delivery-address-id").value = values.deliveryLocation?.address; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Im not 100% sure I'm following the logic and reasoning to update this value.
I think what you're trying to achieve can be solved by by these elements setting their values based on state or props instead.
There aren't many cases where we need to use document.getElementById. Majority of use cases can be solved with react element refs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're just trying to set the value of the address input I had previously added the value
prop which you can use instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're goign to have to spell it out for me. I don't know how to set the default value of the AddressInputElement without doing the above. Whatever you want me to insert, I'll do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, @qdozaq instructed me on the proper way to do this, so this shoudl also now be addressed now.
@@ -226,14 +207,28 @@ const MissionEditView = ({ mission, toDetailsView, toListView, volunteers }) => | |||
date: values.deliveryWindow.startTime, | |||
location: "", | |||
}); | |||
console.log("mission tentative:" + mission.tentativeVolunteerUid); | |||
console.log(mission); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be sure to review your commits before you submit a PR to remove debug console logs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, my bad, this is gone.
@@ -380,6 +374,7 @@ const MissionEditView = ({ mission, toDetailsView, toListView, volunteers }) => | |||
</Card> | |||
<Card label="Delivery Details" classes={classes}> | |||
<Row Icon={ScheduleIcon} classes={classes}> | |||
{" "} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're trying to add spacing to both sides of this input, can we use CSS instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, not sure how that got in there, but it's gone now.
import { Box, Container, Grid, Paper } from "@material-ui/core"; | ||
|
||
const Row = ({ children, Icon }) => { | ||
if (!children) return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Row seems to be a general name for this component, but with a pretty specific use case here.
We may not need to even have a separate component for Row
because of the nature of the parent it's living in.
In this case, i would just put the JSX from Row
inside your return for MissionSFundedStatusRow
component.
missionFundedStatusText = "Not Yet Funded"; | ||
break; | ||
default: | ||
throw Error("mission funded status not exist", mission.fundedStatus); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this an error that should be default?
Can a mission not have a FundedStatus?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know, I was trying to reuse code from someone else. I think this was @mat10tng 's?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, this is an error. A mission must have a funded status
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we still fixing this?
} | ||
renderOption={(group) => ( | ||
<> | ||
<GroupWorkIcon style={{ color: _.randomColor(group.groupDisplayName) }} />{" "} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see random colors in the design for this, is this necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish I could answer, this was code I was re-using, originally authored by @mat10tng .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, we have random color for group, but this using the same seed, so its mean
hash -> specific color. But it is in the design
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh okay, I couldn't find random colors on the designs. Might have looked at the wrong frames
switch (mission?.fundedStatus) { | ||
case Mission.FundedStatus.fundedbydonation: | ||
missionFundedStatusText = "Funded By Donation" + fundedDateText; | ||
break; | ||
case Mission.FundedStatus.fundedbyrecipient: | ||
missionFundedStatusText = "Funded By Recipient" + fundedDateText; | ||
break; | ||
case Mission.FundedStatus.fundingnotneeded: | ||
missionFundedStatusText = "Funding Not Needed"; | ||
break; | ||
case Mission.FundedStatus.notfunded: | ||
missionFundedStatusText = "Not Yet Funded"; | ||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use template literals in stead of + for string concatenations?
If fundedDateText
isn't provided properly, you're gonna see Funded By Donation12/12/20
or whatever the date text looks like
Funded by donation: ${fundedDateText}
probably be a little cleaner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
variant="outlined" | ||
InputProps={{ ...params.InputProps, type: "search" }} | ||
<> | ||
{editable ? ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of wrapping this whole component in the ternary I think it would be a lot more clear to just put an if statement before hand
if (!editable) {
return <H6>...
}
return <Autocomplete ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
); | ||
|
||
const props = { classes, mission }; | ||
|
||
const volunteerEditable = volunteerStatus.includes(mission.status); | ||
|
||
useEffect(() => { | ||
document.getElementById("pickup-address-id").value = values.pickUpLocation?.address; | ||
document.getElementById("delivery-address-id").value = values.deliveryLocation?.address; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're just trying to set the value of the address input I had previously added the value
prop which you can use instead
@@ -368,6 +361,7 @@ const MissionEditView = ({ mission, toDetailsView, toListView, volunteers }) => | |||
<Grid item className={classes.fullWidth}> | |||
<AddressInput |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change this to AddressAutocomplete. It should be the better version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should work with defaultLocation props. The adressInput component is unfortunately outdated, with incorrect address and no map. You can check the AdressAutocompelete with default props in action by test order a foodbox
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For reference this is how it's being use for checkout https://github.com/factn/resilience-app/blob/master/src/app/page/Request/foodbox/DeliveryStep.jsx#L113
idk if the final design has the map view or but I guess we can worry about that later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 'final design' is miles behind. Can we pretty pretty please have the map preview turned on? For both address fields?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jwu910 ?
let fundedDateText = mission.fundedDate ? " on " + mission.fundedDate : ""; | ||
switch (mission?.fundedStatus) { | ||
case Mission.FundedStatus.fundedbydonation: | ||
missionFundedStatusText = "Funded By Donation ${fundedDateText}"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incorrect syntax here, these should be in backticks. `` and not quotes.
The linter is catching this warning too
|
||
const MissionFundedStatusRow = ({ classes, mission }) => { | ||
let missionFundedStatusText; | ||
let fundedDateText = mission.fundedDate ? " on " + mission.fundedDate : ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused variable?
missionFundedStatusText = "Not Yet Funded"; | ||
break; | ||
default: | ||
throw Error("mission funded status not exist", mission.fundedStatus); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we still fixing this?
} | ||
renderOption={(group) => ( | ||
<> | ||
<GroupWorkIcon style={{ color: _.randomColor(group.groupDisplayName) }} />{" "} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh okay, I couldn't find random colors on the designs. Might have looked at the wrong frames
move on to another pr #637 |
…volunteer selection.
Related to this ticket ...
#561