-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6501 from uktrade/feature/TET-597-MigrateInvestme…
…ntAdminPageToReactRouter migrate investment admin page to react router
- Loading branch information
Showing
13 changed files
with
110 additions
and
120 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
65 changes: 0 additions & 65 deletions
65
src/apps/investments/views/admin/client/InvestmentProjectAdmin.jsx
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
95 changes: 95 additions & 0 deletions
95
src/client/modules/Investments/Projects/InvestmentProjectAdmin.jsx
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,95 @@ | ||
import React from 'react' | ||
import { useParams } from 'react-router-dom' | ||
|
||
import { H4, InsetText } from 'govuk-react' | ||
import styled from 'styled-components' | ||
import { SPACING } from '@govuk-react/constants' | ||
|
||
import urls from '../../../../lib/urls' | ||
import { | ||
InvestmentProjectStageResource, | ||
InvestmentResource, | ||
} from '../../../components/Resource' | ||
import { buildProjectBreadcrumbs } from '../utils' | ||
import { transformObjectToOption } from '../../../../apps/transformers' | ||
import { | ||
DefaultLayout, | ||
FieldRadios, | ||
Form, | ||
FormLayout, | ||
} from '../../../components' | ||
import { FORM_LAYOUT } from '../../../../common/constants' | ||
import { TASK_UPDATE_STAGE } from './state' | ||
|
||
const StyledP = styled('p')` | ||
margin-bottom: ${SPACING.SCALE_2}; | ||
` | ||
|
||
const InvestmentName = (props) => ( | ||
<InvestmentResource.Inline {...props}> | ||
{(project) => project.name} | ||
</InvestmentResource.Inline> | ||
) | ||
|
||
const InvestmentProjectAdmin = () => { | ||
const { projectId } = useParams() | ||
|
||
return ( | ||
<DefaultLayout | ||
heading="Change the project stage" | ||
pageTitle={ | ||
<> | ||
Admin - <InvestmentName id={projectId} /> - Projects - Investments | ||
</> | ||
} | ||
breadcrumbs={buildProjectBreadcrumbs([ | ||
{ | ||
link: urls.investments.projects.details(projectId), | ||
text: <InvestmentName id={projectId} />, | ||
}, | ||
{ text: 'Admin' }, | ||
])} | ||
useReactRouter={false} | ||
> | ||
<InvestmentResource id={projectId}> | ||
{(project) => ( | ||
<FormLayout setWidth={FORM_LAYOUT.TWO_THIRDS}> | ||
<H4 as="h2">Project details</H4> | ||
<InsetText> | ||
<p>Project name: {project.name}</p> | ||
<StyledP>Current stage: {project.stage.name}</StyledP> | ||
</InsetText> | ||
<Form | ||
cancelRedirectTo={() => | ||
urls.investments.projects.details(projectId) | ||
} | ||
analyticsFormName="investmentProjectAdmin" | ||
flashMessage={() => 'Project stage saved'} | ||
id="investmentProjectAdmin" | ||
redirectTo={() => urls.investments.projects.details(projectId)} | ||
submissionTaskName={TASK_UPDATE_STAGE} | ||
transformPayload={(values) => ({ values, projectId })} | ||
> | ||
<InvestmentProjectStageResource> | ||
{(stages) => ( | ||
<> | ||
<H4 as="h2">Change the stage to</H4> | ||
<FieldRadios | ||
name="projectStageId" | ||
required="Select a new stage" | ||
options={stages | ||
.map((stage) => transformObjectToOption(stage)) | ||
.filter((stage) => stage.value !== project.stage.id)} | ||
/> | ||
</> | ||
)} | ||
</InvestmentProjectStageResource> | ||
</Form> | ||
</FormLayout> | ||
)} | ||
</InvestmentResource> | ||
</DefaultLayout> | ||
) | ||
} | ||
|
||
export default InvestmentProjectAdmin |
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
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