-
Notifications
You must be signed in to change notification settings - Fork 1
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
📅 Add last updated to resource detail page #474
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,6 +72,7 @@ function ResourceDetail(props) { | |
const [addressString, setAddresString] = useState(''); | ||
const [financialAidDetails, setFinancialAidDetails] = useState(null); | ||
const [contacts, setContacts] = useState(null); | ||
const [lastUpdated, setLastUpdated] = useState(''); | ||
|
||
const updateIsSaved = useCallback( | ||
(savedSet) => { | ||
|
@@ -84,48 +85,51 @@ function ResourceDetail(props) { | |
async function didMount() { | ||
const response = await getResourceByID(match.params.id, true); | ||
if (response !== null) { | ||
const { res } = response; | ||
setName(res.name); | ||
setPhone(res.phoneNumbers); | ||
setAddress(res.address ?? ''); | ||
setAddressLine2(res.addressLine2 ?? ''); | ||
setAptUnitSuite(res.aptUnitSuite ?? ''); | ||
setCity(res.city ?? ''); | ||
setState(res.state ?? ''); | ||
setZip(res.zip ?? ''); | ||
setDescription(res.description); | ||
setLanguages(res.availableLanguages); | ||
setCategory(res.category[0]); | ||
setSubcategory(res.subcategory[0]); | ||
setCost(res.cost); | ||
const { result } = response; | ||
setName(result.name); | ||
setPhone(result.phoneNumbers); | ||
setAddress(result.address ?? ''); | ||
setAddressLine2(result.addressLine2 ?? ''); | ||
setAptUnitSuite(result.aptUnitSuite ?? ''); | ||
setCity(result.city ?? ''); | ||
setState(result.state ?? ''); | ||
setZip(result.zip ?? ''); | ||
setDescription(result.description); | ||
setLanguages(result.availableLanguages); | ||
setCategory(result.category[0]); | ||
setSubcategory(result.subcategory[0]); | ||
setCost(result.cost); | ||
setLat( | ||
res?.geoLocation === null || | ||
res?.geoLocation === undefined || | ||
res?.geoLocation?.coordinates === null || | ||
res?.geoLocation?.coordinates === undefined || | ||
Number.isNaN(res?.geoLocation?.coordinates[1]) | ||
result?.geoLocation === null || | ||
result?.geoLocation === undefined || | ||
result?.geoLocation?.coordinates === null || | ||
result?.geoLocation?.coordinates === undefined || | ||
Number.isNaN(result?.geoLocation?.coordinates[1]) | ||
? 0.0 | ||
: res?.geoLocation?.coordinates[1], | ||
: result?.geoLocation?.coordinates[1], | ||
); | ||
setLng( | ||
res?.geoLocation === null || | ||
res?.geoLocation === undefined || | ||
res?.geoLocation?.coordinates === null || | ||
res?.geoLocation?.coordinates === undefined || | ||
Number.isNaN(res?.geoLocation?.coordinates[0]) | ||
result?.geoLocation === null || | ||
result?.geoLocation === undefined || | ||
result?.geoLocation?.coordinates === null || | ||
result?.geoLocation?.coordinates === undefined || | ||
Number.isNaN(result?.geoLocation?.coordinates[0]) | ||
? 0.0 | ||
: res?.geoLocation?.coordinates[0], | ||
: result?.geoLocation?.coordinates[0], | ||
); | ||
setEmail(res.email ?? ''); | ||
setWebsite(res.website ?? ''); | ||
setEligibility(res.eligibilityRequirements); | ||
setInternalNotes(res.internalNotes); | ||
setEmail(result.email ?? ''); | ||
setWebsite(result.website ?? ''); | ||
setEligibility(result.eligibilityRequirements); | ||
setInternalNotes(result.internalNotes); | ||
setHours( | ||
res.hoursOfOperation ? res.hoursOfOperation.hoursOfOperation : [], | ||
result.hoursOfOperation | ||
? result.hoursOfOperation.hoursOfOperation | ||
: [], | ||
); | ||
setRequiredDocuments(res.requiredDocuments); | ||
setFinancialAidDetails(res.financialAidDetails); | ||
setContacts(res.contacts); | ||
setRequiredDocuments(result.requiredDocuments); | ||
setFinancialAidDetails(result.financialAidDetails); | ||
setContacts(result.contacts); | ||
setLastUpdated(result.lastUpdated ?? ''); | ||
|
||
if (authed) { | ||
let savedSet = new Set(); | ||
|
@@ -390,6 +394,17 @@ function ResourceDetail(props) { | |
id: `resource-eligibilityRequirements-${match.params.id}`, | ||
defaultMessage: eligibility, | ||
})}`} | ||
{lastUpdated && ( | ||
<t style={{ color: 'gray' }}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is a t tag? is there a reason we can't do span/div? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. bruh idk I swear it was used for text but that might've been a completely different project lol |
||
{`\n\n${intl.formatMessage( | ||
detailMessages.lastUpdated, | ||
)} ${intl.formatDate(lastUpdated, { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks for doing the format date! |
||
year: 'numeric', | ||
month: 'long', | ||
day: 'numeric', | ||
})}`} | ||
</t> | ||
)} | ||
</Col> | ||
</Row> | ||
<Row> | ||
|
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.
thanks for changing all this back 😂