import React, { useEffect, useRef, useState } from 'react'; import { __ } from '@wordpress/i18n'; import { isEmpty, pathOr } from 'ramda'; // api import UserService from '../../service/user-service'; import AssignedApplicationService from '../../service/assigned-application-service'; import DashboardService from '../../service/dashboard-service'; // store import { storeSet } from '../../store'; // tools import set404FromErrorResponse from '../../helpers/set404FromErrorResponse'; import uniqid from '../../helpers/uniqid'; // components import { Dialog } from 'primereact/dialog'; import { Button } from 'primereact/button'; import { classNames } from 'primereact/utils'; import { Dropdown } from 'primereact/dropdown'; import NumberFlow from '@number-flow/react'; import DraftApplicationsTableAsync from '../Dashboard/components/DraftApplicationsTableAsync'; import AllDomandeTableAsync from './components/AllDomandeTableAsync'; const Domande = () => { const [loading, setLoading] = useState(false); const [isVisibleEditDialog, setIsVisibleEditDialog] = useState(false); const [roleIds, setRoleIds] = useState([]); const [users, setUsers] = useState([]); const [chosenUser, setChosenUser] = useState(0); const [chosenApplication, setChosenApplication] = useState(0); const [updaterString, setUpdaterString] = useState(''); const [mainStats, setMainStats] = useState({}); const toast = useRef(null); const getRolesCallback = (data) => { if (data.status === 'SUCCESS') { const roles = data.data .filter(o => ['ROLE_PRE_INSTRUCTOR', 'ROLE_INSTRUCTOR_MANAGER'].includes(o.roleType)); setRoleIds(roles.map(o => o.id)); } setLoading(false); } const errGetRolesCallback = (data) => { set404FromErrorResponse(data); setLoading(false); } const getUsersCallback = (data) => { if (data.status === 'SUCCESS') { const users = data.data .map(o => ({ name: `${o.firstName} ${o.lastName} (${o.email})`, value: o.id })); setUsers(users); } setLoading(false); } const errGetUsersCallback = (data) => { set404FromErrorResponse(data); setLoading(false); } const headerEditDialog = () => { return {__('Assegni la domanda', 'gepafin')} } const hideEditDialog = () => { setIsVisibleEditDialog(false); setChosenUser(0); setChosenApplication(0); } const footerEditDialog = () => { return