Skip to content

Commit

Permalink
add comments to results page
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoalzate committed Jun 3, 2024
1 parent 392e1af commit 5f3916a
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 9 deletions.
2 changes: 0 additions & 2 deletions packages/berlin/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,6 @@ const router = (queryClient: QueryClient) =>
loader: ({ params }) =>
redirectToCycleIfOpen(queryClient, params.eventId, params.cycleId),
path: ':cycleId/results',
loader: ({ params }) =>
redirectToCycleIfOpen(queryClient, params.eventId, params.cycleId),
Component: Results,
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ import IconButton from '../../icon-button';

// Styled Components
import { Card } from './ResultsTable.styled';
import { useNavigate } from 'react-router-dom';

type ResultsTableProps = {
$expanded: boolean;
eventId?: string;
cycleId?: string;
option: {
optionTitle: string;
pluralityScore: string;
Expand All @@ -35,9 +38,9 @@ type ResultsTableProps = {
onClick: () => void;
};

function ResultsTable({ $expanded, option, onClick }: ResultsTableProps) {
function ResultsTable({ $expanded, option, onClick, cycleId, eventId }: ResultsTableProps) {
const theme = useAppStore((state) => state.theme);

const navigate = useNavigate();
const formattedQuadraticScore = useMemo(() => {
const score = parseFloat(option.quadraticScore);
return score % 1 === 0 ? score.toFixed(0) : score.toFixed(3);
Expand All @@ -54,6 +57,10 @@ function ResultsTable({ $expanded, option, onClick }: ResultsTableProps) {
enabled: !!option.id,
});

const handleCommentsClick = () => {
navigate(`/events/${eventId}/cycles/${cycleId}/options/${option.id}`);
};

return (
<Card
$expanded={$expanded}
Expand Down Expand Up @@ -85,6 +92,16 @@ function ResultsTable({ $expanded, option, onClick }: ResultsTableProps) {
<Body>
<Bold>Voter affiliations:</Bold> {option.listOfGroupNames.join(', ')}
</Body>
<Body>
<IconButton
$padding={0}
$color="secondary"
icon={{ src: `/icons/comments-${theme}.svg`, alt: 'Comments icon' }}
onClick={handleCommentsClick}
$width={24}
$height={24}
/>
</Body>
</FlexColumn>
</Card>
);
Expand Down
2 changes: 1 addition & 1 deletion packages/berlin/src/pages/Account.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ function AccountForm({
icon={{ src: `/icons/add-${theme}.svg`, alt: 'Add icon' }}
/>
</FlexColumn>
<Button type="submit" disabled={isSubmitting}>
<Button type="submit" disabled={isSubmitting || true}>
Submit
</Button>
</FlexColumn>
Expand Down
4 changes: 3 additions & 1 deletion packages/berlin/src/pages/PublicGroupRegistration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ function PublicGroupRegistration() {
/>
)}
/>
<Button type="submit">Join group</Button>
<Button disabled type="submit">
Join group
</Button>
</Form>
</FlexColumn>
);
Expand Down
2 changes: 1 addition & 1 deletion packages/berlin/src/pages/Register.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ function RegisterForm(props: {
/>
))}
</Form>
<Button onClick={handleSubmit(onSubmit)} disabled={isSubmitting || isPending}>
<Button onClick={handleSubmit(onSubmit)} disabled={isSubmitting || isPending || true}>
Save
</Button>
</FlexColumn>
Expand Down
2 changes: 2 additions & 0 deletions packages/berlin/src/pages/Results.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ function Results() {
key={option.id}
$expanded={expandedIndex === index}
option={option}
cycleId={cycleId}
eventId={eventId}
onClick={() => setExpandedIndex(expandedIndex === index ? null : index)}
/>
))}
Expand Down
10 changes: 8 additions & 2 deletions packages/berlin/src/pages/SecretGroupRegistration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,11 @@ function SecretGroupRegistration() {
open={isDialogOpen}
onOpenChange={setIsDialogOpen}
trigger={
<Button style={{ marginTop: 'auto' }} onClick={() => setIsDialogOpen(true)}>
<Button
disabled
style={{ marginTop: 'auto' }}
onClick={() => setIsDialogOpen(true)}
>
{groups.create.buttonText}
</Button>
}
Expand Down Expand Up @@ -174,7 +178,9 @@ function SecretGroupRegistration() {
errors={errors?.secret?.message ? [errors.secret.message] : []}
required
/>
<Button type="submit">{groups.join.buttonText}</Button>
<Button disabled type="submit">
{groups.join.buttonText}
</Button>
</Form>
</FlexColumn>
</FlexRowToColumn>
Expand Down

0 comments on commit 5f3916a

Please sign in to comment.