| | |
| | | import DialogCloseButton from "../components/DialogCloseButton"; |
| | | import { format } from 'date-fns'; |
| | | import ArrowBackIosNewIcon from '@mui/icons-material/ArrowBackIosNew'; |
| | | import request from '@/utils/request'; |
| | | |
| | | const MissionResend = ({ open, id }) => { |
| | | const redirect = useRedirect(); |
| | |
| | | </Box> |
| | | )} |
| | | |
| | | <ActionTable actionIds={record?.actionIds} /> |
| | | |
| | | <ActionTable actionIds={record?.actionIds} currCode={record.currCode} handleClose={handleClose} /> |
| | | </Box> |
| | | </Box> |
| | | </Stack> |
| | |
| | | }, |
| | | ]; |
| | | |
| | | const ActionTable = ({ actionIds }) => { |
| | | const ActionTable = ({ actionIds, currCode, handleClose }) => { |
| | | const dataProvider = useDataProvider(); |
| | | const translate = useTranslate(); |
| | | const notify = useNotify(); |
| | | const [actions, setActions] = useState([]); |
| | | const [selected, setSelected] = React.useState([]); |
| | | |
| | |
| | | dataProvider.getMany('action', { ids: actionIds }).then(res => { |
| | | if (res.data?.length > 0) { |
| | | setActions(res.data); |
| | | |
| | | // init selected |
| | | const indexOfCurrCode = res.data.findIndex(item => item.code === currCode); |
| | | if (indexOfCurrCode !== -1) { |
| | | const selectedIds = res.data.slice(indexOfCurrCode).map(item => item.id); |
| | | setSelected(selectedIds); |
| | | } |
| | | } |
| | | }) |
| | | } |
| | |
| | | setSelected(newSelected); |
| | | }; |
| | | |
| | | const resendSubmit = () => { |
| | | if (!!selected?.length) { |
| | | request.post("/mission/resend", selected.map(id => ({ id }))).then(res => { |
| | | const { code, msg, data } = res.data; |
| | | if (code === 200) { |
| | | notify(msg || 'common.response.success', { type: 'success', messageArgs: { _: msg } }); |
| | | handleClose(); |
| | | } else { |
| | | notify(msg || 'common.response.fail', { type: 'error', messageArgs: { _: msg } }); |
| | | } |
| | | }).catch(error => { |
| | | notify(error.message || 'common.response.fail', { type: 'error', messageArgs: { _: error.message } }); |
| | | }) |
| | | } |
| | | } |
| | | |
| | | return ( |
| | | <> |
| | |
| | | </Typography> |
| | | )} |
| | | {selected.length > 0 && ( |
| | | <Tooltip title="Delete"> |
| | | <IconButton> |
| | | <Tooltip title="Resend"> |
| | | <Button |
| | | onClick={() => { |
| | | alert('clicked'); |
| | | }} |
| | | onClick={resendSubmit} |
| | | > |
| | | ss |
| | | {translate('ra.action.confirm')} |
| | | </Button> |
| | | </IconButton> |
| | | </Tooltip> |
| | | )} |
| | | </Toolbar> |