diff --git a/src/components/PatternedBackground.tsx b/src/components/PatternedBackground.tsx new file mode 100644 index 00000000..346edcd9 --- /dev/null +++ b/src/components/PatternedBackground.tsx @@ -0,0 +1,34 @@ +const PatternedBackground = () => ( +
+ + + + + + +
+); + +export default PatternedBackground; diff --git a/src/providers/board.tsx b/src/providers/board.tsx index 2e335ddd..2b090216 100644 --- a/src/providers/board.tsx +++ b/src/providers/board.tsx @@ -7,68 +7,26 @@ import React, { import { api } from "~/utils/api"; +import { + GetBoardByIdOutput, + ReorderCardInput, + ReorderListInput, +} from "~/types/router.types"; + interface BoardContextProps { - boardData: BoardData; - setBoardData: React.Dispatch>; - updateList: (params: UpdateListParams) => void; - updateCard: (params: UpdateCardParams) => void; + boardData: GetBoardByIdOutput; + setBoardData: React.Dispatch>; + updateList: (params: ReorderListInput) => void; + updateCard: (params: ReorderCardInput) => void; } -interface BoardData { - name: string; - publicId: string; - labels: Label[]; - lists: List[]; - workspace: { - members: Members[]; - } | null; -} - -interface Label { - publicId: string; - name: string; - colourCode: string | null; -} - -interface List { - publicId: string; - name: string; - boardId: number; - index: number; - cards: Card[]; -} - -interface Members { - publicId: string; - user: { - name: string | null; - } | null; -} - -interface Card { - publicId: string; - title: string; -} - -interface UpdateListParams { - boardId: string; - listId: string; - currentIndex: number; - newIndex: number; -} - -interface UpdateCardParams { - cardId: string; - newListId: string; - newIndex: number; -} - -const initialBoardData: BoardData = { +const initialBoardData: GetBoardByIdOutput = { name: "", publicId: "", lists: [], labels: [], workspace: { + publicId: "", members: [], }, }; @@ -79,10 +37,13 @@ export const BoardProvider: React.FC<{ children: ReactNode }> = ({ children, }) => { const utils = api.useUtils(); - const [boardData, setBoardData] = useState(initialBoardData); + const [boardData, setBoardData] = + useState(initialBoardData); - const refetchBoard = () => - utils.board.byId.refetch({ id: boardData.publicId }); + const refetchBoard = () => { + if (boardData?.publicId) + utils.board.byId.refetch({ boardPublicId: boardData.publicId }); + }; const updateCardMutation = api.card.reorder.useMutation({ onSuccess: async () => { @@ -109,7 +70,7 @@ export const BoardProvider: React.FC<{ children: ReactNode }> = ({ listId, currentIndex, newIndex, - }: UpdateListParams) => { + }: ReorderListInput) => { updateListMutation.mutate({ boardId, listId, @@ -118,7 +79,7 @@ export const BoardProvider: React.FC<{ children: ReactNode }> = ({ }); }; - const updateCard = ({ cardId, newListId, newIndex }: UpdateCardParams) => { + const updateCard = ({ cardId, newListId, newIndex }: ReorderCardInput) => { updateCardMutation.mutate({ cardId, newListId, diff --git a/src/types/database.types.ts b/src/types/database.types.ts index 2882ecfb..4f63ec19 100644 --- a/src/types/database.types.ts +++ b/src/types/database.types.ts @@ -69,56 +69,6 @@ export type Database = { }, ] } - account: { - Row: { - access_token: string | null - expires_at: number | null - id_token: string | null - provider: string - providerAccountId: string - refresh_token: string | null - scope: string | null - session_state: string | null - token_type: string | null - type: string - userId: string - } - Insert: { - access_token?: string | null - expires_at?: number | null - id_token?: string | null - provider: string - providerAccountId: string - refresh_token?: string | null - scope?: string | null - session_state?: string | null - token_type?: string | null - type: string - userId: string - } - Update: { - access_token?: string | null - expires_at?: number | null - id_token?: string | null - provider?: string - providerAccountId?: string - refresh_token?: string | null - scope?: string | null - session_state?: string | null - token_type?: string | null - type?: string - userId?: string - } - Relationships: [ - { - foreignKeyName: "account_userId_user_id_fk" - columns: ["userId"] - isOneToOne: false - referencedRelation: "user" - referencedColumns: ["id"] - }, - ] - } board: { Row: { createdAt: string @@ -425,32 +375,6 @@ export type Database = { }, ] } - session: { - Row: { - expires: string - sessionToken: string - userId: string - } - Insert: { - expires: string - sessionToken: string - userId: string - } - Update: { - expires?: string - sessionToken?: string - userId?: string - } - Relationships: [ - { - foreignKeyName: "session_userId_user_id_fk" - columns: ["userId"] - isOneToOne: false - referencedRelation: "user" - referencedColumns: ["id"] - }, - ] - } user: { Row: { email: string @@ -475,24 +399,6 @@ export type Database = { } Relationships: [] } - verificationToken: { - Row: { - expires: string - identifier: string - token: string - } - Insert: { - expires: string - identifier: string - token: string - } - Update: { - expires?: string - identifier?: string - token?: string - } - Relationships: [] - } workspace: { Row: { createdAt: string diff --git a/src/types/router.types.ts b/src/types/router.types.ts new file mode 100644 index 00000000..8b7d7f6e --- /dev/null +++ b/src/types/router.types.ts @@ -0,0 +1,9 @@ +import { RouterInputs, type RouterOutputs } from "~/utils/api"; + +export type GetBoardByIdOutput = RouterOutputs["board"]["byId"]; +export type ReorderListInput = RouterInputs["list"]["reorder"]; +export type ReorderCardInput = RouterInputs["card"]["reorder"]; +export type UpdateBoardInput = RouterInputs["board"]["update"]; +export type NewListInput = RouterInputs["list"]["create"]; +export type NewCardInput = RouterInputs["card"]["create"]; +export type NewBoardInput = RouterInputs["board"]["create"]; diff --git a/src/views/board/components/DeleteBoardConfirmation.tsx b/src/views/board/components/DeleteBoardConfirmation.tsx index 07f72337..b144fd89 100644 --- a/src/views/board/components/DeleteBoardConfirmation.tsx +++ b/src/views/board/components/DeleteBoardConfirmation.tsx @@ -16,6 +16,13 @@ export function DeleteBoardConfirmation() { }, }); + const handleDeleteBoard = () => { + if (boardData?.publicId) + deleteBoard.mutate({ + boardPublicId: boardData.publicId, + }); + }; + return ( <>
@@ -34,11 +41,7 @@ export function DeleteBoardConfirmation() { Cancel