@@ -12,6 +12,7 @@ import Alert from 'react-bootstrap/Alert'
1212import { DocumentControlObj } from "../hooks/DocumentControlContext"
1313import { Loading } from "../components/Loading"
1414import { CreateChangeRequestModal } from "../components/CreateChangeRequestModal"
15+ import { Alerts } from "../components/Alerts"
1516
1617
1718const checkIfPrefix = ( id ) => {
@@ -52,6 +53,7 @@ const onSelect = async (inp, type) => {
5253 return results
5354}
5455
56+
5557const DisplayDocumentBody = ( { setLoading, setErrorMsg} ) => {
5658 const {
5759 woqlClient,
@@ -102,17 +104,44 @@ const DisplayDocumentBody = ({setLoading, setErrorMsg}) => {
102104 />
103105}
104106
107+
108+ const FAKE_ERROR = {
109+ "@type" :"api:InsertDocumentErrorResponse" ,
110+ "api:error" : {
111+ "@type" :"api:SchemaCheckFailure" ,
112+ "api:witnesses" : [
113+ {
114+ "@type" :"ConstraintFailure" ,
115+ "constraint_name" :"MidLifeInsurance" ,
116+ "message" :"Failed to satisfy: 12 > 30\n\n\n In the Constraint:\n\n( 'Policy/3':'Policy'\n ∧ 'Policy/3' =[insurance_product]> 'MidLifeInsurance/Mid-Life%20Insurance%20Product'\n ∧ 'MidLifeInsurance/Mid-Life%20Insurance%20Product':'MidLifeInsurance'\n ) ⇒\n 'Policy/3' =[customer]> 'Customer/Jill+Curry+2'\n ∧ 'Customer/Jill+Curry+2' =[age]> 12\n ∧ « 12 > 30\n » ∧ 12 < 60\n \n"
117+ } ,
118+ {
119+ "@type" :"ConstraintFailure" ,
120+ "constraint_name" :"Policy" ,
121+ "message" :"Failed to satisfy: 12 > 30\n\n\n In the Constraint:\n\n( 'Policy/3':'Policy'\n ∧ 'Policy/3' =[insurance_product]> 'MidLifeInsurance/Mid-Life%20Insurance%20Product'\n ∧ 'MidLifeInsurance/Mid-Life%20Insurance%20Product':'MidLifeInsurance'\n ) ⇒\n 'Policy/3' =[customer]> 'Customer/Jill+Curry+2'\n ∧ 'Customer/Jill+Curry+2' =[age]> 12\n ∧ « 12 > 30\n » ∧ 12 < 60\n \n"
122+ }
123+ ]
124+ } ,
125+ "api:message" :"Schema check failure" ,
126+ "api:status" :"api:failure"
127+ }
128+
105129export const DocumentNew = ( ) => {
106130 const {
107131 setChangeRequestBranch, branch, woqlClient
108132 } = WOQLClientObj ( )
109133
134+ const {
135+ formatErrorMessages
136+ } = DocumentControlObj ( )
137+
110138
111139 const [ showModal , setShowModal ] = useState ( false )
112140 const { type} = useParams ( )
113141
114142 const [ loading , setLoading ] = useState ( false )
115- const [ errorMsg , setErrorMsg ] = useState ( false )
143+ //const [errorMsg, setErrorMsg]=useState(false)
144+ const [ errorMsg , setErrorMsg ] = useState ( FAKE_ERROR )
116145
117146 useEffect ( ( ) => {
118147 if ( branch === "main" ) {
@@ -127,16 +156,17 @@ export const DocumentNew = () => {
127156 // setCurrentMode(currentMode)
128157 }
129158
130- return < main className = "content w-100 document__interface__main" >
131- { errorMsg && < Alert variant = { "danger" } className = "mr-3" >
159+ return < main className = "content w-100 document__interface__main" >
160+ { errorMsg && < Alerts message = { formatErrorMessages ( errorMsg ) } type = { CONST . TERMINUS_DANGER } onCancel = { setErrorMsg } /> }
161+ { /*errorMsg && <Alert variant={"danger"} className="mr-3">
132162 {errorMsg}
133- </ Alert > }
163+ </Alert>*/ }
134164 { showModal && < CreateChangeRequestModal showModal = { showModal }
135165 type = { type }
136166 setShowModal = { setShowModal }
137167 updateViewMode = { updateViewMode } /> }
138168 { branch !== "main" &&
139- < Card className = "mr-3 bg-dark" >
169+ < Card className = "bg-dark" >
140170 < Card . Header className = "justify-content-between d-flex w-100 text-break" >
141171 < Header mode = { CONST . CREATE_DOCUMENT } type = { type } />
142172 </ Card . Header >
0 commit comments