@@ -37,7 +37,8 @@ import {InfoBlock} from "../components/InfoBlock.jsx";
3737import DOMPurify from "dompurify" ;
3838import { PolicyOverview } from "../policies/PolicyOverview.jsx" ;
3939import { PolicyForm } from "../policies/PolicyForm.jsx" ;
40- import { groupByValues , policyTemplateRegular } from "../utils/Policy.js" ;
40+ import { groupByValues , policyTemplateRegular , policyTemplateStepUp , policyTypes } from "../utils/Policy.js" ;
41+ import PolicyChoiceDialog from "../policies/PolicyChoiceDialog.jsx" ;
4142
4243const confirmationModalOptions = {
4344 makeConnection : "makeConnection" ,
@@ -81,12 +82,19 @@ const ApplicationDetail = ({anonymous, refreshUser}) => {
8182 const [ showPolicyOverview , setShowPolicyOverview ] = useState ( false ) ;
8283 const [ showPolicyDetails , setShowPolicyDetails ] = useState ( false ) ;
8384 const [ currentPolicy , setCurrentPolicy ] = useState ( null ) ;
85+ const [ showNewPolicyChoice , setShowNewPolicyChoice ] = useState ( false ) ;
8486
85- const toPolicyDetail = ( policyIdentifier , allPolicies = policies ) => {
87+ const toPolicyDetail = ( policyIdentifier , allPolicies = policies , policyType = null ) => {
8688 setShowPolicyOverview ( false ) ;
8789 let newCurrentPolicy ;
8890 if ( policyIdentifier === "new" ) {
89- newCurrentPolicy = policyTemplateRegular ( user . identityProvider . data . entityid , serviceProvider . data . entityid ) ;
91+ if ( isEmpty ( policyType ) ) {
92+ setShowNewPolicyChoice ( true ) ;
93+ return ;
94+ } else {
95+ newCurrentPolicy = policyType === policyTypes . step ? policyTemplateStepUp ( user . identityProvider . data . entityid ) :
96+ policyTemplateRegular ( user . identityProvider . data . entityid ) ;
97+ }
9098 } else {
9199 newCurrentPolicy = allPolicies . find ( policy => policy . id === policyIdentifier ) ;
92100 if ( isEmpty ( newCurrentPolicy ) ) {
@@ -95,6 +103,7 @@ const ApplicationDetail = ({anonymous, refreshUser}) => {
95103 }
96104 newCurrentPolicy . data . attributes = groupByValues ( [ ...newCurrentPolicy . data . attributes ] ) ;
97105 }
106+ setShowNewPolicyChoice ( false ) ;
98107 window . scrollTo ( { top : 0 , behavior : "smooth" } ) ;
99108 setCurrentPolicy ( newCurrentPolicy ) ;
100109 setShowPolicyDetails ( true ) ;
@@ -767,6 +776,13 @@ const ApplicationDetail = ({anonymous, refreshUser}) => {
767776
768777 return (
769778 < div className = { `application-detail-container` } >
779+ { showNewPolicyChoice &&
780+ < PolicyChoiceDialog policies = { policies }
781+ close = { ( ) => {
782+ setShowNewPolicyChoice ( false ) ;
783+ setShowPolicyOverview ( true ) ;
784+ } }
785+ confirm = { toPolicyDetail } /> }
770786 { open && < ConfirmationDialog confirm = { action }
771787 cancel = { cancel }
772788 isError = { isError }
@@ -777,7 +793,7 @@ const ApplicationDetail = ({anonymous, refreshUser}) => {
777793 question = { question } >
778794 { confirmationModalChildren ( ) }
779795 </ ConfirmationDialog > }
780- { accessible && renderAccessibleApp ( ) }
796+ { ( ! showNewPolicyChoice && accessible ) && renderAccessibleApp ( ) }
781797 { ! accessible && renderNonAccessibleApp ( ) }
782798 </ div >
783799 ) ;
0 commit comments