generated from xgeekshq/oss-template
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
860850b
commit 05ed385
Showing
89 changed files
with
21,280 additions
and
29,938 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,66 @@ | ||
import fetchData from "../utils/fetchData"; | ||
import { BoardType, UpdateTitleWithToken } from "../types/board"; | ||
import { Nullable } from "../types/common"; | ||
import BoardType, { BoardToAdd } from "../types/board/board"; | ||
import UpdateCardPositionDto from "../types/card/updateCardPosition.dto"; | ||
import UpdateBoardDto from "../types/board/updateBoard"; | ||
import AddCardDto from "../types/card/addCard.dto"; | ||
import DeleteCardDto from "../types/card/deleteCard.dto"; | ||
import UpdateCardDto from "../types/card/updateCard.dto"; | ||
// #region BOARD | ||
|
||
export const postBoard = (newBoard: BoardType): Promise<BoardType> => { | ||
export const createBoardRequest = (newBoard: BoardToAdd): Promise<BoardType> => { | ||
return fetchData(`/boards`, { method: "POST", data: newBoard }); | ||
}; | ||
|
||
export const updateBoardTitle = ({ id, title }: UpdateTitleWithToken): Promise<BoardType> => { | ||
return fetchData(`/boards/${id}/updateTitle`, { method: "PATCH", data: { title } }); | ||
export const updateBoardRequest = ({ board }: UpdateBoardDto): Promise<BoardType> => { | ||
return fetchData(`/boards/${board._id}`, { method: "PUT", data: board }); | ||
}; | ||
|
||
export const getBoard = (id: Nullable<string>): Promise<BoardType> => { | ||
return fetchData<BoardType>(`/boards/${id}`, { method: "POST" }); | ||
}; | ||
|
||
export const getBoardWithAuth = (id: string): Promise<BoardType> => { | ||
export const getBoardRequest = (id: string): Promise<BoardType> => { | ||
return fetchData<BoardType>(`/boards/${id}`); | ||
}; | ||
|
||
export const getBoards = (): Promise<BoardType[]> => { | ||
export const getBoardsRequest = (): Promise<BoardType[]> => { | ||
return fetchData<BoardType[]>(`/boards`); | ||
}; | ||
|
||
export const deleteBoard = async (id: string): Promise<BoardType> => { | ||
export const deleteBoardRequest = async (id: string): Promise<BoardType> => { | ||
return fetchData(`/boards/${id}`, { method: "DELETE" }); | ||
}; | ||
|
||
// #endregion | ||
|
||
// #region CARD | ||
|
||
export const addCardRequest = (addCardDto: AddCardDto): Promise<BoardType> => { | ||
return fetchData<BoardType>(`/boards/${addCardDto.boardId}/card`, { | ||
method: "POST", | ||
data: addCardDto, | ||
}); | ||
}; | ||
|
||
export const updateCardRequest = (updateCard: UpdateCardDto): Promise<BoardType> => { | ||
return fetchData<BoardType>( | ||
updateCard.isCardGroup | ||
? `/boards/${updateCard.boardId}/card/${updateCard.cardId}` | ||
: `/boards/${updateCard.boardId}/card/${updateCard.cardId}/items/${updateCard.cardItemId}`, | ||
{ method: "PUT", data: updateCard } | ||
); | ||
}; | ||
|
||
export const updateCardPositionRequest = ( | ||
updateCardPosition: UpdateCardPositionDto | ||
): Promise<BoardType> => { | ||
return fetchData<BoardType>( | ||
`/boards/${updateCardPosition.boardId}/card/${updateCardPosition.cardId}/updateCardPosition`, | ||
{ method: "PUT", data: updateCardPosition } | ||
); | ||
}; | ||
|
||
export const deleteCardRequest = (deleteCardDto: DeleteCardDto): Promise<BoardType> => { | ||
return fetchData<BoardType>(`/boards/${deleteCardDto.boardId}/card/${deleteCardDto.cardId}`, { | ||
method: "DELETE", | ||
data: deleteCardDto, | ||
}); | ||
}; | ||
|
||
// #endregion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import { Cross1Icon } from "@modulz/radix-icons"; | ||
import { styled } from "../../stitches.config"; | ||
import { | ||
AlertDialog, | ||
AlertDialogAction, | ||
AlertDialogCancel, | ||
AlertDialogContent, | ||
AlertDialogOverlay, | ||
AlertDialogPortal, | ||
AlertDialogTrigger, | ||
} from "../Primitives/AlertDialog"; | ||
import Button from "../Primitives/Button"; | ||
import Text from "../Primitives/Text"; | ||
import Flex from "../Primitives/Flex"; | ||
import ClickEvent from "../../types/events/clickEvent"; | ||
|
||
const CloseButton = styled(AlertDialogCancel, Button, { | ||
position: "relative", | ||
top: "0", | ||
left: "0", | ||
}); | ||
|
||
const ActionButton = styled(AlertDialogAction, Button, { | ||
position: "relative", | ||
top: "0", | ||
left: "0", | ||
}); | ||
|
||
const StyledCrossIcon = styled(Cross1Icon, { size: "$15" }); | ||
|
||
interface BoardAlertDialogProps { | ||
text: string; | ||
defaultOpen: boolean; | ||
handleConfirm: (event: ClickEvent<HTMLButtonElement, MouseEvent>) => void; | ||
handleClose: (event: ClickEvent<HTMLButtonElement, MouseEvent>) => void; | ||
} | ||
|
||
const BoardAlertDialog: React.FC<BoardAlertDialogProps> = ({ | ||
text, | ||
handleConfirm, | ||
handleClose, | ||
defaultOpen, | ||
}) => { | ||
const handleStopPropagation = <T,>(event: ClickEvent<T, MouseEvent>) => { | ||
event.stopPropagation(); | ||
}; | ||
|
||
return ( | ||
<AlertDialog defaultOpen={defaultOpen}> | ||
{!defaultOpen && ( | ||
<AlertDialogTrigger align="center" asChild> | ||
<Button | ||
id="delete-item" | ||
size="20" | ||
onClick={handleStopPropagation} | ||
variant="ghost" | ||
css={{ cursor: "pointer" }} | ||
> | ||
<StyledCrossIcon /> | ||
</Button> | ||
</AlertDialogTrigger> | ||
)} | ||
<AlertDialogPortal> | ||
<AlertDialogOverlay /> | ||
<AlertDialogContent | ||
direction="column" | ||
onClick={handleStopPropagation} | ||
css={{ width: "$400" }} | ||
> | ||
<Text>{text}</Text> | ||
<Flex justify="end" css={{ mt: "$16" }} gap="16"> | ||
<ActionButton size="2" color="red" css={{ width: "10%" }} onClick={handleConfirm}> | ||
Yes | ||
</ActionButton> | ||
<CloseButton | ||
color="blue" | ||
size="2" | ||
css={{ position: "relative", width: "10%" }} | ||
onClick={handleClose} | ||
> | ||
No | ||
</CloseButton> | ||
</Flex> | ||
</AlertDialogContent> | ||
</AlertDialogPortal> | ||
</AlertDialog> | ||
); | ||
}; | ||
|
||
export default BoardAlertDialog; |
Oops, something went wrong.