Skip to content

Commit

Permalink
Merge pull request #641 from lexicongovernance/develop
Browse files Browse the repository at this point in the history
v2.5.5
  • Loading branch information
diegoalzate authored Jul 2, 2024
2 parents 744f609 + a07b402 commit 00e0773
Show file tree
Hide file tree
Showing 143 changed files with 1,131 additions and 4,285 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.4",
"prettier": "^3.1.1",
"typescript": "^5.2.2",
"typescript": "^5.5.2",
"vite": "^5.0.0",
"vite-plugin-node-polyfills": "^0.17.0"
}
Expand Down
29 changes: 29 additions & 0 deletions packages/api/src/fetchEventGroupCategories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { GetGroupCategoriesResponse } from './types';

async function fetchEventGroupCategories(
eventId: string,
): Promise<GetGroupCategoriesResponse | null> {
try {
const response = await fetch(
`${import.meta.env.VITE_SERVER_URL}/api/events/${eventId}/group-categories`,
{
credentials: 'include',
headers: {
'Content-Type': 'application/json',
},
},
);

if (!response.ok) {
throw new Error(`HTTP Error! Status: ${response.status}`);
}

const groupCategories = (await response.json()) as { data: GetGroupCategoriesResponse };
return groupCategories.data;
} catch (error) {
console.error('Error fetching cycles:', error);
return null;
}
}

export default fetchEventGroupCategories;
2 changes: 1 addition & 1 deletion packages/api/src/fetchGroupCategories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { GetGroupCategoriesResponse } from './types';

