@@ -11,12 +11,14 @@ import {APPLICATION_LINKS, providerDescription, providerName, providerOrganizati
1111import { isEmpty , stopEvent } from "../utils/Utils.js" ;
1212import { useAppStore } from "../stores/AppStore.js" ;
1313import { useShallow } from "zustand/react/shallow" ;
14+ import ConfirmationDialog from "../components/ConfirmationDialog.jsx" ;
1415
15- const ApplicationDetail = ( ) => {
16+ const ApplicationDetail = ( { anonymous } ) => {
1617
17- const { arp, privacy} = useAppStore ( useShallow ( state => ( {
18+ const { arp, privacy, user } = useAppStore ( useShallow ( state => ( {
1819 arp : state . arp ,
19- privacy : state . privacy
20+ privacy : state . privacy ,
21+ user : state . user
2022 } ) ) ) ;
2123
2224 const navigate = useNavigate ( ) ;
@@ -26,6 +28,7 @@ const ApplicationDetail = () => {
2628 const [ serviceProvider , setServiceProvider ] = useState ( [ ] ) ;
2729 const [ showAttributes , setShowAttributes ] = useState ( false ) ;
2830 const [ showPrivacy , setShowPrivacy ] = useState ( false ) ;
31+ const [ confirmation , setConfirmation ] = useState ( { } ) ;
2932
3033 useEffect ( ( ) => {
3134 publicServiceProviderByDetail ( manageType , manageId )
@@ -76,19 +79,75 @@ const ApplicationDetail = () => {
7679 return arp . attributes . find ( attr => attr . urn === urn ) ;
7780 }
7881
82+ const mayConnectWithoutInteraction = ( ) => {
83+ const connectOption = metaData [ "coin:dashboard_connect_option" ] || "connect_with_interaction" ;
84+ const sameInstitution = ! isEmpty ( metaData [ "coin:institution_guid" ] ) &&
85+ metaData [ "coin:institution_guid" ] === user . identityProvider . data . metaDataFields [ "coin:institution_guid" ]
86+ return connectOption !== "connect_with_interaction" || sameInstitution ;
87+ }
88+
89+ const openConnectDialog = ( ) => {
90+ setConfirmation ( {
91+ open : true ,
92+ cancel : ( ) => setConfirmation ( { open : false } ) ,
93+ action : ( ) => doDelete ( invitation , false ) ,
94+ question : I18n . t ( "invitationsManagement.deleteConfirmation" , { email : invitation . inviter . name } ) ,
95+ okButton : I18n . t ( "invitationsManagement.revoke" )
96+ } ) ;
97+ }
98+
99+ const doRequestConnection = ( ) => {
100+
101+ }
102+
103+ const openRequestConnectionDialog = ( ) => {
104+ setConfirmation ( {
105+ open : true ,
106+ cancel : ( ) => setConfirmation ( { open : false } ) ,
107+ action : ( ) => doDelete ( invitation , false ) ,
108+ question : I18n . t ( "invitationsManagement.deleteConfirmation" , { email : invitation . inviter . name } ) ,
109+ okButton : I18n . t ( "invitationsManagement.revoke" )
110+ } ) ;
111+ }
112+
113+ const goBack = e => {
114+ stopEvent ( e ) ;
115+ navigate ( - 1 ) ;
116+ }
117+
118+ const connectButtonText = ( ) => {
119+ //Is the app already connected, may the app be connected without interaction, or is there already an outstanding change request?
120+ return I18n . t ( `applicationConnect.${ mayConnectWithoutInteraction ( ) ? "connect" : "request" } ` )
121+ }
122+
123+ const { open, cancel, action, question, okButton, children} = confirmation ;
124+
79125 return (
80126 < div className = "application-detail-container" >
81- < div className = "application-detail-header-container" >
127+ { open && < ConfirmationDialog confirm = { action }
128+ cancel = { cancel }
129+ confirmationHeader = { I18n . t ( "forms.submit" ) }
130+ confirmationTxt = { okButton }
131+ question = { question } >
132+ { children }
133+ </ ConfirmationDialog >
134+ }
135+ { anonymous && < div className = "application-detail-header-container" >
82136 < div className = "application-detail-header" >
83137 < div className = "left" >
84138 < h1 className = "large" > { I18n . t ( "applicationDetail.title" ) } </ h1 >
85139 < p > { I18n . t ( "applicationDetail.subTitle" ) } </ p >
86140 </ div >
87141 < img src = { StudentPng } alt = "student" />
88142 </ div >
89- </ div >
143+ </ div > }
144+ { ! anonymous &&
145+ < div className = "application-detail-top" >
146+ < a href = { "/" } onClick = { goBack } > { I18n . t ( "applicationConnect.back" ) } </ a >
147+ </ div >
148+ }
90149 < div className = "inner-application-detail-container" >
91- < div className = " application-detail" >
150+ < div className = { ` application-detail ${ anonymous ? "" : "stand-alone" } ` } >
92151 < div className = "meta-data" >
93152 { metaData [ "logo:0:url" ] && < img src = { metaData [ "logo:0:url" ] } alt = "" /> }
94153 { ! metaData [ "logo:0:url" ] && < PlaceHolderImage /> }
@@ -100,11 +159,13 @@ const ApplicationDetail = () => {
100159 { providerName ( I18n . locale , serviceProvider ) }
101160 </ p >
102161 </ div >
103- < Button type = { ButtonType . Secondary }
104- icon = { < ArrowLeftIcon /> }
105- iconPlacement = { ButtonIconPlacement . Left }
106- onClick = { ( ) => navigate ( - 1 ) }
107- txt = { I18n . t ( "applicationDetail.back" ) } />
162+ { anonymous && < Button type = { ButtonType . Secondary }
163+ icon = { < ArrowLeftIcon /> }
164+ iconPlacement = { ButtonIconPlacement . Left }
165+ onClick = { goBack }
166+ txt = { I18n . t ( "applicationDetail.back" ) } /> }
167+ { ! anonymous && < Button onClick = { ( ) => alert ( "Todo" ) }
168+ txt = { connectButtonText ( ) } /> }
108169 </ div >
109170 < div className = "details" >
110171 < div className = "left" >
0 commit comments