-
Notifications
You must be signed in to change notification settings - Fork 2
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 #1503 from bcgov/external-project-overview
feat: external project overview
- Loading branch information
Showing
7 changed files
with
300 additions
and
3 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
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,93 @@ | ||
import Link from "next/link"; | ||
import TaskListSection from "./TaskListSection"; | ||
|
||
const ExternalTaskList = ({}) => { | ||
return ( | ||
<> | ||
<Link href="/cif-external">{"< Return to Dashboard"}</Link> | ||
<div className="container"> | ||
<ol> | ||
<TaskListSection | ||
key={"tasklist_section_1"} | ||
defaultExpandedState={false} | ||
listItemName={"Application Overview"} | ||
listItemMode={""} | ||
renderCaret={false} | ||
> | ||
{null} | ||
</TaskListSection> | ||
<TaskListSection | ||
key={"tasklist_section_2"} | ||
defaultExpandedState={false} | ||
listItemName={"Attachments"} | ||
listItemMode={""} | ||
renderCaret={false} | ||
> | ||
{null} | ||
</TaskListSection> | ||
<TaskListSection | ||
key={"tasklist_section_3"} | ||
defaultExpandedState={false} | ||
listItemName={"Review"} | ||
listItemMode={""} | ||
renderCaret={false} | ||
> | ||
{null} | ||
</TaskListSection> | ||
<TaskListSection | ||
key={"tasklist_section_4"} | ||
defaultExpandedState={false} | ||
listItemName={"Declarations"} | ||
listItemMode={""} | ||
renderCaret={false} | ||
> | ||
{null} | ||
</TaskListSection> | ||
<TaskListSection | ||
key={"tasklist_section_5"} | ||
defaultExpandedState={false} | ||
listItemName={"Submit"} | ||
listItemMode={""} | ||
renderCaret={false} | ||
> | ||
{null} | ||
</TaskListSection> | ||
</ol> | ||
<style jsx>{` | ||
ol { | ||
list-style: none; | ||
margin: 0; | ||
} | ||
a { | ||
padding: 10px 0 10px 0; | ||
} | ||
h2 { | ||
font-size: 1.25rem; | ||
margin: 0; | ||
padding: 20px 0 10px 0; | ||
border-bottom: 1px solid #d1d1d1; | ||
text-indent: 15px; | ||
} | ||
div :global(a) { | ||
color: #1a5a96; | ||
} | ||
div :global(a:hover) { | ||
text-decoration: none; | ||
color: blue; | ||
} | ||
div.container { | ||
background-color: #e5e5e5; | ||
width: 400px; | ||
margin-top: 20px; | ||
} | ||
`}</style> | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default ExternalTaskList; |
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
59 changes: 59 additions & 0 deletions
59
app/pages/cif-external/project-revision/[projectRevision]/view.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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import withRelayOptions from "lib/relay/withRelayOptions"; | ||
import { graphql, usePreloadedQuery } from "react-relay/hooks"; | ||
import { RelayProps, withRelay } from "relay-nextjs"; | ||
import { viewExternalProjectRevisionQuery } from "__generated__/viewExternalProjectRevisionQuery.graphql"; | ||
import ExternalLayout from "components/Layout/ExternalLayout"; | ||
import ProjectFormSummary from "components/Form/ProjectFormSummary"; | ||
import ExternalTaskList from "components/TaskList/ExternalTaskList"; | ||
import { Button } from "@button-inc/bcgov-theme"; | ||
import { useRouter } from "next/router"; | ||
|
||
const ExternalCifProjectViewQuery = graphql` | ||
query viewExternalProjectRevisionQuery($projectRevision: ID!) { | ||
session { | ||
...ExternalLayout_session | ||
} | ||
projectRevision(id: $projectRevision) { | ||
...ProjectFormSummary_projectRevision | ||
} | ||
} | ||
`; | ||
export function ExternalProjectFormPage({ | ||
preloadedQuery, | ||
}: RelayProps<{}, viewExternalProjectRevisionQuery>) { | ||
const router = useRouter(); | ||
const { session, projectRevision } = usePreloadedQuery( | ||
ExternalCifProjectViewQuery, | ||
preloadedQuery | ||
); | ||
const taskList = <ExternalTaskList />; | ||
let renderList = false; | ||
if ( | ||
router.pathname === "/cif-external/project-revision/[projectRevision]/view" | ||
) { | ||
renderList = true; | ||
} | ||
return ( | ||
<ExternalLayout session={session} leftSideNav={taskList}> | ||
<div className="container"> | ||
<ProjectFormSummary projectRevision={projectRevision} viewOnly={true} /> | ||
{renderList && ( | ||
<Button | ||
size="small" | ||
onClick={() => { | ||
console.log("to be implemented: 🍰"); | ||
}} | ||
> | ||
Next | ||
</Button> | ||
)} | ||
</div> | ||
</ExternalLayout> | ||
); | ||
} | ||
|
||
export default withRelay( | ||
ExternalProjectFormPage, | ||
ExternalCifProjectViewQuery, | ||
withRelayOptions | ||
); |
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
111 changes: 111 additions & 0 deletions
111
app/tests/unit/pages/project-revision/[projectRevision]/form/[formIndex]/external.test.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 |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import "@testing-library/jest-dom"; | ||
import { screen, within } from "@testing-library/react"; | ||
|
||
import PageTestingHelper from "tests/helpers/pageTestingHelper"; | ||
import externalCompiledQuery from "__generated__/viewExternalProjectRevisionQuery.graphql"; | ||
import ExternalProjectFormPage from "pages/cif-external/project-revision/[projectRevision]/view"; | ||
import { FormIndexPageQuery } from "__generated__/FormIndexPageQuery.graphql"; | ||
|
||
const defaultMockResolver = { | ||
ProjectRevision(context, generateId) { | ||
return { | ||
id: `mock-id`, | ||
projectId: 123, | ||
changeStatus: "pending", | ||
projectByProjectId: { | ||
proposalReference: "001", | ||
}, | ||
projectFormChange: { | ||
id: `mock-project-form-${generateId()}`, | ||
newFormData: { | ||
someProjectData: "test2", | ||
}, | ||
asProject: { | ||
fundingStreamRfpByFundingStreamRfpId: { | ||
fundingStreamByFundingStreamId: { | ||
name: "EP", | ||
}, | ||
}, | ||
}, | ||
}, | ||
managerFormChanges: { | ||
edges: [ | ||
{ | ||
node: { | ||
projectManagerLabel: { | ||
id: "Test Label 1 ID", | ||
rowId: 1, | ||
label: "Test Label 1", | ||
}, | ||
formChange: null, | ||
}, | ||
}, | ||
], | ||
}, | ||
milestoneReportStatuses: { | ||
edges: [], | ||
}, | ||
}; | ||
}, | ||
}; | ||
|
||
const externalPageTestingHelper = new PageTestingHelper<FormIndexPageQuery>({ | ||
pageComponent: ExternalProjectFormPage, | ||
compiledQuery: externalCompiledQuery, | ||
defaultQueryResolver: defaultMockResolver, | ||
defaultQueryVariables: { | ||
projectRevision: "mock-id", | ||
}, | ||
}); | ||
|
||
describe("The Project Overview Page (external)", () => { | ||
beforeEach(() => { | ||
externalPageTestingHelper.reinit(); | ||
externalPageTestingHelper.setMockRouterValues({ | ||
pathname: "/cif-external/project-revision/[projectRevision]/view", | ||
query: { projectRevision: "mock-id" }, | ||
}); | ||
}); | ||
|
||
it("renders the task list in the left navigation", () => { | ||
externalPageTestingHelper.loadQuery(); | ||
externalPageTestingHelper.renderPage(); | ||
|
||
expect( | ||
within( | ||
screen.getByRole("navigation", { name: "side navigation" }) | ||
).getByText(/Application Overview/i) | ||
).toBeInTheDocument(); | ||
|
||
expect( | ||
within( | ||
screen.getByRole("navigation", { name: "side navigation" }) | ||
).getByText(/Attachments/i) | ||
).toBeInTheDocument(); | ||
|
||
expect( | ||
within( | ||
screen.getByRole("navigation", { name: "side navigation" }) | ||
).getByText(/Review/i) | ||
).toBeInTheDocument(); | ||
|
||
expect(screen.getByText("< Return to Dashboard")).toBeInTheDocument(); | ||
|
||
expect( | ||
within( | ||
screen.getByRole("navigation", { name: "side navigation" }) | ||
).getByText(/Declaration/i) | ||
).toBeInTheDocument(); | ||
}); | ||
|
||
it("renders the next button", () => { | ||
externalPageTestingHelper.loadQuery(); | ||
externalPageTestingHelper.renderPage(); | ||
screen.logTestingPlaygroundURL(); | ||
expect( | ||
screen.getByRole("button", { | ||
name: /next/i, | ||
}) | ||
).toBeInTheDocument(); | ||
}); | ||
}); |
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