-
Notifications
You must be signed in to change notification settings - Fork 0
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
Zabilsya
committed
Dec 10, 2024
1 parent
cd52572
commit 55dc510
Showing
10 changed files
with
99 additions
and
14 deletions.
There are no files selected for viewing
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 +1,2 @@ | ||
export * from './useGetRun'; | ||
export * from './useCreateRun'; |
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,24 @@ | ||
import { useMutation, UseMutationResult, useQueryClient } from '@tanstack/react-query'; | ||
import { notification } from 'antd'; | ||
import { getErrorMessage } from '@shared/config'; | ||
|
||
import { runService } from '../../runService'; | ||
import { CreateRunRequest } from '../../types'; | ||
import { RunQueryKey } from '../../keys'; | ||
|
||
/** Hook for creating run (run transfer) */ | ||
export const useCreateRun = (data: CreateRunRequest): UseMutationResult => { | ||
const queryClient = useQueryClient(); | ||
|
||
return useMutation({ | ||
mutationFn: () => runService.createRun(data), | ||
onSuccess: () => { | ||
queryClient.invalidateQueries({ queryKey: [RunQueryKey.GET_RUNS, data.transfer_id] }); | ||
}, | ||
onError: (error) => { | ||
notification.error({ | ||
message: getErrorMessage(error), | ||
}); | ||
}, | ||
}); | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from 'react'; | ||
import { ControlButtons } from '@shared/ui'; | ||
import { Typography } from 'antd'; | ||
import { WarningOutlined } from '@ant-design/icons'; | ||
import { useCreateRun } from '@entities/run'; | ||
|
||
import classes from './styles.module.less'; | ||
import { CreateRunProps } from './types'; | ||
|
||
const { Text } = Typography; | ||
|
||
export const CreateRun = ({ transferId, transferName, onSuccess, onCancel }: CreateRunProps) => { | ||
const { mutate: createRun, isPending } = useCreateRun({ transfer_id: transferId }); | ||
|
||
const handleSubmit = () => { | ||
createRun(null, { onSuccess }); | ||
}; | ||
|
||
return ( | ||
<div className={classes.root}> | ||
<div className={classes.main}> | ||
<WarningOutlined className={classes.icon} /> | ||
<Text> | ||
Do you really want to run transfer <b>«{transferName}»</b>? | ||
</Text> | ||
</div> | ||
<ControlButtons isLoading={isPending} submitButtonText="Confirm" onSubmit={handleSubmit} onCancel={onCancel} /> | ||
</div> | ||
); | ||
}; |
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,20 @@ | ||
.root { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 24px; | ||
|
||
.main { | ||
display: flex; | ||
align-items: flex-start; | ||
gap: 24px; | ||
|
||
.icon { | ||
color: @red-6; | ||
|
||
svg { | ||
width: 24px; | ||
height: 24px; | ||
} | ||
} | ||
} | ||
} |
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,6 @@ | ||
export interface CreateRunProps { | ||
transferId: number; | ||
transferName: string; | ||
onSuccess: () => void; | ||
onCancel: () => void; | ||
} |
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,2 +1,3 @@ | ||
export * from './RunList'; | ||
export * from './RunDetailInfo'; | ||
export * from './CreateRun'; |
7 changes: 3 additions & 4 deletions
7
src/widgets/run/TransferRuns/components/CreateRunButton/components/CreateRunModal/index.tsx
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,14 +1,13 @@ | ||
import React from 'react'; | ||
import { DEFAULT_MODAL_WIDTH } from '@shared/constants'; | ||
import { ModalWrapper } from '@shared/ui'; | ||
import { CreateRun } from '@features/run'; | ||
|
||
import { CreateRunModalProps } from './types'; | ||
|
||
export const CreateRunModal = ({ transferId, transferName, onClose, ...props }: CreateRunModalProps) => { | ||
return ( | ||
<ModalWrapper title="Run transfer" width={DEFAULT_MODAL_WIDTH} onCancel={onClose} {...props}> | ||
{/* //TODO: [DOP-20067] add create run modal */} | ||
{/* <CreateRun transferId={transferId} transferName={transferName} onSuccess={onClose} onCancel={onClose} /> */} | ||
<ModalWrapper title="Run Transfer" width={400} onCancel={onClose} {...props}> | ||
<CreateRun transferId={transferId} transferName={transferName} onSuccess={onClose} onCancel={onClose} /> | ||
</ModalWrapper> | ||
); | ||
}; |
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