Skip to content

Commit

Permalink
Fix agenda not showing current agenda and cleanup (#2818)
Browse files Browse the repository at this point in the history
  • Loading branch information
vctt94 authored Oct 29, 2020
1 parent db46b99 commit 9011e86
Show file tree
Hide file tree
Showing 13 changed files with 296 additions and 303 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { classNames } from "pi-ui";
import { FormattedMessage as T } from "react-intl";
import AgendaProgressIndicator from "../ProgressIndicator/ProgressIndicator";
import styles from "./AgendaCard.module.css";
import AgendaProgressIndicator from "./ProgressIndicator";
import styles from "./Overview.module.css";

const AgendaCard = ({ agenda, onClick, selectedChoice }) => (
<div
Expand All @@ -10,7 +10,7 @@ const AgendaCard = ({ agenda, onClick, selectedChoice }) => (
onClick && styles.agendaCard
)}
onClick={onClick}>
<div className={styles.bottom}>
<div className={styles.cardBottom}>
<AgendaProgressIndicator
passed={agenda.passed}
inProgress={!agenda.finished}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Overview from "./Overview/Overview";
import AgendaCard from "./AgendaCard/AgendaCard";
import Overview from "./Overview";
import AgendaCard from "./AgendaCard";
import { useState, useEffect, useMemo } from "react";

const AgendaOverview = ({
Expand All @@ -14,16 +14,14 @@ const AgendaOverview = ({
const [selectedChoiceId, setSelectedChoiceId] = useState(selectedChoice);
useEffect(() => {
if (selectedChoice !== selectedChoiceId) {
setSelectedChoiceId(selectedChoice);
setSelectedChoiceId(selectedChoiceId);
}
}, [selectedChoice, selectedChoiceId]);

const hasModifiedChoice = () => selectedChoiceId !== selectedChoice;

const updatePreferences = () => {
if (!hasModifiedChoice()) return;
onUpdateVotePreference(agenda.name, selectedChoiceId);
};

const agendaChoices = agenda.choices;
const choices = useMemo(
() =>
Expand All @@ -41,7 +39,6 @@ const AgendaOverview = ({
passed: agenda.passed,
selectedChoiceId,
activeChoiceId: selectedChoice,
hasModifiedChoice,
choices,
setSelectedChoiceId,
updatePreferences,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { RadioButtonGroup, classNames } from "pi-ui";
import { KeyBlueButton } from "buttons";
import { FormattedMessage as T } from "react-intl";
import ProgressIndicator from "../ProgressIndicator/ProgressIndicator";
import ProgressIndicator from "./ProgressIndicator";
import styles from "./Overview.module.css";

const AgendaDetails = ({ name, onClose, description }) => (
Expand Down Expand Up @@ -37,10 +37,7 @@ const AgendaVotingOptions = ({
label: choiceId,
value: choiceId
}));
const handleChange = (option) => {
setSelected(option.value);
};

const handleChange = (option) => setSelected(option.value);
const showVotingOptions = !!options.length && (!finished || selected);

return (
Expand Down Expand Up @@ -74,7 +71,6 @@ const Overview = ({
agendaDescription,
choices,
selectedChoiceId,
hasModifiedChoice,
closeCurrentAgenda,
setSelectedChoiceId,
updatePreferences,
Expand All @@ -98,7 +94,7 @@ const Overview = ({
{!isFinished && (
<div className={styles.bottomOptions}>
<KeyBlueButton
disabled={!hasModifiedChoice || disabled}
disabled={disabled}
className={styles.updatePreferencesButton}
onClick={updatePreferences}>
<T id="agenda.updatePreference" m="Update Preference" />
Expand Down
Loading

0 comments on commit 9011e86

Please sign in to comment.