diff --git a/src/components/CoSign/CoSignOld.jsx b/src/components/CoSign/CoSignOld.jsx
new file mode 100644
index 000000000..a7362076f
--- /dev/null
+++ b/src/components/CoSign/CoSignOld.jsx
@@ -0,0 +1,141 @@
+import PropTypes from 'prop-types';
+import {useContext} from 'react';
+import {FormattedMessage} from 'react-intl';
+import {useAsync} from 'react-use';
+
+import {ConfigContext, SubmissionContext} from 'Context';
+import {get} from 'api';
+import Body from 'components/Body';
+import ErrorMessage from 'components/Errors/ErrorMessage';
+import Loader from 'components/Loader';
+import LoginOptionsDisplay from 'components/LoginOptions/LoginOptionsDisplay';
+import {getLoginUrl} from 'components/utils';
+import Types from 'types';
+import {getBEMClassName} from 'utils';
+
+const getCosignStatus = async (baseUrl, submissionUuid) => {
+ const endpoint = `${baseUrl}submissions/${submissionUuid}/co-sign`;
+ return await get(endpoint);
+};
+
+const CoSignAuthentication = ({form, submissionUuid, authPlugin}) => {
+ const loginOption = form.loginOptions.find(opt => opt.identifier === authPlugin);
+ if (!loginOption) {
+ return (
+
+
+
+ );
+ }
+
+ // add the co-sign submission parameter to the login URL
+ const loginUrl = getLoginUrl(loginOption, {coSignSubmission: submissionUuid});
+ const modifiedLoginOption = {
+ ...loginOption,
+ url: loginUrl,
+ label: (
+
+ ),
+ };
+
+ return (
+
+ );
+};
+
+CoSignAuthentication.propTypes = {
+ form: Types.Form.isRequired,
+ submissionUuid: PropTypes.string.isRequired,
+ authPlugin: PropTypes.string.isRequired,
+};
+
+const CoSignOld = ({
+ submissionUuid,
+ interactive = true,
+ form = null,
+ saveStepData,
+ authPlugin = 'digid-mock',
+}) => {
+ const {baseUrl} = useContext(ConfigContext);
+ const {submission} = useContext(SubmissionContext);
+
+ if (!submissionUuid) {
+ submissionUuid = submission.id;
+ }
+
+ const {
+ loading,
+ value: coSignState,
+ error,
+ } = useAsync(
+ async () => await getCosignStatus(baseUrl, submissionUuid),
+ [baseUrl, submissionUuid]
+ );
+
+ // log errors to the console if any
+ if (error) console.error(error);
+
+ // while loading, display spinner
+ if (loading) {
+ return ;
+ }
+ const {coSigned, representation} = coSignState;
+
+ if (!coSigned) {
+ if (!interactive) {
+ return (
+
+ );
+ }
+
+ if (!form || !saveStepData) {
+ throw new Error('Interactive co-sign components require the "form" and "saveStepData" props');
+ }
+
+ return (
+
+ );
+ }
+
+ return (
+
+
+ {representation ?? (
+
+ )}
+
+
+ );
+};
+
+CoSignOld.propTypes = {
+ interactive: PropTypes.bool,
+ form: Types.Form,
+ submissionUuid: PropTypes.string, // fall back to context if not provided
+ saveStepData: PropTypes.func,
+ authPlugin: PropTypes.string,
+};
+
+export default CoSignOld;
+export {CoSignAuthentication};
diff --git a/src/components/CoSign/Cosign.jsx b/src/components/CoSign/Cosign.jsx
index 3ac340acf..6c7e65cca 100644
--- a/src/components/CoSign/Cosign.jsx
+++ b/src/components/CoSign/Cosign.jsx
@@ -61,7 +61,7 @@ const Cosign = () => {
return (
- } />
+ {/*} />*/}
{
- const endpoint = `${baseUrl}submissions/${submissionUuid}/co-sign`;
- return await get(endpoint);
-};
-
-const CoSignAuthentication = ({form, submissionUuid, authPlugin}) => {
- const loginOption = form.loginOptions.find(opt => opt.identifier === authPlugin);
- if (!loginOption) {
- return (
-
-
-
- );
- }
-
- // add the co-sign submission parameter to the login URL
- const loginUrl = getLoginUrl(loginOption, {coSignSubmission: submissionUuid});
- const modifiedLoginOption = {
- ...loginOption,
- url: loginUrl,
- label: (
-
- ),
- };
-
- return (
-
- );
-};
-
-CoSignAuthentication.propTypes = {
- form: Types.Form.isRequired,
- submissionUuid: PropTypes.string.isRequired,
- authPlugin: PropTypes.string.isRequired,
-};
-
-const CoSignOld = ({
- submissionUuid,
- interactive = true,
- form = null,
- saveStepData,
- authPlugin = 'digid-mock',
-}) => {
- const {baseUrl} = useContext(ConfigContext);
- const {submission} = useContext(SubmissionContext);
-
- if (!submissionUuid) {
- submissionUuid = submission.id;
- }
-
- const {
- loading,
- value: coSignState,
- error,
- } = useAsync(
- async () => await getCosignStatus(baseUrl, submissionUuid),
- [baseUrl, submissionUuid]
- );
-
- // log errors to the console if any
- if (error) console.error(error);
-
- // while loading, display spinner
- if (loading) {
- return ;
- }
- const {coSigned, representation} = coSignState;
-
- if (!coSigned) {
- if (!interactive) {
- return (
-
- );
- }
-
- if (!form || !saveStepData) {
- throw new Error('Interactive co-sign components require the "form" and "saveStepData" props');
- }
-
- return (
-
- );
- }
-
- return (
-
-
- {representation ?? (
-
- )}
-
-
- );
-};
-
-CoSignOld.propTypes = {
- interactive: PropTypes.bool,
- form: Types.Form,
- submissionUuid: PropTypes.string, // fall back to context if not provided
- saveStepData: PropTypes.func,
- authPlugin: PropTypes.string,
-};
-
export default CoSignOld;
-export {CoSignAuthentication, Cosign, CosignDone};
+export {Cosign, CosignDone};
diff --git a/src/components/CoSign/test.spec.jsx b/src/components/CoSign/test.spec.jsx
index fd2f0667f..3bfd2c758 100644
--- a/src/components/CoSign/test.spec.jsx
+++ b/src/components/CoSign/test.spec.jsx
@@ -4,7 +4,7 @@ import {IntlProvider} from 'react-intl';
import {testLoginForm} from 'components/FormStart/fixtures';
-import {CoSignAuthentication} from './index';
+import {CoSignAuthentication} from './CoSignOld';
it('CoSign component constructs the right auth URL', () => {
// Control the location that the test will use