crashing voting history fix

This commit is contained in:
Sendou
2020-01-06 13:31:52 +02:00
parent 1dbbc0c4fb
commit 807a462ac6
2 changed files with 9 additions and 3 deletions

View File

@@ -37,7 +37,6 @@ const summaryMap = summary => {
}
const SummaryLists = ({ summaries }) => {
console.log("summaries", summaries)
const members = []
const suggested = []

View File

@@ -20,7 +20,14 @@ const VotingHistory = () => {
} = useQuery(userLean)
useEffect(() => {
if (loading || error || userQueryLoading || userQueryError) return
if (
loading ||
error ||
userQueryLoading ||
userQueryError ||
!data.summaries
)
return
const monthsYears = data.summaries.reduce(
(acc, cur) => {
@@ -48,12 +55,12 @@ const VotingHistory = () => {
setMonthChoices(monthsYears)
}, [data, loading, error, userQueryLoading, userQueryError, userData])
if (!loading && !data.summaries) return <Redirect to="/access" />
if (loading || userQueryLoading || monthChoices.length === 0)
return <Loading />
if (error) return <Error errorMessage={error.message} />
if (userQueryError) return <Error errorMessage={userQueryError.message} />
if (!userData.user) return <Redirect to="/access" />
if (!data.summaries) return <Redirect to="/404" />
const parts = forms.monthYear.split(" ")
const month = months.indexOf(parts[0])