@@ -15,13 +15,23 @@ const StyledSpan = styled('span')(({ theme }) => ({ color: theme.palette.error.d
1515 * @param {JSON } state The second number.
1616 * @returns {Promise }
1717 */
18- function certificateReducer ( state , newValue ) {
19- const { field, value } = newValue ;
18+ function certificateReducer ( state , action ) {
19+ // If we receive a direct certificate update
20+ if ( action . type === undefined && action . value !== undefined ) {
21+ return {
22+ type : action . value . type || 'PEM' ,
23+ value : action . value . value || '' ,
24+ } ;
25+ }
26+ // If we receive a field update
27+ const { field, value } = action ;
2028 if ( field === 'tenantWideCertificates' ) {
21- return { ...state , [ field ] : value } ;
22- } else {
23- return newValue ;
29+ return {
30+ type : value . type || state . type ,
31+ value : value . value || '' ,
32+ } ;
2433 }
34+ return state ;
2535}
2636
2737export default function KeyManagerConfiguration ( props ) {
@@ -39,10 +49,15 @@ export default function KeyManagerConfiguration(props) {
3949 type : 'PEM' ,
4050 value : '' ,
4151 } ) ;
42- // Add effect to watch for changes
52+ // Add effect to watch for changes and sync with additionalProperties
4353 useEffect ( ( ) => {
4454 if ( tenantWideCertificates ) {
45- setAdditionalProperties ( 'certificates' , tenantWideCertificates ) ;
55+ // Ensure we only pass the correct structure
56+ const certificateData = {
57+ type : tenantWideCertificates . type || 'PEM' ,
58+ value : tenantWideCertificates . value || '' ,
59+ } ;
60+ setAdditionalProperties ( 'certificates' , certificateData ) ;
4661 }
4762 } , [ tenantWideCertificates , setAdditionalProperties ] ) ;
4863
0 commit comments