From 3d47c2be7d1195fb882dec049d52d1b09c1a349f Mon Sep 17 00:00:00 2001 From: Diego Alzate Date: Fri, 17 May 2024 18:22:58 +0100 Subject: [PATCH 1/2] remove all types in berlin --- packages/berlin/src/types/ButtonType.ts | 7 --- packages/berlin/src/types/CycleType.ts | 63 ------------------- packages/berlin/src/types/DBEventType.ts | 9 --- .../berlin/src/types/ForumQuestionType.ts | 18 ------ packages/berlin/src/types/GroupType.ts | 7 --- .../src/types/RegistrationFieldOptionType.ts | 7 --- .../berlin/src/types/RegistrationFieldType.ts | 15 ----- packages/berlin/src/types/RegistrationType.ts | 7 --- .../berlin/src/types/UserAttributesType.ts | 8 --- packages/core/src/types/AuthUserType.ts | 7 --- 10 files changed, 148 deletions(-) delete mode 100644 packages/berlin/src/types/ButtonType.ts delete mode 100644 packages/berlin/src/types/CycleType.ts delete mode 100644 packages/berlin/src/types/DBEventType.ts delete mode 100644 packages/berlin/src/types/ForumQuestionType.ts delete mode 100644 packages/berlin/src/types/GroupType.ts delete mode 100644 packages/berlin/src/types/RegistrationFieldOptionType.ts delete mode 100644 packages/berlin/src/types/RegistrationFieldType.ts delete mode 100644 packages/berlin/src/types/RegistrationType.ts delete mode 100644 packages/berlin/src/types/UserAttributesType.ts delete mode 100644 packages/core/src/types/AuthUserType.ts diff --git a/packages/berlin/src/types/ButtonType.ts b/packages/berlin/src/types/ButtonType.ts deleted file mode 100644 index 2a72f69f..00000000 --- a/packages/berlin/src/types/ButtonType.ts +++ /dev/null @@ -1,7 +0,0 @@ -export interface ButtonProps extends React.ButtonHTMLAttributes { - children: React.ReactNode; - color?: 'primary' | 'secondary'; - variant?: 'text' | 'contained'; - center?: boolean; - onClick?: () => void; -} diff --git a/packages/berlin/src/types/CycleType.ts b/packages/berlin/src/types/CycleType.ts deleted file mode 100644 index 39830108..00000000 --- a/packages/berlin/src/types/CycleType.ts +++ /dev/null @@ -1,63 +0,0 @@ -export type Question = { - id: string; - createdAt: string; - updatedAt: string; - description: string | null; - cycleId: string; - title: string; -}; - -export type Option = { - id: string; - createdAt: string; - updatedAt: string; - questionId: string; - text: string; - voteScore: number; -}; - -export type Cycle = { - id: string; - eventId: string | null; - createdAt: string; - updatedAt: string; - status: 'OPEN' | 'CLOSED' | 'RESULTS' | null; - startAt: string; - endAt: string; -}; - -export type ResponseUserVotesType = { - id: string; - userId: string; - optionId: string; - numOfVotes: number; - createdAt: string; - updatedAt: string; -}[]; - -export type ResponseCycleType = { - id: string; - createdAt: string; - updatedAt: string; - status: 'OPEN' | 'CLOSED' | 'RESULTS' | null; - startAt: string; - endAt: string; - forumQuestions: { - id: string; - createdAt: string; - updatedAt: string; - questionSubTitle: string | null; - cycleId: string; - questionTitle: string; - questionOptions: { - id: string; - createdAt: string; - updatedAt: string; - questionId: string; - optionTitle: string; - optionSubTitle?: string; - accepted: boolean; - voteScore: number; - }[]; - }[]; -}[]; diff --git a/packages/berlin/src/types/DBEventType.ts b/packages/berlin/src/types/DBEventType.ts deleted file mode 100644 index 30743ef2..00000000 --- a/packages/berlin/src/types/DBEventType.ts +++ /dev/null @@ -1,9 +0,0 @@ -export type DBEvent = { - id: string; - name: string; - imageUrl: string; - registrationDescription: string | null; - createdAt: string; - updatedAt: string; - description: string | null; -}; diff --git a/packages/berlin/src/types/ForumQuestionType.ts b/packages/berlin/src/types/ForumQuestionType.ts deleted file mode 100644 index 346071e0..00000000 --- a/packages/berlin/src/types/ForumQuestionType.ts +++ /dev/null @@ -1,18 +0,0 @@ -export type GetForumQuestionStatisticsResponse = { - numProposals: number; - sumNumOfHearts: number; - numOfParticipants: number; - numOfGroups: number; - optionStats: Record< - string, - { - optionTitle: string; - pluralityScore: string; - distinctUsers: string; - allocatedHearts: string; - optionSubTitle: string; - distinctGroups: number; - listOfGroupNames: string[]; - } - >; -}; diff --git a/packages/berlin/src/types/GroupType.ts b/packages/berlin/src/types/GroupType.ts deleted file mode 100644 index 72ee81de..00000000 --- a/packages/berlin/src/types/GroupType.ts +++ /dev/null @@ -1,7 +0,0 @@ -export type GetGroupsResponse = { - id: string; - name: string; - description: string; - createdAt: string; - updatedAt: string; -}; diff --git a/packages/berlin/src/types/RegistrationFieldOptionType.ts b/packages/berlin/src/types/RegistrationFieldOptionType.ts deleted file mode 100644 index 032853c4..00000000 --- a/packages/berlin/src/types/RegistrationFieldOptionType.ts +++ /dev/null @@ -1,7 +0,0 @@ -export type RegistrationFieldOption = { - id: string; - createdAt: string; - updatedAt: string; - registrationFieldId: string; - value: string; -}; diff --git a/packages/berlin/src/types/RegistrationFieldType.ts b/packages/berlin/src/types/RegistrationFieldType.ts deleted file mode 100644 index d11741d4..00000000 --- a/packages/berlin/src/types/RegistrationFieldType.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { RegistrationFieldOption } from './RegistrationFieldOptionType'; - -export type GetRegistrationFieldsResponse = { - id: string; - name: string; - createdAt: string; - updatedAt: string; - description: string | null; - eventId: string; - type: 'SELECT' | 'TEXT' | 'NUMBER' | 'DATE' | 'BOOLEAN'; - required: boolean | null; - fieldDisplayRank: number | null; - characterLimit: number; - registrationFieldOptions: RegistrationFieldOption[]; -}[]; diff --git a/packages/berlin/src/types/RegistrationType.ts b/packages/berlin/src/types/RegistrationType.ts deleted file mode 100644 index 9ba88368..00000000 --- a/packages/berlin/src/types/RegistrationType.ts +++ /dev/null @@ -1,7 +0,0 @@ -export type RegistrationStatus = 'DRAFT' | 'APPROVED' | 'PUBLISHED' | null; -export type GetRegistrationResponseType = { - userId: string; - id?: string | undefined; - eventId?: string | undefined; - status: RegistrationStatus; -}; diff --git a/packages/berlin/src/types/UserAttributesType.ts b/packages/berlin/src/types/UserAttributesType.ts deleted file mode 100644 index 71e29a3a..00000000 --- a/packages/berlin/src/types/UserAttributesType.ts +++ /dev/null @@ -1,8 +0,0 @@ -export type GetUserAttributesResponse = { - id: string; - createdAt: Date; - updatedAt: Date; - userId: string; - attributeKey: string; - attributeValue: string; -}[]; diff --git a/packages/core/src/types/AuthUserType.ts b/packages/core/src/types/AuthUserType.ts deleted file mode 100644 index 10bf1bad..00000000 --- a/packages/core/src/types/AuthUserType.ts +++ /dev/null @@ -1,7 +0,0 @@ -export type AuthUser = { - id: string; - username: string | null; - email: string | null; - createdAt: string; - updatedAt: string; -}; From e9b2cc7ebae3f668717d06c8df9533097508a2be Mon Sep 17 00:00:00 2001 From: Diego Alzate Date: Fri, 17 May 2024 18:30:45 +0100 Subject: [PATCH 2/2] remove types from berlin --- packages/berlin/src/pages/Account.tsx | 4 ++-- packages/berlin/src/pages/Comments.tsx | 5 +---- packages/berlin/src/pages/Cycle.tsx | 7 ++----- packages/berlin/src/pages/Event.tsx | 1 - packages/berlin/src/pages/Register.tsx | 6 ++---- 5 files changed, 7 insertions(+), 16 deletions(-) diff --git a/packages/berlin/src/pages/Account.tsx b/packages/berlin/src/pages/Account.tsx index 0c477572..aa001bb8 100644 --- a/packages/berlin/src/pages/Account.tsx +++ b/packages/berlin/src/pages/Account.tsx @@ -15,6 +15,7 @@ import { putUsersToGroups, postUsersToGroups, GetGroupsResponse, + GetEventsResponse, } from 'api'; // Components @@ -37,7 +38,6 @@ import { formatGroups } from '../utils/formatGroups'; import { useAppStore } from '../store'; import { Body } from '../components/typography/Body.styled'; import { useEffect, useMemo } from 'react'; -import { DBEvent } from '../types/DBEventType'; const ACADEMIC_CREDENTIALS = ['Bachelors', 'Masters', 'PhD', 'JD', 'None']; @@ -158,7 +158,7 @@ function AccountForm({ initialUser: InitialUser; user: GetUserResponse | null | undefined; groups: GetGroupsResponse[] | null | undefined; - events: DBEvent[] | null | undefined; + events: GetEventsResponse | null | undefined; }) { const navigate = useNavigate(); const theme = useAppStore((state) => state.theme); diff --git a/packages/berlin/src/pages/Comments.tsx b/packages/berlin/src/pages/Comments.tsx index 50c39795..44d26f2b 100644 --- a/packages/berlin/src/pages/Comments.tsx +++ b/packages/berlin/src/pages/Comments.tsx @@ -25,9 +25,6 @@ import { handleLocalVote, } from '../utils/voting'; -// Types -import { ResponseUserVotesType } from '../types/CycleType'; - // Store import { useAppStore } from '../store'; @@ -46,7 +43,7 @@ import IconButton from '../components/icon-button'; import Textarea from '../components/textarea'; import { INITIAL_HEARTS } from '../utils/constants'; -type LocalUserVotes = ResponseUserVotesType | { optionId: string; numOfVotes: number }[]; +type LocalUserVotes = { optionId: string; numOfVotes: number }[]; function Comments() { const theme = useAppStore((state) => state.theme); diff --git a/packages/berlin/src/pages/Cycle.tsx b/packages/berlin/src/pages/Cycle.tsx index f09a40e9..1cab9e88 100644 --- a/packages/berlin/src/pages/Cycle.tsx +++ b/packages/berlin/src/pages/Cycle.tsx @@ -19,9 +19,6 @@ import { handleLocalVote, } from '../utils/voting'; -// Types -import { ResponseUserVotesType } from '../types/CycleType'; - // Store import { useAppStore } from '../store'; @@ -38,7 +35,7 @@ import OptionCard from '../components/option-card'; import { FIVE_MINUTES_IN_SECONDS, INITIAL_HEARTS } from '../utils/constants'; type Order = 'asc' | 'desc'; -type LocalUserVotes = ResponseUserVotesType | { optionId: string; numOfVotes: number }[]; +type LocalUserVotes = { optionId: string; numOfVotes: number }[]; function Cycle() { const queryClient = useQueryClient(); @@ -116,7 +113,7 @@ function Cycle() { } }, [cycleState, time, formattedTime]); - const updateInitialVotesAndHearts = (votes: ResponseUserVotesType) => { + const updateInitialVotesAndHearts = (votes: GetUserVotesResponse) => { const givenVotes = votes .map((option) => option.numOfVotes) .reduce((prev, curr) => prev + curr, 0); diff --git a/packages/berlin/src/pages/Event.tsx b/packages/berlin/src/pages/Event.tsx index 8428d054..505e90bf 100644 --- a/packages/berlin/src/pages/Event.tsx +++ b/packages/berlin/src/pages/Event.tsx @@ -10,7 +10,6 @@ import { GetCycleResponse, fetchEvent, fetchEventCycles } from 'api'; import { Body } from '../components/typography/Body.styled'; import { FlexColumn } from '../components/containers/FlexColum.styled'; import { Table } from '../components/table'; -// import BackButton from '../components/back-button'; import Button from '../components/button'; import EventCard from '../components/event-card'; import Link from '../components/link'; diff --git a/packages/berlin/src/pages/Register.tsx b/packages/berlin/src/pages/Register.tsx index 2185a88d..5e23649d 100644 --- a/packages/berlin/src/pages/Register.tsx +++ b/packages/berlin/src/pages/Register.tsx @@ -14,6 +14,7 @@ import { fetchRegistrationFields, fetchRegistrations, fetchUsersToGroups, + GetEventResponse, GetRegistrationsResponseType, GetUsersToGroupsResponse, postRegistration, @@ -28,9 +29,6 @@ import { // Hooks import useUser from '../hooks/useUser'; -// Types -import { DBEvent } from '../types/DBEventType'; - // Components import { Error } from '../components/typography/Error.styled'; import { FlexColumn } from '../components/containers/FlexColum.styled'; @@ -242,7 +240,7 @@ function RegisterForm(props: { registrationFields: GetRegistrationFieldsResponse | null | undefined; registrationId: string | null | undefined; groupId: string | null | undefined; - event: DBEvent | null | undefined; + event: GetEventResponse | null | undefined; show: boolean; mode: 'edit' | 'create'; onRegistrationFormCreate?: (newRegistrationId: string) => void;