Server IP : 85.214.239.14 / Your IP : 18.119.255.183 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : 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, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /var/www/wordpress/wp-content/plugins/really-simple-ssl/settings/src/Settings/TwoFA/ |
Upload File : |
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;