Skip to content

Commit

Permalink
Resend export win email functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
paulgain committed Feb 26, 2024
1 parent 71afd72 commit 2379568
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 8 deletions.
29 changes: 29 additions & 0 deletions src/client/components/Task/TaskButton.jsx
Original file line number Diff line number Diff line change
@@ -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 }) => (
<Task>
{(getTask) => {
const task = getTask(name, id)
return (
<Task.Status
id={id}
name={name}
renderProgress={ProgressIndicator.Inline}
>
{() => (
<Button
disabled={task.progress}
onClick={() => task.start(startOptions)}
>
{children}
</Button>
)}
</Task.Status>
)
}}
</Task>
)
28 changes: 28 additions & 0 deletions src/client/components/Task/__stories__/TaskButton.stories.jsx
Original file line number Diff line number Diff line change
@@ -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 = () => (
<StyledList>
{[{ id: 1 }, { id: 2 }, { id: 3 }].map((item) => (
<li>
<TaskButton
id={item.id}
name={'TASK_DO_SOMETHING'}
startOptions={{ payload: item.id }}
>
Do Something
</TaskButton>
</li>
))}
</StyledList>
)
23 changes: 15 additions & 8 deletions src/client/modules/ExportWins/Status/WinsSentList.jsx
Original file line number Diff line number Diff line change
@@ -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,
})

Expand Down Expand Up @@ -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={() => (
<ButtonContainer>
<Button as={ReactRouterLink} onClick={() => alert('TODO')}>
<TaskButtonContainer>
<TaskButton
id={item.id}
name={TASK_RESEND_EXPORT_WIN}
startOptions={{ payload: item.id }}
>
Resend export win
</Button>
</ButtonContainer>
</TaskButton>
</TaskButtonContainer>
)}
/>
</li>
Expand Down
1 change: 1 addition & 0 deletions src/client/modules/ExportWins/Status/state.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const TASK_RESEND_EXPORT_WIN = 'TASK_RESEND_EXPORT_WIN'
4 changes: 4 additions & 0 deletions src/client/modules/ExportWins/Status/tasks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { apiProxyAxios } from '../../../components/Task/utils'

export const resendExportWin = (id) =>
apiProxyAxios.post(`/v4/export-win/${id}/resend-win`)
4 changes: 4 additions & 0 deletions src/client/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -697,4 +700,5 @@ export const tasks = {
[TASK_PREVIEW_QUOTE]: previewQuote,
[TASK_CREATE_QUOTE]: createQuote,
[TASK_CANCEL_QUOTE]: cancelQuote,
[TASK_RESEND_EXPORT_WIN]: resendExportWin,
}

0 comments on commit 2379568

Please sign in to comment.