HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux WebLive 5.15.0-79-generic #86-Ubuntu SMP Mon Jul 10 16:07:21 UTC 2023 x86_64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/html/wptoho/wp-content/plugins/really-simple-ssl/settings/src/Settings/TwoFA/RolesStore.js
import {create} from 'zustand';
import * as rsssl_api from "../../utils/api";
import {produce} from "immer";
const useRolesData = create(( set, get ) => ({
    roles: [],
    rolesLoaded:false,
    fetchRoles: async ( id ) => {
        try {
            // Fetch the roles from the server using rsssl_api.getUserRoles()
            const response = await rsssl_api.doAction('get_roles', { id: id });

            // Handle the response
            if ( !response ) {
                console.error('No response received from the server.');
                return;
            }

            const data = response.roles;
            if (typeof data !== 'object') {
                console.error('Invalid data received in the server response. Expected an object.');
                return;
            }

            // Convert the object to an array
            const dataArray = Object.values(data);

            // Format the data into options array for react-select

            const formattedData = dataArray.map((role, index) => ({ value: role, label: role.charAt(0).toUpperCase() + role.slice(1) }));
            // Set the roles state with formatted data
            set({roles: formattedData,rolesLoaded:true  });


        } catch (error) {
            console.error('Error:', error);
        }
    }
}));

export default useRolesData;