Server IP : 15.235.198.142 / Your IP : 216.73.216.17 Web Server : Apache/2.4.58 (Ubuntu) System : Linux ballsack 6.8.0-45-generic #45-Ubuntu SMP PREEMPT_DYNAMIC Fri Aug 30 12:02:04 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/rhodeworks/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;