feat: complete deal
This commit is contained in:
@@ -59,6 +59,29 @@ export const LeadsPage: FC = () => {
|
||||
}
|
||||
});
|
||||
}
|
||||
const onSuccess = (dealId: number) => {
|
||||
const summary = summaries.find(summary => summary.id == dealId);
|
||||
if (!summary) return;
|
||||
modals.openConfirmModal({
|
||||
title: "Завершение сделки",
|
||||
children:
|
||||
<Flex>
|
||||
Вы действительно хотите завершить сделку {summary.name}?
|
||||
</Flex>,
|
||||
onConfirm: () => {
|
||||
DealService.completeDeal({requestBody: {dealId: dealId}})
|
||||
.then(async ({ok, message}) => {
|
||||
notifications.guess(ok, {message});
|
||||
if (!ok) return;
|
||||
await refetch();
|
||||
})
|
||||
},
|
||||
labels: {
|
||||
confirm: "Завершить",
|
||||
cancel: "Отмена"
|
||||
}
|
||||
});
|
||||
}
|
||||
const onDragEnd = async (result: DropResult) => {
|
||||
setIsDragEnded(true);
|
||||
// If there is no changes
|
||||
@@ -78,6 +101,10 @@ export const LeadsPage: FC = () => {
|
||||
onDelete(dealId);
|
||||
return;
|
||||
}
|
||||
if (droppableId === 'SUCCESS') {
|
||||
onSuccess(dealId);
|
||||
return;
|
||||
}
|
||||
const status = getDealStatusByName(droppableId);
|
||||
const request: Partial<DealSummaryReorderRequest> = {
|
||||
dealId: dealId,
|
||||
@@ -122,7 +149,13 @@ export const LeadsPage: FC = () => {
|
||||
}
|
||||
const getBoardBody = () => {
|
||||
return (
|
||||
|
||||
<motion.div
|
||||
style={{
|
||||
display: "flex",
|
||||
height: "100%",
|
||||
flex: 1
|
||||
}}
|
||||
key={displayMode}
|
||||
initial={{opacity: 0}}
|
||||
animate={{opacity: 1}}
|
||||
@@ -134,78 +167,120 @@ export const LeadsPage: FC = () => {
|
||||
setIsDragEnded(false);
|
||||
}}
|
||||
onDragEnd={onDragEnd}>
|
||||
<div className={styles['boards']}>
|
||||
<Board
|
||||
withCreateButton
|
||||
summaries={summaries
|
||||
.filter(summary => summary.status == DealStatus.AWAITING_ACCEPTANCE)}
|
||||
title={"Ожидает приемки"}
|
||||
droppableId={"AWAITING_ACCEPTANCE"}
|
||||
color={'#4A90E2'}
|
||||
/>
|
||||
<Board
|
||||
summaries={summaries
|
||||
.filter(summary => summary.status == DealStatus.PACKAGING)}
|
||||
title={"Упаковка"}
|
||||
droppableId={"PACKAGING"}
|
||||
color={'#F5A623'}
|
||||
<Flex
|
||||
justify={"space-between"}
|
||||
direction={"column"}
|
||||
style={{flex: 1}}
|
||||
>
|
||||
|
||||
/>
|
||||
<Board
|
||||
summaries={summaries
|
||||
.filter(summary => summary.status == DealStatus.AWAITING_SHIPMENT)}
|
||||
title={"Ожидает отгрузки"}
|
||||
droppableId={"AWAITING_SHIPMENT"}
|
||||
color={'#7ED321'}
|
||||
<div className={styles['boards']}>
|
||||
<Board
|
||||
withCreateButton
|
||||
summaries={summaries
|
||||
.filter(summary => summary.status == DealStatus.AWAITING_ACCEPTANCE)}
|
||||
title={"Ожидает приемки"}
|
||||
droppableId={"AWAITING_ACCEPTANCE"}
|
||||
color={'#4A90E2'}
|
||||
/>
|
||||
<Board
|
||||
summaries={summaries
|
||||
.filter(summary => summary.status == DealStatus.PACKAGING)}
|
||||
title={"Упаковка"}
|
||||
droppableId={"PACKAGING"}
|
||||
color={'#F5A623'}
|
||||
|
||||
/>
|
||||
<Board
|
||||
summaries={summaries
|
||||
.filter(summary => summary.status == DealStatus.AWAITING_PAYMENT)}
|
||||
title={"Ожидает оплаты"}
|
||||
droppableId={"AWAITING_PAYMENT"}
|
||||
color={'#D0021B'}
|
||||
/>
|
||||
<Board
|
||||
summaries={summaries
|
||||
.filter(summary => summary.status == DealStatus.AWAITING_SHIPMENT)}
|
||||
title={"Ожидает отгрузки"}
|
||||
droppableId={"AWAITING_SHIPMENT"}
|
||||
color={'#7ED321'}
|
||||
|
||||
/>
|
||||
<Board
|
||||
summaries={summaries
|
||||
.filter(summary => summary.status == DealStatus.COMPLETED)}
|
||||
title={"Завершена"}
|
||||
droppableId={"COMPLETED"}
|
||||
color={'#417505'}
|
||||
/>
|
||||
</div>
|
||||
<Flex justify={"flex-end"}>
|
||||
<div
|
||||
className={
|
||||
classNames(
|
||||
styles['delete'],
|
||||
isDragEnded && styles['delete-hidden']
|
||||
)
|
||||
}
|
||||
>
|
||||
<Droppable droppableId={"DELETE"}>
|
||||
{(provided) => (
|
||||
<>
|
||||
<div
|
||||
{...provided.droppableProps}
|
||||
ref={provided.innerRef}
|
||||
>
|
||||
{!isDragEnded &&
|
||||
<span>
|
||||
/>
|
||||
<Board
|
||||
summaries={summaries
|
||||
.filter(summary => summary.status == DealStatus.AWAITING_PAYMENT)}
|
||||
title={"Ожидает оплаты"}
|
||||
droppableId={"AWAITING_PAYMENT"}
|
||||
color={'#D0021B'}
|
||||
|
||||
/>
|
||||
<Board
|
||||
summaries={summaries
|
||||
.filter(summary => summary.status == DealStatus.COMPLETED)}
|
||||
title={"Завершена"}
|
||||
droppableId={"COMPLETED"}
|
||||
color={'#417505'}
|
||||
/>
|
||||
</div>
|
||||
<Flex justify={"space-between"} gap={rem(10)}>
|
||||
<div
|
||||
className={
|
||||
classNames(
|
||||
styles['delete'],
|
||||
isDragEnded && styles['delete-hidden']
|
||||
)
|
||||
}
|
||||
>
|
||||
<Droppable droppableId={"DELETE"}>
|
||||
{(provided, snapshot) => (
|
||||
<>
|
||||
<div
|
||||
{...provided.droppableProps}
|
||||
ref={provided.innerRef}
|
||||
>
|
||||
{
|
||||
!isDragEnded
|
||||
&&
|
||||
!snapshot.isDraggingOver &&
|
||||
<span>
|
||||
Удалить
|
||||
</span>
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
</div>
|
||||
{provided.placeholder}
|
||||
</>
|
||||
</div>
|
||||
{provided.placeholder}
|
||||
</>
|
||||
|
||||
)}
|
||||
</Droppable>
|
||||
</div>
|
||||
)}
|
||||
</Droppable>
|
||||
</div>
|
||||
<div
|
||||
className={
|
||||
classNames(
|
||||
styles['delete'],
|
||||
isDragEnded && styles['delete-hidden']
|
||||
)
|
||||
}
|
||||
>
|
||||
<Droppable droppableId={"SUCCESS"}>
|
||||
{(provided, snapshot) => (
|
||||
<>
|
||||
<div
|
||||
{...provided.droppableProps}
|
||||
ref={provided.innerRef}
|
||||
>
|
||||
{
|
||||
!isDragEnded
|
||||
&&
|
||||
!snapshot.isDraggingOver &&
|
||||
<span>
|
||||
Успешно завершена
|
||||
</span>
|
||||
|
||||
}
|
||||
</div>
|
||||
{provided.placeholder}
|
||||
</>
|
||||
|
||||
)}
|
||||
</Droppable>
|
||||
</div>
|
||||
</Flex>
|
||||
</Flex>
|
||||
|
||||
</DragDropContext>
|
||||
</motion.div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user