async function fetchGroupCategories(): Promise<GetGroupCategoriesResponse | null> {
try {
const response = await fetch(`${import.meta.env.VITE_SERVER_URL}/api//group-categories`, {
const response = await fetch(`${import.meta.env.VITE_SERVER_URL}/api/group-categories`, {
credentials: 'include',
headers: {
'Content-type': 'application/json',
Expand Down
6 changes: 3 additions & 3 deletions packages/api/src/fetchGroups.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { GetGroupsResponse } from './types';

async function fetchGroups({
groupCategoryName,
groupCategoryId,
}: {
groupCategoryName: string;
groupCategoryId: string;
}): Promise<GetGroupsResponse[] | null> {
try {
const response = await fetch(
`${import.meta.env.VITE_SERVER_URL}/api/group-categories/${groupCategoryName}/groups`,
`${import.meta.env.VITE_SERVER_URL}/api/group-categories/${groupCategoryId}/groups`,
{
credentials: 'include',
headers: {
Expand Down
1 change: 1 addition & 0 deletions packages/api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ export { default as postVotes } from './postVotes';
export { default as putRegistration } from './putRegistration';
export { default as putUser } from './putUser';
export { default as putUsersToGroups } from './putUsersToGroups';
export { default as fetchEventGroupCategories } from './fetchEventGroupCategories';
export * from './types';
18 changes: 15 additions & 3 deletions packages/api/src/types/CycleType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export type GetCycleResponse = {
endAt: string;
forumQuestions: {
id: string;
showScore: boolean;
createdAt: string;
updatedAt: string;
questionSubTitle: string | null;
Expand All @@ -20,12 +21,23 @@ export type GetCycleResponse = {
optionTitle: string;
optionSubTitle?: string;
accepted: boolean;
voteScore?: number;
fundingRequest: string;
user: {
group: {
user?: {
groups?: {
id: string;
name: string;
};
groupCategory?: {
id: string;
name: string | null;
createdAt: Date;
updatedAt: Date;
eventId: string | null;
userCanCreate: boolean;
userCanView: boolean;
required: boolean;
};
}[];
username: string;
firstName: string;
lastName: string;
Expand Down
1 change: 1 addition & 0 deletions packages/api/src/types/GroupCategoryType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export type GetGroupCategoryResponse = {
eventId: string | null;
userCanCreate: boolean;
userCanView: boolean;
required: boolean;
};

export type GetGroupCategoriesResponse = GetGroupCategoryResponse[];
2 changes: 2 additions & 0 deletions packages/api/src/types/GroupType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export type GetGroupsResponse = {
eventId: string;
userCanCreate: boolean;
userCanView: boolean;
required: boolean;
createdAt: string;
updatedAt: string;
};
Expand All @@ -27,6 +28,7 @@ export type PostGroupResponse = {
groupCategoryId: string | null;
name: string;
secret: string | null;
required: boolean;
description: string;
createdAt: string;
updatedAt: string;
Expand Down
1 change: 0 additions & 1 deletion packages/api/src/types/UserType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ export type PutUserRequest = {
lastName: string;
email?: string;
telegram?: string | null;
userAttributes: Record<string, string>;
};
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.
6 changes: 3 additions & 3 deletions packages/berlin/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
// React and third-party libraries
import { RouterProvider, createBrowserRouter, redirect } from 'react-router-dom';
import { QueryClient } from '@tanstack/react-query';
import { RouterProvider, createBrowserRouter, redirect } from 'react-router-dom';

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

// API
import { fetchEvents, fetchUser, fetchCycle, fetchRegistrations } from 'api';
import { fetchCycle, fetchEvents, fetchRegistrations, fetchUser } from 'api';

// Pages
import { default as BerlinLayout } from './layout/index.ts';
import Account from './pages/Account';
import Comments from './pages/Comments.tsx';
import Cycle from './pages/Cycle.tsx';
import DataPolicy from './pages/DataPolicy.tsx';
import Event from './pages/Event.tsx';
import Events from './pages/Events.tsx';
import Holding from './pages/Holding';
import Landing from './pages/Landing';
import Onboarding from './pages/Onboarding';
import Comments from './pages/Comments.tsx';
import PassportPopupRedirect from './pages/Popup';
import PublicGroupRegistration from './pages/PublicGroupRegistration.tsx';
import Register from './pages/Register';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ import styled from 'styled-components';
import { FlexRow } from '../../containers/FlexRow.styled';

export const Card = styled(FlexRow)`
border-bottom: 2px solid var(--color-black);
gap: 0;
width: 100%;
display: none;
@media (min-width: 600px) {
display: flex;
border-bottom: 2px solid var(--color-black);
gap: 0;
width: 100%;
}
`;

export const Proposal = styled(FlexRow)`
Expand Down Expand Up @@ -53,7 +57,7 @@ export const Hearts = styled(FlexRow)`
padding: 1.5rem;
`;

// export const Plurality = styled(FlexRow)`
// max-width: 5.5rem;
// padding: 1.5rem;
// `;
export const Plurality = styled(FlexRow)`
max-width: 5rem;
padding: 1.5rem;
`;
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import IconButton from '../../icon-button';
import { Body } from '../../typography/Body.styled';
import { Affiliation, Lead, Card, Hearts, Proposal } from './CycleColumns.styled';
import { Affiliation, Lead, Card, Hearts, Proposal, Plurality } from './CycleColumns.styled';

type CycleColumnsProps = {
onColumnClick: (column: string) => void;
showScore?: boolean;
};

function CycleColumns({ onColumnClick }: CycleColumnsProps) {
function CycleColumns({ onColumnClick, showScore }: CycleColumnsProps) {
return (
<Card>
<Proposal>
Expand All @@ -25,13 +26,15 @@ function CycleColumns({ onColumnClick }: CycleColumnsProps) {
icon={{ src: `/icons/heart-full.svg`, alt: 'Full heart' }}
/>
</Hearts>
{/* <Plurality onClick={() => onColumnClick('voteScore')}>
<IconButton
$padding={0}
$color="secondary"
icon={{ src: `/icons/plurality-score.svg`, alt: 'Plurality score' }}
/>
</Plurality> */}
{showScore && (
<Plurality onClick={() => onColumnClick('voteScore')}>
<IconButton
$padding={0}
$color="secondary"
icon={{ src: `/icons/plurality-score.svg`, alt: 'Plurality score' }}
/>
</Plurality>
)}
</Card>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ import styled from 'styled-components';
import { Grid } from '../../containers/Grid.styled';

export const Card = styled(Grid)<{ $showFunding: boolean }>`
border-bottom: 2px solid var(--color-black);
grid-template-columns: ${(props) =>
props.$showFunding ? 'auto repeat(3, 48px) 100px' : 'auto repeat(3, 48px)'};
padding: 1.5rem;
display: none;
@media (min-width: 600px) {
border-bottom: 2px solid var(--color-black);
display: grid;
grid-template-columns: ${(props) =>
props.$showFunding ? 'auto repeat(3, 48px) 100px' : 'auto repeat(3, 48px)'};
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
12 changes: 3 additions & 9 deletions packages/berlin/src/components/event-card/EventCard.styled.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
import styled, { css } from 'styled-components';
import styled from 'styled-components';
import { FlexColumn } from '../containers/FlexColumn.styled';
import { FlexRowToColumn } from '../containers/FlexRowToColumn.styled';

export const Card = styled(FlexColumn)<{ $direction?: 'row' | 'column' }>`
export const Card = styled(FlexRowToColumn)`
border-radius: 1rem;
border: 1px solid var(--color-black);
flex-direction: column;
overflow: hidden;
width: 100%;
${(props) =>
props.$direction === 'row' &&
css`
flex-direction: row;
`}
`;

export const ImageContainer = styled.div`
Expand Down
5 changes: 2 additions & 3 deletions packages/berlin/src/components/event-card/EventCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ import Markdown from 'react-markdown';

type EventCardProps = {
event: GetEventResponse;
$direction?: 'row' | 'column';
onClick?: () => void;
};

function EventCard({ event, $direction = 'column', onClick }: EventCardProps) {
function EventCard({ event, onClick }: EventCardProps) {
return (
<Card $direction={$direction}>
<Card>
<ImageContainer>
<img src={event.imageUrl} alt={`${event.name} image`} />
</ImageContainer>
Expand Down
56 changes: 56 additions & 0 deletions packages/berlin/src/components/form/FormInput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { FieldValues, Path, UseFormReturn } from 'react-hook-form';
import { SelectInput } from './SelectInput';
import { TextAreaInput } from './TextAreaInput';
import { TextInput } from './TextInput';
import { NumberInput } from './NumberInput';

export function FormInput<T extends FieldValues>(props: {
form: UseFormReturn<T>;
name: Path<T>;
label: string;
options?: { name: string; value: string }[];
required: boolean | null;
type: string;
}) {
switch (props.type) {
case 'TEXT':
return (
<TextInput
form={props.form}
name={props.name}
label={props.label}
required={props.required}
/>
);
case 'TEXTAREA':
return (
<TextAreaInput
form={props.form}
name={props.name}
label={props.label}
required={props.required}
/>
);
case 'SELECT':
return (
<SelectInput
form={props.form}
name={props.name}
label={props.label}
required={props.required}
options={props.options ?? []}
/>
);
case 'NUMBER':
return (
<NumberInput
form={props.form}
name={props.name}
label={props.label}
required={props.required}
/>
);
default:
return <></>;
}
}
Loading

0 comments on commit 00e0773

Please sign in to comment.