Skip to content
This repository has been archived by the owner on Dec 12, 2020. It is now read-only.

add summary document #82

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"@patternfly/react-core": "3.134.2",
"@patternfly/react-inline-edit-extension": "2.15.6",
"@patternfly/react-table": "2.25.6",
"@projectopenubl/xml-builder-react": "^0.1.4",
"@projectopenubl/xml-builder-react": "0.1.6",
"@redhat-cloud-services/frontend-components-notifications": "^0.0.7",
"@types/enzyme": "^3.10.4",
"@types/jest": "24.0.23",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@ import React from "react";
import { TabsDocument } from "@projectopenubl/xml-builder-react";
import { XmlBuilderRouterProps } from "../../../models/routerProps";
import DocumentCreate from "../../../SmartComponents/DocumentCreate";
import { handleDocumentTabRedirect } from "../Utils";

interface StateToProps {}

interface DispatchToProps {}

interface Props extends StateToProps, DispatchToProps, XmlBuilderRouterProps {}
interface Props extends XmlBuilderRouterProps {}

interface State {}

Expand All @@ -17,13 +14,7 @@ export class PageCreateStandardDocument extends React.Component<Props, State> {
eventKey: number | string
): void => {
const { history } = this.props;

const url = `/documents/create`;
if (eventKey === 0) {
history.push(url + "/standard-document");
} else if (eventKey === 1) {
history.push(url + "/voided-document");
}
handleDocumentTabRedirect(history, eventKey);
};

render() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from "react";
import { TabsDocument } from "@projectopenubl/xml-builder-react";
import { XmlBuilderRouterProps } from "../../../models/routerProps";
import DocumentCreate from "../../../SmartComponents/DocumentCreate";
import { handleDocumentTabRedirect } from "../Utils";

interface Props extends XmlBuilderRouterProps {}

interface State {}

export class PageCreateSummaryDocument extends React.Component<Props, State> {
handleOnTabSelect = (
event: React.MouseEvent<HTMLElement, MouseEvent>,
eventKey: number | string
): void => {
const { history } = this.props;
handleDocumentTabRedirect(history, eventKey);
};

render() {
return (
<React.Fragment>
<TabsDocument activeKey={2} onTabSelect={this.handleOnTabSelect}>
<DocumentCreate formType="summary-document" />
</TabsDocument>
</React.Fragment>
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./PageCreateSummaryDocument";
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@ import React from "react";
import { TabsDocument } from "@projectopenubl/xml-builder-react";
import { XmlBuilderRouterProps } from "../../../models/routerProps";
import DocumentCreate from "../../../SmartComponents/DocumentCreate";
import { handleDocumentTabRedirect } from "../Utils";

interface StateToProps {}

interface DispatchToProps {}

interface Props extends StateToProps, DispatchToProps, XmlBuilderRouterProps {}
interface Props extends XmlBuilderRouterProps {}

interface State {}

Expand All @@ -17,13 +14,7 @@ export class PageCreateVoidedDocument extends React.Component<Props, State> {
eventKey: number | string
): void => {
const { history } = this.props;

const url = `/documents/create`;
if (eventKey === 0) {
history.push(url + "/standard-document");
} else if (eventKey === 1) {
history.push(url + "/voided-document");
}
handleDocumentTabRedirect(history, eventKey);
};

render() {
Expand Down
6 changes: 6 additions & 0 deletions src/PresentationalComponents/PageDocuments/PageDocuments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Switch, Route } from "react-router-dom";
import { XmlBuilderRouterProps } from "../../models/routerProps";
import { PageCreateStandardDocument } from "./PageCreateStandardDocument";
import { PageCreateVoidedDocument } from "./PageCreateVoidedDocument";
import { PageCreateSummaryDocument } from "./PageCreateSummaryDocument";

interface StateToProps {}

Expand All @@ -29,6 +30,11 @@ export const PageDocuments: React.FC<Props> = ({ match }) => {
component={PageCreateVoidedDocument}
exact={true}
/>
<Route
path={`${match.path}/create/summary-document`}
component={PageCreateSummaryDocument}
exact={true}
/>
</Switch>
</React.Fragment>
);
Expand Down
13 changes: 13 additions & 0 deletions src/PresentationalComponents/PageDocuments/Utils.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export const handleDocumentTabRedirect = (
history: any,
eventKey: number | string
): void => {
const url = `/documents/create`;
if (eventKey === 0) {
history.push(url + "/standard-document");
} else if (eventKey === 1) {
history.push(url + "/voided-document");
} else if (eventKey === 2) {
history.push(url + "/summary-document");
}
};
22 changes: 21 additions & 1 deletion src/SmartComponents/DocumentCreate/DocumentCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import {
DocumentRequestResponseViewer,
StandardDocumentFormData,
FormVoidedDocument,
FormVoidedDocumentData
FormVoidedDocumentData,
FormSummaryDocument,
FormSummaryDocumentData
} from "@projectopenubl/xml-builder-react";
import { DocumentType } from "../../models/xml-builder";
import { XmlBuilderRouterProps } from "../../models/routerProps";
Expand Down Expand Up @@ -102,6 +104,17 @@ class DocumentCreate extends React.Component<Props, State> {
});
};

handleFormSummaryDocumentSubmit = (
form: FormSummaryDocumentData,
input: any
) => {
this.setState({ requestInput: input }, () => {
let documentType: DocumentType = "summary-document";
this.createDocument(documentType, input);
this.enrichDocument(documentType, input);
});
};

render() {
const { formType } = this.props;
const {
Expand All @@ -124,6 +137,13 @@ class DocumentCreate extends React.Component<Props, State> {
<FormVoidedDocument onSubmit={this.handleFormVoidedDocumentSubmit} />
);
break;
case "summary-document":
form = (
<FormSummaryDocument
onSubmit={this.handleFormSummaryDocumentSubmit}
/>
);
break;
default:
form = <small>No valid form type</small>;
}
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2180,10 +2180,10 @@
resolved "https://registry.yarnpkg.com/@patternfly/react-tokens/-/react-tokens-2.7.25.tgz#69b517f635721bedcefa6b4535688a11586be115"
integrity sha512-04hRDWt07pyjLUO1VN9QbrPpQMJzjd+nQYp8vgoe6+mYBzw+D4banJeudZ1oTFii9hWV+mLEu6aiwPtTigPM1Q==

"@projectopenubl/xml-builder-react@^0.1.4":
version "0.1.4"
resolved "https://registry.yarnpkg.com/@projectopenubl/xml-builder-react/-/xml-builder-react-0.1.4.tgz#8124d95512be176b515ed96072ade4e0f4b43ba7"
integrity sha512-jg4/UeTUFR2MI59wXDAwPHPaa3U2AfdMkWgB5NSt7mzqYEdjkQYd8qJknXsteUwNJ+kdGYZmDxEUZ0S9kDddKg==
"@projectopenubl/[email protected].6":
version "0.1.6"
resolved "https://registry.yarnpkg.com/@projectopenubl/xml-builder-react/-/xml-builder-react-0.1.6.tgz#3d005f017bbfc87b9fda37b24528761322b0c221"
integrity sha512-tou8ogFRhn69JiQEPr4+TF2P0Gz9KGlte0c6I9c4auNgvM60UTCod3AmATHTcCB4i4tSGwt6RzGdx4MOLFdcKQ==
dependencies:
"@testing-library/jest-dom" "^4.2.4"
"@testing-library/react" "^9.3.2"
Expand Down