diff --git a/app/javascript/api/action-items-api.ts b/app/javascript/api/action-items-api.ts index 9bae47f8..503d43bc 100644 --- a/app/javascript/api/action-items-api.ts +++ b/app/javascript/api/action-items-api.ts @@ -22,7 +22,7 @@ export const actionItemsApi = { return actionItems.data; }, - async updateActionItems(id: number, body?: string, assigneeId?: string, status?: string) { + async updateActionItems(id: number, assigneeId?: string, body?: string, status?: string) { const actionItems = await api.patch>( `action_items/${id}`, { body, assigneeId, status } diff --git a/app/javascript/components/pages/action-items/action-items-container.tsx b/app/javascript/components/pages/action-items/action-items-container.tsx index d0e78661..800877d5 100644 --- a/app/javascript/components/pages/action-items/action-items-container.tsx +++ b/app/javascript/components/pages/action-items/action-items-container.tsx @@ -15,6 +15,10 @@ import { import { ActionItem } from "./action/action-item"; import { actionItemsApi } from "../../../api/action-items-api"; import "../../style.less"; +import {CommentValues, TextModal} from "../../../constants/constants"; +import Modal from "../../shared/modal/modal"; +import ModalConfirm from "../../shared/modal-confirm/modal-confirm"; +import {cardApi} from "../../../api/card-api"; import style from "./style.module.less"; @@ -26,6 +30,8 @@ const ActionItemsContainer: React.FC = () => { const [isModalOpen, setModalOpen] = useState(false); const [cardId, setCardId] = useState(null); + const [confirmComment, setConfirmComment] = useState(""); + const [isError, setIsError] = useState(false); const columns = [ ACTION_ITEM_STATUS.ToDo, ACTION_ITEM_STATUS.InProgress, @@ -48,6 +54,10 @@ const ActionItemsContainer: React.FC = () => { getActionItems(); }, []); + + const isShort = confirmComment.length <= CommentValues.MinLength; + const isLong = confirmComment.length > CommentValues.MaxLength; + const handleOnDragEnd = (items: Array) => (result: DropResult) => { const { destination, draggableId } = result; @@ -72,18 +82,46 @@ const ActionItemsContainer: React.FC = () => { changeStatus(); }; - const handleDeleteItem = async () => { - setModalOpen(false); + const handleDeleteAssignment = async () => { dispatch(actions.pending()); try { - const response = await actionItemsApi.changeActionItemStatus(Number(cardId), ACTION_ITEM_STATUS.Closed) + const response = await actionItemsApi.updateActionItems(Number(cardId), ' '); dispatch(actions.setActionItems(response)); + setIsError(false); } catch (error) { dispatch(actions.rejected()); - alert(`Something went wrong. Error ${error}`); + setIsError(true); + throw new Error(`Something went wrong. Error ${error}`); + } + }; + + const handleAddConfirmComment = async () => { + if (cardId) { + try { + await cardApi.addComment({ + cardId: cardId, + content: confirmComment, + }); + setIsError(false); + } catch (error) { + setIsError(true); + throw new Error(`Something went wrong. Error ${error}`); + } } }; + const handleSubmit = () => { + setConfirmComment(""); + setModalOpen(false); + handleDeleteAssignment(); + //handleAddConfirmComment(); + }; + + const handleCancel = () => { + setConfirmComment(""); + setModalOpen(false); + } + const getColumnName = (name: string) => { switch (name) { case ACTION_ITEM_STATUS.ToDo: @@ -142,25 +180,21 @@ const ActionItemsContainer: React.FC = () => { ))}
-
-
-

Delete file permanently?

-
-
- - -
-
+ + +