diff --git a/src/client/components/Task/TaskButton.jsx b/src/client/components/Task/TaskButton.jsx new file mode 100644 index 00000000000..009be6011c3 --- /dev/null +++ b/src/client/components/Task/TaskButton.jsx @@ -0,0 +1,29 @@ +import React from 'react' +import Button from '@govuk-react/button' + +import ProgressIndicator from '../ProgressIndicator' +import Task from '.' + +export const TaskButton = ({ id, name, startOptions, children }) => ( + + {(getTask) => { + const task = getTask(name, id) + return ( + + {() => ( + + )} + + ) + }} + +) diff --git a/src/client/components/Task/__stories__/TaskButton.stories.jsx b/src/client/components/Task/__stories__/TaskButton.stories.jsx new file mode 100644 index 00000000000..ade516f2ac9 --- /dev/null +++ b/src/client/components/Task/__stories__/TaskButton.stories.jsx @@ -0,0 +1,28 @@ +import React from 'react' +import styled from 'styled-components' + +import { TaskButton } from '../TaskButton' + +export default { + title: 'Task/TaskButton', +} + +const StyledList = styled('ul')({ + listStyleType: 'none', +}) + +export const List = () => ( + + {[{ id: 1 }, { id: 2 }, { id: 3 }].map((item) => ( +
  • + + Do Something + +
  • + ))} +
    +) diff --git a/src/client/modules/ExportWins/Status/WinsSentList.jsx b/src/client/modules/ExportWins/Status/WinsSentList.jsx index d88e1b7b8fe..e32d9b6eeec 100644 --- a/src/client/modules/ExportWins/Status/WinsSentList.jsx +++ b/src/client/modules/ExportWins/Status/WinsSentList.jsx @@ -1,16 +1,16 @@ import React from 'react' -import { Link as ReactRouterLink } from 'react-router-dom' -import { Button } from 'govuk-react' import styled from 'styled-components' import ExportWinsResource from '../../../components/Resource/ExportWins' +import { TaskButton } from '../../../components/Task/TaskButton' import { currencyGBP } from '../../../utils/number-utils' import { formatMediumDate } from '../../../utils/date' import { CollectionItem } from '../../../components' +import { TASK_RESEND_EXPORT_WIN } from './state' import { WIN_FILTERS } from './constants' import urls from '../../../../lib/urls' -const ButtonContainer = styled('div')({ +const TaskButtonContainer = styled('div')({ marginTop: 10, }) @@ -38,16 +38,23 @@ export default () => ( label: 'Total value: ', value: currencyGBP(item.total_expected_export_value), }, - { label: 'Date won: ', value: formatMediumDate(item.date) }, + { + label: 'Date won: ', + value: formatMediumDate(item.date), + }, { label: 'First sent: ', value: '???' }, { label: 'Last sent: ', value: '???' }, ]} buttonRenderer={() => ( - - - + + )} /> diff --git a/src/client/modules/ExportWins/Status/state.js b/src/client/modules/ExportWins/Status/state.js new file mode 100644 index 00000000000..183638e99ec --- /dev/null +++ b/src/client/modules/ExportWins/Status/state.js @@ -0,0 +1 @@ +export const TASK_RESEND_EXPORT_WIN = 'TASK_RESEND_EXPORT_WIN' diff --git a/src/client/modules/ExportWins/Status/tasks.js b/src/client/modules/ExportWins/Status/tasks.js new file mode 100644 index 00000000000..0563fb8c0b9 --- /dev/null +++ b/src/client/modules/ExportWins/Status/tasks.js @@ -0,0 +1,4 @@ +import { apiProxyAxios } from '../../../components/Task/utils' + +export const resendExportWin = (id) => + apiProxyAxios.post(`/v4/export-win/${id}/resend-win`) diff --git a/src/client/tasks.js b/src/client/tasks.js index b0fa0fae350..0e370c1af95 100644 --- a/src/client/tasks.js +++ b/src/client/tasks.js @@ -444,6 +444,9 @@ import { getExportWin, } from '../client/modules/ExportWins/Form/tasks' +import { resendExportWin } from '../client/modules/ExportWins/Status/tasks' +import { TASK_RESEND_EXPORT_WIN } from './modules/ExportWins/Status/state' + export const tasks = { 'Create list': createList, 'Edit company': editCompany, @@ -697,4 +700,5 @@ export const tasks = { [TASK_PREVIEW_QUOTE]: previewQuote, [TASK_CREATE_QUOTE]: createQuote, [TASK_CANCEL_QUOTE]: cancelQuote, + [TASK_RESEND_EXPORT_WIN]: resendExportWin, }