- updated bando form;
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { is, uniq } from 'ramda';
|
||||
import { uniq } from 'ramda';
|
||||
|
||||
// store
|
||||
import { storeSet, storeGet } from '../../../../store';
|
||||
import { useStore, storeSet } from '../../../../store';
|
||||
|
||||
// tools
|
||||
import getBandoSeverity from '../../../../helpers/getBandoSeverity';
|
||||
@@ -11,7 +11,7 @@ import getBandoLabel from '../../../../helpers/getBandoLabel';
|
||||
import getDateFromISOstring from '../../../../helpers/getDateFromISOstring';
|
||||
|
||||
// api
|
||||
import BandoService from '../../../../service/bando-service';
|
||||
import UserService from '../../../../service/user-service';
|
||||
|
||||
// components
|
||||
import { FilterMatchMode, FilterOperator } from 'primereact/api';
|
||||
@@ -25,34 +25,32 @@ import { Button } from 'primereact/button';
|
||||
import { Calendar } from 'primereact/calendar';
|
||||
import { Tag } from 'primereact/tag';
|
||||
import ProperBandoLabel from '../../../../components/ProperBandoLabel';
|
||||
import { Link } from 'react-router-dom';
|
||||
import UserService from '../../../../service/user-service';
|
||||
|
||||
|
||||
const AllUsersTable = () => {
|
||||
const [items, setItems] = useState(null);
|
||||
const users = useStore().main.users();
|
||||
const [filters, setFilters] = useState(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [globalFilterValue, setGlobalFilterValue] = useState('');
|
||||
const [statuses, setStatuses] = useState([]);
|
||||
|
||||
useEffect(() => {
|
||||
setLoading(true);
|
||||
UserService.getUsers(getCallback, errGetCallbacks);
|
||||
if (!loading) {
|
||||
setLoading(true);
|
||||
UserService.getUsers(getCallback, errGetCallbacks);
|
||||
}
|
||||
}, []);
|
||||
|
||||
const getCallback = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
setItems(getFormattedData(data.data));
|
||||
storeSet.main.users(getFormattedData(data.data));
|
||||
setStatuses(uniq(data.data.map(o => o.status)))
|
||||
initFilters();
|
||||
}
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
const errGetCallbacks = (data) => {
|
||||
const errGetCallbacks = () => {
|
||||
setLoading(false);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
const getFormattedData = (data) => {
|
||||
@@ -128,7 +126,8 @@ const AllUsersTable = () => {
|
||||
const statusFilterTemplate = (options) => {
|
||||
return <Dropdown value={options.value} options={statuses}
|
||||
onChange={(e) => options.filterCallback(e.value, options.index)}
|
||||
itemTemplate={statusItemTemplate} placeholder={__('Scegli uno', 'gepafin')} className="p-column-filter"
|
||||
itemTemplate={statusItemTemplate} placeholder={__('Scegli uno', 'gepafin')}
|
||||
className="p-column-filter"
|
||||
showClear/>;
|
||||
};
|
||||
|
||||
@@ -147,7 +146,7 @@ const AllUsersTable = () => {
|
||||
|
||||
return (
|
||||
<div className="appPageSection__table">
|
||||
<DataTable value={items} paginator showGridlines rows={10} loading={loading} dataKey="id"
|
||||
<DataTable value={users} paginator showGridlines rows={10} loading={loading} dataKey="id"
|
||||
filters={filters}
|
||||
globalFilterFields={['name', 'status']}
|
||||
header={header}
|
||||
|
||||
Reference in New Issue
Block a user