diff --git a/client/src/components/desktop/ResourceDetail.jsx b/client/src/components/desktop/ResourceDetail.jsx index 89ad3e71..fb68f0d0 100644 --- a/client/src/components/desktop/ResourceDetail.jsx +++ b/client/src/components/desktop/ResourceDetail.jsx @@ -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 && ( +
+ {`\n\n${intl.formatMessage( + detailMessages.lastUpdated, + )} ${intl.formatDate(lastUpdated, { + year: 'numeric', + month: 'long', + day: 'numeric', + })}`} +
+ )} diff --git a/client/src/components/mobile/ResourceDetailMobile.jsx b/client/src/components/mobile/ResourceDetailMobile.jsx index 8b28f088..33a39e54 100644 --- a/client/src/components/mobile/ResourceDetailMobile.jsx +++ b/client/src/components/mobile/ResourceDetailMobile.jsx @@ -62,14 +62,12 @@ const ResourceDetailMobile = (props: Props) => { const [phone, setPhone] = useState([]); const [address, setAddress] = useState(null); const [addressLine2, setAddressLine2] = useState(null); - // const [aptUnitSuite, setAptUnitSuite] = useState(''); const [city, setCity] = useState(''); const [state, setState] = useState(''); const [zip, setZip] = useState(''); const [languages, setLanguages] = useState([]); const [requiredDocuments, setRequiredDocuments] = useState(null); const [cost, setCost] = useState(null); - // const [internalNotes, setInternalNotes] = useState([]); const [hours, setHours] = useState(null); const [image, setImage] = useState(null); const [financialAidDetails, setFinancialAidDetails] = useState(null); @@ -79,7 +77,7 @@ const ResourceDetailMobile = (props: Props) => { const [lng, setLng] = useState(0); const [distFromResource, setDistFromResource] = useState(null); const [eligibility, setEligibility] = useState(''); - // const [modalVisible, setModalVisible] = useState(false); + const [lastUpdated, setLastUpdated] = useState(''); const [isSaved, setIsSaved] = useState(false); const [isWithinOperationHours, setIsWithinOperationHours] = useState(null); @@ -89,61 +87,62 @@ const ResourceDetailMobile = (props: Props) => { const response = await getResourceByID(resourceId, true); if (response) { - const { res } = response; + const { result } = response; setImage( - res.image && res.image !== '' - ? res.image - : determineStockPhoto(res.category, res.subcategory), + result.image && result.image !== '' + ? result.image + : determineStockPhoto(result.category, result.subcategory), ); - setCategory(res.category[0]); - setSubcategory(res.subcategory[0]); + setCategory(result.category[0]); + setSubcategory(result.subcategory[0]); - setName(res.name); - setDescription(res.description); + setName(result.name); + setDescription(result.description); - setPhone(res.phoneNumbers); - setEmail(res.email); - setWebsite(res.website); + setPhone(result.phoneNumbers); + setEmail(result.email); + setWebsite(result.website); - setLanguages(res.availableLanguages); - setCost(res.cost); + setLanguages(result.availableLanguages); + setCost(result.cost); - setAddress(res.address); - setAddressLine2(res.addressLine2); - setCity(res.city); - setState(res.state); - setZip(res.zip); - setRequiredDocuments(res.requiredDocuments); - setEligibility(res.eligibilityRequirements); - setFinancialAidDetails(res.financialAidDetails); - setContacts(res.contacts); + setAddress(result.address); + setAddressLine2(result.addressLine2); + setCity(result.city); + setState(result.state); + setZip(result.zip); + setRequiredDocuments(result.requiredDocuments); + setEligibility(result.eligibilityRequirements); + setFinancialAidDetails(result.financialAidDetails); + setContacts(result.contacts); + setLastUpdated(result.lastUpdated ?? ''); setHours( - res.hoursOfOperation && - res.hoursOfOperation.hoursOfOperation.length > 0 - ? res.hoursOfOperation.hoursOfOperation + result.hoursOfOperation && + result.hoursOfOperation.hoursOfOperation.length > 0 + ? result.hoursOfOperation.hoursOfOperation : null, ); 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], ); } else { setResourceExists(false); @@ -359,6 +358,19 @@ const ResourceDetailMobile = (props: Props) => { defaultMessage: eligibility, })}`} + + {lastUpdated && ( +
+ {`\n\n${intl.formatMessage( + detailMessages.lastUpdated, + )} ${intl.formatDate(lastUpdated, { + year: 'numeric', + month: 'long', + day: 'numeric', + })}`} +
+ )} +
diff --git a/client/src/utils/messages.js b/client/src/utils/messages.js index 9c3efe70..86b88fd5 100644 --- a/client/src/utils/messages.js +++ b/client/src/utils/messages.js @@ -60,6 +60,10 @@ export const detailMessages = defineMessages({ id: 'detailEligibility', defaultMessage: 'Eligibility Requirements', }, + lastUpdated: { + id: 'lastUpdated', + defaultMessage: 'Last updated', + }, basicInfo: { id: 'detailBasicInfo', defaultMessage: 'Basic Information',