Skip to content

Commit

Permalink
Fix v.1 - .slice() method causing client exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
andyclarkemedia committed Aug 19, 2022
1 parent 77e88d4 commit c43c2b8
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 125 deletions.
5 changes: 4 additions & 1 deletion components/elements/carouselItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ const CarouselItem = ({ toggleLanguage, data, toggleLocationPreference, updateCi
}
}

useEffect(() => {
console.log(new Date(data['submissiontimestamp']).toLocaleString().split(',')[1] === undefined)
})

// Get viewport dimensions
const vw = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0)
Expand All @@ -55,7 +58,7 @@ const CarouselItem = ({ toggleLanguage, data, toggleLocationPreference, updateCi

<LocationBoxWrapper>
<DateText >{new Date(data['submissiontimestamp']).toLocaleString().split(',')[0]}</DateText>
<DateText >{new Date(data['submissiontimestamp']).toLocaleString().split(',')[1].slice(0,6)}</DateText>
<DateText >{new Date(data['submissiontimestamp']).toLocaleString().split(',')[1] !== undefined ? new Date(data['submissiontimestamp']).toLocaleString().split(',')[1].slice(0,6) : "-"}</DateText>
</LocationBoxWrapper>
</CarouselBox>
)
Expand Down
7 changes: 5 additions & 2 deletions components/elements/dateFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@ const DateFilter = (props) => {
useEffect(() => {
// Fix to ensure mui selected patterns are correct on load - should be a better method available
// Infrequent behaviour
if (props.toggleDate.endDate.slice(0,5) !== dates.now.slice(0,5)) {
document.querySelector('#custom-date-button').classList += ' Mui-selected'

if ((props.toggleDate.endDate !== undefined) && (dates.now !== undefined)) {
if (props.toggleDate.endDate.slice(0,5) !== dates.now?.slice(0,5)) {
document.querySelector('#custom-date-button').classList += ' Mui-selected'
}
}

})
Expand Down
4 changes: 2 additions & 2 deletions components/elements/floodMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ const FloodMap = ({ toggleLanguage, configureAPI, toggleDate, updateFloodData, u
</TooltipFlex>
<Typography sx={{fontSize: `20px`, fontWeight: (theme) => (theme.typography.fontWeightLight), marginTop: (theme) => (theme.spacing(2))}}>{object.submissionText !== undefined ? "'" + object.submissionText + "'" : uiText.global.tooltips.noComment[toggleLanguage.language]}</Typography>
<TooltipFlex sx={{marginTop: (theme) => (theme.spacing(2))}}>
<Typography sx={{ color: `#888888`, fontSize: `14px`, fontWeight: (theme) => (theme.typography.fontWeightLight)}} >{object?.timestamp ? new Date(object.timestamp).toLocaleString().split(',')[0] : null}</Typography>
<Typography sx={{ color: `#888888`, fontSize: `14px`, fontWeight: (theme) => (theme.typography.fontWeightLight)}} >{object?.timestamp ? new Date(object.timestamp).toLocaleString().split(',')[1].slice(0,6) : null}</Typography>
<Typography sx={{ color: `#888888`, fontSize: `14px`, fontWeight: (theme) => (theme.typography.fontWeightLight)}} >{object?.timestamp ? new Date(object.timestamp).toLocaleString().split(',')[0] : '-'}</Typography>
<Typography sx={{ color: `#888888`, fontSize: `14px`, fontWeight: (theme) => (theme.typography.fontWeightLight)}} >{object?.timestamp ? new Date(object.timestamp).toLocaleString().split(',')[1] !== undefined ? new Date(object.timestamp).toLocaleString().split(',')[1].slice(0,6) : '-' : '-'}</Typography>
</TooltipFlex>
</MyTooltipBox>
) : null;
Expand Down
4 changes: 2 additions & 2 deletions components/elements/rainfallMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ const RainfallMap = ({ toggleLanguage, toggleDate, toggleDataType, mapBoxToken,
</TooltipFlex>
<SubmissionText sx={{fontWeight: (theme) => (theme.typography.fontWeightLight), marginTop: (theme) => (theme.spacing(2))}}>{"'" + object.submissionText + "'"}</SubmissionText>
<TooltipFlex sx={{marginTop: (theme) => (theme.spacing(2))}}>
<DateText sx={{ color: `#888888`, fontSize: `14px`, fontWeight: (theme) => (theme.typography.fontWeightLight)}} >{object?.timestamp ? new Date(object.timestamp).toLocaleString().split(',')[0] : null}</DateText>
<DateText sx={{ color: `#888888`, fontSize: `14px`, fontWeight: (theme) => (theme.typography.fontWeightLight)}} >{object?.timestamp ? new Date(object.timestamp).toLocaleString().split(',')[1].slice(0,6) : null}</DateText>
<DateText sx={{ color: `#888888`, fontSize: `14px`, fontWeight: (theme) => (theme.typography.fontWeightLight)}} >{object?.timestamp ? new Date(object.timestamp).toLocaleString().split(',')[0] : '-'}</DateText>
<DateText sx={{ color: `#888888`, fontSize: `14px`, fontWeight: (theme) => (theme.typography.fontWeightLight)}} >{object?.timestamp ? new Date(object.timestamp).toLocaleString().split(',')[1] !== undefined ? new Date(object.timestamp).toLocaleString().split(',')[1].slice(0,6) : '-' : '-'}</DateText>
</TooltipFlex>
</MyTooltipBox>
);
Expand Down
3 changes: 2 additions & 1 deletion components/elements/searchDropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
removeCitizenRiverFloodEventsData
} from "../../store/actions";
import locationPaths from "../../data/locationPaths";
import locationPathsBR from "../../data/locationPathsBR";
import config from "../../api/config";
import uiText from "../../data/ui-text";
import requestCitizenEvents from "../../api/requestCitizenEvents";
Expand Down Expand Up @@ -112,7 +113,7 @@ const SearchDropdown = ({ configureAPI, toggleDate, toggleGreatestDateRange, tog
<LocationName>{searchResult['placename']}</LocationName>
<DetailsBox>
<HasCitizenDataText>{searchResult['hascitizendata'] ? "": uiText.global.labels.hasNoCitizenData[toggleLanguage.language]}</HasCitizenDataText>
<LocationBox locationName={locationPaths[searchResult['placetype']].text}/>
<LocationBox locationName={toggleLanguage.language === 'en' ? locationPaths[searchResult['placetype']].text : locationPathsBR[searchResult['placetype']].text}/>
</DetailsBox>
</MyListItem>
</ListItemButton>
Expand Down
116 changes: 0 additions & 116 deletions components/modules/cookies.js

This file was deleted.

2 changes: 1 addition & 1 deletion components/modules/landing-page/about.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const About = ({ toggleLanguage }) => {
<AboutVideoBox >
<ReactPlayerWrapper >
<ReactPlayerInnerWrapper>
<ReactPlayer className={styles.reactPlayer} url='https://www.youtube.com/embed/lQUulgzMA18?showinfo=0&enablejsapi=1&origin=http://localhost:3000'/>
<ReactPlayer className={styles.reactPlayer} url={toggleLanguage.language === 'en' ? 'https://www.youtube.com/embed/lQUulgzMA18?showinfo=0&enablejsapi=1&origin=http://localhost:3000' : 'https://www.youtube.com/embed/U92B4gBIgik?showinfo=0&enablejsapi=1&origin=http://localhost:3000'}/>
<div className={styles.reactPlayerBackground}></div>
</ReactPlayerInnerWrapper>
</ReactPlayerWrapper>
Expand Down
14 changes: 14 additions & 0 deletions data/locationPathsBR.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export default {
M: {
text: "Município",
zoom: 8,
},
O: {
text: "Organização",
zoom: 15,
},
E: {
text: "Estado",
zoom: 6,
}
}

0 comments on commit c43c2b8

Please sign in to comment.