Skip to content

Commit

Permalink
merge conflicts with develop
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoalzate committed Jun 24, 2024
1 parent 85c263a commit a7679c1
Show file tree
Hide file tree
Showing 13 changed files with 340 additions and 228 deletions.
6 changes: 3 additions & 3 deletions packages/api/src/types/CycleType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ export type GetCycleResponse = {
accepted: boolean;
voteScore?: number;
fundingRequest: string;
user: {
groups: {
user?: {
groups?: {
id: string;
name: string;
groupCategory: {
groupCategory?: {
id: string;
name: string | null;
createdAt: Date;
Expand Down
19 changes: 12 additions & 7 deletions packages/berlin/public/logos/lexicon-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ export const Hearts = styled(FlexRow)`
`;

export const Plurality = styled(FlexRow)`
max-width: 5.5rem;
max-width: 5rem;
padding: 1.5rem;
`;
6 changes: 3 additions & 3 deletions packages/berlin/src/components/dots/Dots.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import { Dot } from './Dots.styled';
type DotsProps = {
dots: number;
activeDotIndex: number;
setStep: React.Dispatch<React.SetStateAction<number>>;
handleClick: (index: number) => void;
};

function Dots({ dots, activeDotIndex, setStep }: DotsProps) {
function Dots({ dots, activeDotIndex, handleClick }: DotsProps) {
return (
<FlexRow>
{Array.from({ length: dots }).map((_, index) => (
<Dot key={index} $active={index === activeDotIndex} onClick={() => setStep(index)} />
<Dot key={index} $active={index === activeDotIndex} onClick={() => handleClick(index)} />
))}
</FlexRow>
);
Expand Down
20 changes: 8 additions & 12 deletions packages/berlin/src/components/header/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// React and third-party libraries
import { useState } from 'react';
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { useLocation, useNavigate } from 'react-router-dom';
import { useState } from 'react';
import { useNavigate } from 'react-router-dom';

// Store
import { useAppStore } from '../../store';
Expand All @@ -21,13 +21,13 @@ import NavButton from '../nav-button';
import ZupassLoginButton from '../zupass-button/ZupassLoginButton';

// Styled components
import IconButton from '../icon-button';
import {
Bar,
BurgerMenuContainer,
DesktopButtons,
HeaderContainer,
LogoContainer,
LogoImage,
LogoSubtitle,
LogoTextContainer,
LogoTitle,
Expand All @@ -38,12 +38,10 @@ import {
StyledHeader,
ThemeButton,
} from './Header.styled';
import IconButton from '../icon-button';

function Header() {
const queryClient = useQueryClient();
const { user } = useUser();
const location = useLocation();
const theme = useAppStore((state) => state.theme);
const toggleTheme = useAppStore((state) => state.toggleTheme);
const navigate = useNavigate();
Expand All @@ -64,13 +62,11 @@ function Header() {
<StyledHeader>
<HeaderContainer>
<LogoContainer onClick={() => navigate('/')}>
<LogoImage src={header.logo.src} alt={header.logo.alt} height={96} width={96} />
{location.pathname === '/' && (
<LogoTextContainer>
<LogoTitle>{header.title}</LogoTitle>
<LogoSubtitle>{header.subtitle}</LogoSubtitle>
</LogoTextContainer>
)}
<img src={`/logos/lexicon-${theme}.svg`} alt="Lexicon Logo" height={64} width={64} />
<LogoTextContainer>
<LogoTitle>{header.title}</LogoTitle>
<LogoSubtitle>{header.subtitle}</LogoSubtitle>
</LogoTextContainer>
</LogoContainer>
<NavContainer>
<NavButtons>
Expand Down
11 changes: 7 additions & 4 deletions packages/berlin/src/components/option-card/OptionCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,17 @@ function OptionCard({

const [expanded, setExpanded] = useState(false);

const author = `${option.user.firstName} ${option.user.lastName}`;
const author = option.user ? `${option.user?.firstName} ${option.user?.lastName}` : 'Anonymous';

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

const coauthors = useMemo(() => {
return optionUsers?.group?.users?.filter(
(optionUser) => optionUser.username !== option.user.username,
(optionUser) => optionUser.username !== option.user?.username,
);
}, [optionUsers, option.user.username]);
}, [optionUsers, option.user?.username]);

return (
<Card $expanded={expanded}>
Expand All @@ -89,7 +89,10 @@ function OptionCard({
</Author>
<Affiliation>
<Field>Affiliation:</Field>
<Body>{option.user?.groups.find((group) => group.groupCategory.required)?.name}</Body>
<Body>
{option.user?.groups?.find((group) => group.groupCategory?.required)?.name ??
'No affiliation'}
</Body>
</Affiliation>
<Votes $showScore={showScore}>
<VotesIcon $gap="-4px">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
// React and third-party libraries
import { useQuery } from '@tanstack/react-query';
import { useMemo } from 'react';

// API
import { fetchOptionUsers, fetchRegistrationData, fetchRegistrationFields } from 'api';

// Store
import { useAppStore } from '../../../store';

// Components
import { Body } from '../../typography/Body.styled';
import { Bold } from '../../typography/Bold.styled';
import { FlexColumn } from '../../containers/FlexColumn.styled';
import { FlexRow } from '../../containers/FlexRow.styled';
import IconButton from '../../icon-button';
import { Body } from '../../typography/Body.styled';
import { Bold } from '../../typography/Bold.styled';

// Styled Components
import { useNavigate } from 'react-router-dom';
import { Card, Funding, Icon, Plurality, TitleContainer } from './ResultsTable.styled';

type ResultsTableProps = {
$expanded: boolean;
eventId?: string;
cycleId?: string;
option: {
optionTitle: string;
pluralityScore: string;
Expand All @@ -31,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 @@ -44,6 +51,44 @@ function ResultsTable({ $expanded, option, onClick }: ResultsTableProps) {
return score % 1 === 0 ? score.toFixed(0) : score.toFixed(3);
}, [option.pluralityScore]);

const { data: optionUsers } = useQuery({
queryKey: ['option', option.id, 'users'],
queryFn: () => fetchOptionUsers(option.id || ''),
enabled: !!option.id,
});

const { data: registrationFields } = useQuery({
queryKey: ['event', eventId, 'registrations', 'fields'],
queryFn: () => fetchRegistrationFields(eventId || ''),
enabled: !!eventId,
});

const { data: registrationData } = useQuery({
queryKey: ['registrations', optionUsers?.registrationId, 'registration-data'],
queryFn: () => fetchRegistrationData(optionUsers?.registrationId || ''),
enabled: !!optionUsers?.registrationId,
});

const researchOutputField = registrationFields?.find(
(field) => field.name === 'Select research output:',
);

const researchOutputValue = registrationData?.find(
(data) => data.registrationFieldId === researchOutputField?.id,
)?.value;

const collaborators = optionUsers?.group?.users
?.filter(
(user) =>
user.firstName !== optionUsers?.user?.firstName ||
user.lastName !== optionUsers?.user?.lastName,
)
.map((user) => `${user.firstName} ${user.lastName}`);

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

return (
<Card $expanded={$expanded} $showFunding={option.allocatedFunding !== null} $rowgap="2rem">
<TitleContainer>
Expand Down Expand Up @@ -116,14 +161,31 @@ function ResultsTable({ $expanded, option, onClick }: ResultsTableProps) {
<FlexColumn className="description">
<Body>{option.optionSubTitle}</Body>
<Body>
<Bold>Distinct voters:</Bold> {option.distinctUsers}
<Bold>Research Output:</Bold> {researchOutputValue}
</Body>
<Body>
<Bold>Lead Author:</Bold> {optionUsers?.user?.firstName} {optionUsers?.user?.lastName}
</Body>
<Body>
<Bold>Distinct groups:</Bold> {option.distinctGroups}
<Bold>Collaborators:</Bold>{' '}
{collaborators && collaborators.length > 0 ? collaborators.join(', ') : 'None'}
</Body>
<Body>
<Bold>Distinct voters:</Bold> {option.distinctUsers}
</Body>
<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
Loading

0 comments on commit a7679c1

Please sign in to comment.