4. Selecting a service user - PersonCentredSoftware/RelativesGateway GitHub Wiki

In cases where a Care Home may be looking after multiple Service Users for a particular relative, we have a component which allows Service User selection.

 PcsComponents.getInstance().then(function (lib) {

        lib.getAccess().then(function (access) {

                if (access.Authenticated) {

                    lib.loadChangeSU("pcs-ChangeSU")
                        .then(function (lib) {
                            // Once the ChangeSU component is loaded, assign the on-click even for the change button
                            $("#pcs-su-switch").click(function () {
                                // Call method to change SU
                                lib.doChangeSU($("#SelectedSUID").val())
                                    .then(function () {
                                        // Then once changed, reload the page to refresh the content
                                        window.location = window.location;
                                    });
                                })
                         });
                 }

            })
    });