From 7134bd569add0092fde6ef51fbe809fcd054ea31 Mon Sep 17 00:00:00 2001 From: Carlos Esteban Feria Vila <2582866+carlosthe19916@users.noreply.github.com> Date: Sat, 22 Feb 2020 22:00:58 +0100 Subject: [PATCH] add summary document --- package.json | 2 +- .../PageCreateStandardDocument.tsx | 15 ++-------- .../PageCreateSummaryDocument.tsx | 29 +++++++++++++++++++ .../PageCreateSummaryDocument/index.ts | 1 + .../PageCreateVoidedDocument.tsx | 15 ++-------- .../PageDocuments/PageDocuments.tsx | 6 ++++ .../PageDocuments/Utils.tsx | 13 +++++++++ .../DocumentCreate/DocumentCreate.tsx | 22 +++++++++++++- yarn.lock | 8 ++--- 9 files changed, 81 insertions(+), 30 deletions(-) create mode 100644 src/PresentationalComponents/PageDocuments/PageCreateSummaryDocument/PageCreateSummaryDocument.tsx create mode 100644 src/PresentationalComponents/PageDocuments/PageCreateSummaryDocument/index.ts create mode 100644 src/PresentationalComponents/PageDocuments/Utils.tsx diff --git a/package.json b/package.json index 508e080..974ff67 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/PresentationalComponents/PageDocuments/PageCreateStandardDocument/PageCreateStandardDocument.tsx b/src/PresentationalComponents/PageDocuments/PageCreateStandardDocument/PageCreateStandardDocument.tsx index c9d98b9..0df3c6c 100644 --- a/src/PresentationalComponents/PageDocuments/PageCreateStandardDocument/PageCreateStandardDocument.tsx +++ b/src/PresentationalComponents/PageDocuments/PageCreateStandardDocument/PageCreateStandardDocument.tsx @@ -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 {} @@ -17,13 +14,7 @@ export class PageCreateStandardDocument extends React.Component { 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() { diff --git a/src/PresentationalComponents/PageDocuments/PageCreateSummaryDocument/PageCreateSummaryDocument.tsx b/src/PresentationalComponents/PageDocuments/PageCreateSummaryDocument/PageCreateSummaryDocument.tsx new file mode 100644 index 0000000..3d11267 --- /dev/null +++ b/src/PresentationalComponents/PageDocuments/PageCreateSummaryDocument/PageCreateSummaryDocument.tsx @@ -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 { + handleOnTabSelect = ( + event: React.MouseEvent, + eventKey: number | string + ): void => { + const { history } = this.props; + handleDocumentTabRedirect(history, eventKey); + }; + + render() { + return ( + + + + + + ); + } +} diff --git a/src/PresentationalComponents/PageDocuments/PageCreateSummaryDocument/index.ts b/src/PresentationalComponents/PageDocuments/PageCreateSummaryDocument/index.ts new file mode 100644 index 0000000..161dd58 --- /dev/null +++ b/src/PresentationalComponents/PageDocuments/PageCreateSummaryDocument/index.ts @@ -0,0 +1 @@ +export * from "./PageCreateSummaryDocument"; diff --git a/src/PresentationalComponents/PageDocuments/PageCreateVoidedDocument/PageCreateVoidedDocument.tsx b/src/PresentationalComponents/PageDocuments/PageCreateVoidedDocument/PageCreateVoidedDocument.tsx index 2ff21bf..0dd77c8 100644 --- a/src/PresentationalComponents/PageDocuments/PageCreateVoidedDocument/PageCreateVoidedDocument.tsx +++ b/src/PresentationalComponents/PageDocuments/PageCreateVoidedDocument/PageCreateVoidedDocument.tsx @@ -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 {} @@ -17,13 +14,7 @@ export class PageCreateVoidedDocument extends React.Component { 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() { diff --git a/src/PresentationalComponents/PageDocuments/PageDocuments.tsx b/src/PresentationalComponents/PageDocuments/PageDocuments.tsx index c7290ff..6f5ca0f 100644 --- a/src/PresentationalComponents/PageDocuments/PageDocuments.tsx +++ b/src/PresentationalComponents/PageDocuments/PageDocuments.tsx @@ -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 {} @@ -29,6 +30,11 @@ export const PageDocuments: React.FC = ({ match }) => { component={PageCreateVoidedDocument} exact={true} /> + ); diff --git a/src/PresentationalComponents/PageDocuments/Utils.tsx b/src/PresentationalComponents/PageDocuments/Utils.tsx new file mode 100644 index 0000000..a46f221 --- /dev/null +++ b/src/PresentationalComponents/PageDocuments/Utils.tsx @@ -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"); + } +}; diff --git a/src/SmartComponents/DocumentCreate/DocumentCreate.tsx b/src/SmartComponents/DocumentCreate/DocumentCreate.tsx index f11e962..d87b1f4 100644 --- a/src/SmartComponents/DocumentCreate/DocumentCreate.tsx +++ b/src/SmartComponents/DocumentCreate/DocumentCreate.tsx @@ -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"; @@ -102,6 +104,17 @@ class DocumentCreate extends React.Component { }); }; + 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 { @@ -124,6 +137,13 @@ class DocumentCreate extends React.Component { ); break; + case "summary-document": + form = ( + + ); + break; default: form = No valid form type; } diff --git a/yarn.lock b/yarn.lock index 7ad1f3f..535f787 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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/xml-builder-react@0.1.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"