admin actions update
This commit is contained in:
parent
c1d9457272
commit
8800c6e3c3
@ -55,11 +55,11 @@ export const sendInvite = ({ name, email, companies }) =>
|
||||
|
||||
export const removeUser = ({ email }) =>
|
||||
{
|
||||
console.log("ACTION", "removeUser()", { name, email, companies });
|
||||
console.log("ACTION", "removeUser()", { email });
|
||||
|
||||
return new Promise((resolve, reject) =>
|
||||
{
|
||||
axios.post(`${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/admin/remove`, { name, email, companies })
|
||||
axios.post(`${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/admin/remove`, { email })
|
||||
.then(async (response) =>
|
||||
{
|
||||
console.log("ACTION", "removeUser()", "response.data", response.data);
|
||||
|
||||
@ -217,30 +217,6 @@ export const sendOffstageToken = ({ token, dispatch }) =>
|
||||
});
|
||||
}
|
||||
|
||||
export const getUsers = ({ dispatch }) =>
|
||||
{
|
||||
console.log("ACTION", "getUsers()");
|
||||
|
||||
return new Promise((resolve, reject) =>
|
||||
{
|
||||
axios.post(`${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/admin/`, {})
|
||||
.then(async (response) =>
|
||||
{
|
||||
console.log("getContractRules", "response.data", response.data);
|
||||
dispatch({ type: actionTypes.ADMIN, data: { users: response.data.users } });
|
||||
|
||||
resolve();
|
||||
})
|
||||
.catch((error) =>
|
||||
{
|
||||
console.error("ACTION", "getUsers()", "error");
|
||||
console.error(error);
|
||||
|
||||
reject();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export const sendSwitchAccount = ({ dispatch, acc_number }) =>
|
||||
{
|
||||
console.log("ACTION", "sendSwitchAccount()", `${ process.env.NEXT_PUBLIC_SELF_API_HOST }/api/auth/switch/`);
|
||||
|
||||
@ -9,4 +9,5 @@ export * from './formsActions';
|
||||
export * from './settingsActions';
|
||||
export * from './announcementsActions';
|
||||
export * from './eventsActions';
|
||||
export * from './supportActions';
|
||||
export * from './supportActions';
|
||||
export * from './adminActions';
|
||||
@ -39,17 +39,24 @@ export default class InnerMenu extends React.Component
|
||||
<Link href={`/events`} shallow>
|
||||
<a className={ type === undefined ? "active" : "" }>Все события</a>
|
||||
</Link>
|
||||
</li>
|
||||
</li>
|
||||
{/*}
|
||||
<li>
|
||||
<Link href={`/events#restrictions`} shallow>
|
||||
<a className={ type === "restrictions" ? "active" : "" }>Ограничения</a>
|
||||
</Link>
|
||||
</li>
|
||||
{*/}
|
||||
<li>
|
||||
<Link href={`/events#payments`} shallow>
|
||||
<a className={ type === "payments" ? "active" : "" }>Платежи</a>
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href={`/events#finance`} shallow>
|
||||
<a className={ type === "finance" ? "active" : "" }>Банки и договоры</a>
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href={`/events#additional`} shallow>
|
||||
<a className={ type === "additional" ? "active" : "" }>Дополнительные услуги</a>
|
||||
@ -60,11 +67,6 @@ export default class InnerMenu extends React.Component
|
||||
<a className={ type === "fines" ? "active" : "" }>Штрафы</a>
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href={`/events#finance`} shallow>
|
||||
<a className={ type === "finance" ? "active" : "" }>Банки</a>
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href={`/events#pts`} shallow>
|
||||
<a className={ type === "pts" ? "active" : "" }>ПТС</a>
|
||||
|
||||
@ -73,10 +73,10 @@ export default class CalculationsList extends React.Component
|
||||
<p className="item_desc">
|
||||
{ calculation.date_offset_type_comment !== null && (<>{ `${ calculation.date_offset_type_comment.label }: ${ calculation.date_offset_type_comment.value }` }<br/></>) }
|
||||
{ calculation.number_paydate_comment !== null && (<>{ `${ calculation.number_paydate_comment.label }: ${ calculation.number_paydate_comment.value }` }<br/></>) }
|
||||
{ calculation.insurance_price_result_comment !== null && (<>{ `${ calculation.insurance_price_result_comment.label }: ${ numeral(calculation.insurance_price_result_comment.value).format(' ., ') } ` } ₽<br/></>) }
|
||||
{ calculation.insurance_price_result_comment !== null && (<>{ calculation.insurance_price_result_comment.label }: <span style={{ whiteSpace: "nowrap"}}>{ numeral(calculation.insurance_price_result_comment.value).format(' ., ') } ₽</span><br/></>) }
|
||||
{ calculation.fix_last_payment_available_comment !== null && (<>{ `${ calculation.fix_last_payment_available_comment.label }: ${ calculation.fix_last_payment_available_comment.value ? "да" : "нет" }` }<br/></>) }
|
||||
{ calculation.period_new_comment !== null && (<>{ `${ calculation.period_new_comment.label }: ${ calculation.period_new_comment.value }` }<br/></>) }
|
||||
{ calculation.sum_comment !== null && (<>{ `${ calculation.sum_comment.label }: ${ numeral(calculation.sum_comment.value).format(' ., ') }` } ₽<br/></>) }
|
||||
{ calculation.sum_comment !== null && (<>{ calculation.sum_comment.label }: <span style={{ whiteSpace: "nowrap"}}>{ numeral(calculation.sum_comment.value).format(' ., ') } ₽</span><br/></>) }
|
||||
</p>
|
||||
<a className="item_link interactive" onClick={ () => this._handle_onCalculation(calculation.addcontract_number) }>Подробнее</a>
|
||||
</div>
|
||||
|
||||
@ -46,8 +46,8 @@ export default class InnerMenu extends React.Component
|
||||
|
||||
_getActiveLink = (route) =>
|
||||
{
|
||||
if (route.indexOf("/payments/") > -1) return "График платежей";
|
||||
if (route.indexOf("/change/") > -1) return "Изменить график";
|
||||
if (route.indexOf("/payments") > -1) return "График платежей";
|
||||
if (route.indexOf("/change") > -1) return "Изменить график";
|
||||
if (route.indexOf("/services") > -1) return "Дополнительные услуги";
|
||||
if (route.indexOf("/agreement") > -1) return "Документы по договору";
|
||||
if (route.indexOf("/documents") > -1) return "Закрывающие документы";
|
||||
|
||||
@ -17,7 +17,7 @@ import Footer from '../components/Footer';
|
||||
import Pagination from '../components/Pagination';
|
||||
import Company from "../components/Company";
|
||||
|
||||
import { getUsers, sendPhoneChangeNumber, sendPhoneChangeNumberSmsCode, setUserPhone } from '../../actions';
|
||||
import { getUsers, removeUser, sendInvite, sendPhoneChangeNumber, sendPhoneChangeNumberSmsCode, setUserPhone } from '../../actions';
|
||||
import AccountLayout from "../components/Layout/Account";
|
||||
|
||||
class Form extends React.Component
|
||||
@ -222,10 +222,28 @@ class AdminPage extends React.Component
|
||||
_handle_onSave = () =>
|
||||
{
|
||||
const { form } = this.state;
|
||||
const { name, email, selected_companies_list } = form;
|
||||
console.log("form");
|
||||
console.log(form);
|
||||
|
||||
this.setState({ add: false, edit: false });
|
||||
const companies = [];
|
||||
for(let i in selected_companies_list)
|
||||
{
|
||||
companies.push(selected_companies_list[i].acc_number);
|
||||
}
|
||||
|
||||
this.setState({ add: false, edit: false, loading: true }, () =>
|
||||
{
|
||||
sendInvite({ name, email, companies })
|
||||
.then(() =>
|
||||
{
|
||||
this.setState({ loading: false });
|
||||
})
|
||||
.catch(() =>
|
||||
{
|
||||
this.setState({ loading: false });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
_handle_onCancel = () =>
|
||||
@ -259,7 +277,7 @@ class AdminPage extends React.Component
|
||||
|
||||
render()
|
||||
{
|
||||
const { user, users, companies, add, edit, save } = this.state;
|
||||
const { loading, user, users, companies, add, edit, save } = this.state;
|
||||
console.log("users");
|
||||
console.log(users);
|
||||
|
||||
@ -291,106 +309,114 @@ class AdminPage extends React.Component
|
||||
<div className="aside_container about">
|
||||
<InnerMenu { ...this.props }/>
|
||||
<article>
|
||||
<div className="settings_user_control">
|
||||
<p>Настройки доступа к личному кабинету</p>
|
||||
<div>
|
||||
{ add || edit ? (
|
||||
<>
|
||||
<button className="button button-blue" onClick={ this._handle_onCancel }>Отменить</button>
|
||||
<button className="button button-blue" onClick={ this._handle_onSave } disabled={ save ? false : true }>Сохранить</button>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<button className="button button-blue" onClick={ this._handle_onAdd }>Добавить пользователя</button>
|
||||
<button className="button button-blue" onClick={ this._handle_onEdit }>Редактировать</button>
|
||||
</>
|
||||
) }
|
||||
{ loading ? (
|
||||
<div className="table_row table_header" style={{ minHeight: 300, display: "flex", justifyContent: "center", alignItems: "center" }}>
|
||||
<SpinnerCircular size={90} thickness={51} speed={100} color="rgba(28, 1, 169, 1)" secondaryColor="rgba(236, 239, 244, 1)" />
|
||||
</div>
|
||||
</div>
|
||||
<div className="settings_table editable">
|
||||
<div className="table_header table_row">
|
||||
<div className="table_cell">ФИО пользователя</div>
|
||||
<div className="table_cell">Почта</div>
|
||||
<div className="table_cell">Роль</div>
|
||||
<div className="table_cell">Доступные организации</div>
|
||||
<div className="table_cell" style={ !edit ? { border: "none", } : {} }>Статус</div>
|
||||
{ edit && (
|
||||
<div className="table_cell" style={{ border: "none", }}></div>
|
||||
) }
|
||||
</div>
|
||||
{ users !== undefined && users !== null && users.map((entry, index) =>
|
||||
{
|
||||
if(entry.email === user.email)
|
||||
{
|
||||
return (
|
||||
<div className="table_row" key={ index }>
|
||||
<div className="table_cell" data-title="ФИО пользователя">{ entry.name } (Вы)</div>
|
||||
<div className="table_cell" data-title="Почта">{ entry.email }</div>
|
||||
) : (
|
||||
<>
|
||||
<div className="settings_user_control">
|
||||
<p>Настройки доступа к личному кабинету</p>
|
||||
<div>
|
||||
{ add || edit ? (
|
||||
<>
|
||||
<button className="button button-blue" onClick={ this._handle_onCancel }>Отменить</button>
|
||||
<button className="button button-blue" onClick={ this._handle_onSave } disabled={ save ? false : true }>Сохранить</button>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<button className="button button-blue" onClick={ this._handle_onAdd }>Добавить пользователя</button>
|
||||
<button className="button button-blue" onClick={ this._handle_onEdit }>Редактировать</button>
|
||||
</>
|
||||
) }
|
||||
</div>
|
||||
</div>
|
||||
<div className="settings_table editable">
|
||||
<div className="table_header table_row">
|
||||
<div className="table_cell">ФИО пользователя</div>
|
||||
<div className="table_cell">Почта</div>
|
||||
<div className="table_cell">Роль</div>
|
||||
<div className="table_cell">Доступные организации</div>
|
||||
<div className="table_cell" style={ !edit ? { border: "none", } : {} }>Статус</div>
|
||||
{ edit && (
|
||||
<div className="table_cell" style={{ border: "none", }}></div>
|
||||
) }
|
||||
</div>
|
||||
{ users !== undefined && users !== null && users.map((entry, index) =>
|
||||
{
|
||||
if(entry.email === user.email)
|
||||
{
|
||||
return (
|
||||
<div className="table_row" key={ index }>
|
||||
<div className="table_cell" data-title="ФИО пользователя">{ entry.name } (Вы)</div>
|
||||
<div className="table_cell" data-title="Почта">{ entry.email }</div>
|
||||
<div className="table_cell" data-title="Роль">Администратор</div>
|
||||
<div className="table_cell" data-title="Доступные организации">Все организации</div>
|
||||
<div className="table_cell" data-title="Статус">Активен</div>
|
||||
{ edit && (
|
||||
<div className="table_cell delete" style={{ position: 'relative' }}></div>
|
||||
) }
|
||||
</div>
|
||||
)
|
||||
}
|
||||
return null;
|
||||
}) }
|
||||
{ users !== undefined && users !== null && users.map((entry, index) =>
|
||||
{
|
||||
if(entry.email !== user.email)
|
||||
{
|
||||
return (
|
||||
<div className="table_row" key={ index }>
|
||||
<div className="table_cell" data-title="ФИО пользователя">{ entry.name }</div>
|
||||
<div className="table_cell" data-title="Почта">{ entry.email }</div>
|
||||
<div className="table_cell" data-title="Роль">Администратор</div>
|
||||
<div className="table_cell" data-title="Доступные организации">{ entry.companies.map((company, c_index) => (
|
||||
<p key={ c_index }>{ company.title }</p>
|
||||
)) }</div>
|
||||
<div className="table_cell" data-title="Статус">Активен</div>
|
||||
{ edit && (
|
||||
<div className="table_cell delete" style={{ position: 'relative' }}>
|
||||
<button className="delete_user" title="Удалить пользователя"></button>
|
||||
</div>
|
||||
) }
|
||||
</div>
|
||||
)
|
||||
}
|
||||
return null;
|
||||
}) }
|
||||
{/*}
|
||||
{ user !== undefined && user !== null && user.email !== undefined && user.email !== null && (
|
||||
<div className="table_row">
|
||||
<div className="table_cell" data-title="ФИО пользователя">{ `${ user.lastname } ${ user.name } ${ user.secondname }` }</div>
|
||||
<div className="table_cell" data-title="Почта">{ user.email }</div>
|
||||
<div className="table_cell" data-title="Роль">Администратор</div>
|
||||
<div className="table_cell" data-title="Доступные организации">Все организации</div>
|
||||
<div className="table_cell" data-title="Статус">Активен</div>
|
||||
{ edit && (
|
||||
<div className="table_cell delete" style={{ position: 'relative' }}></div>
|
||||
) }
|
||||
<div className="table_cell delete" style={{ position: 'relative' }}>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
return null;
|
||||
}) }
|
||||
{ users !== undefined && users !== null && users.map((entry, index) =>
|
||||
{
|
||||
if(entry.email !== user.email)
|
||||
{
|
||||
return (
|
||||
<div className="table_row" key={ index }>
|
||||
<div className="table_cell" data-title="ФИО пользователя">{ entry.name }</div>
|
||||
<div className="table_cell" data-title="Почта">{ entry.email }</div>
|
||||
<div className="table_cell" data-title="Роль">Администратор</div>
|
||||
<div className="table_cell" data-title="Доступные организации">{ entry.companies.map((company, c_index) => (
|
||||
<p key={ c_index }>{ company.title }</p>
|
||||
)) }</div>
|
||||
<div className="table_cell" data-title="Статус">Активен</div>
|
||||
{ edit && (
|
||||
<div className="table_cell delete" style={{ position: 'relative' }}>
|
||||
<button className="delete_user" title="Удалить пользователя"></button>
|
||||
</div>
|
||||
) }
|
||||
) }
|
||||
{*/}
|
||||
{/*}
|
||||
<div className="table_row">
|
||||
<div className="table_cell" data-title="ФИО пользователя">Иванов Иван Иванович</div>
|
||||
<div className="table_cell" data-title="Почта">iivanov@mail.com</div>
|
||||
<div className="table_cell" data-title="Роль">Администратор</div>
|
||||
<div className="table_cell" data-title="Доступные организации">Все организации</div>
|
||||
<div className="table_cell" data-title="Статус">Активен</div>
|
||||
<div className="table_cell delete" style={{ position: 'relative' }}>
|
||||
<button className="delete_user" title="Удалить пользователя"></button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
return null;
|
||||
}) }
|
||||
{/*}
|
||||
{ user !== undefined && user !== null && user.email !== undefined && user.email !== null && (
|
||||
<div className="table_row">
|
||||
<div className="table_cell" data-title="ФИО пользователя">{ `${ user.lastname } ${ user.name } ${ user.secondname }` }</div>
|
||||
<div className="table_cell" data-title="Почта">{ user.email }</div>
|
||||
<div className="table_cell" data-title="Роль">Администратор</div>
|
||||
<div className="table_cell" data-title="Доступные организации">Все организации</div>
|
||||
<div className="table_cell" data-title="Статус">Активен</div>
|
||||
<div className="table_cell delete" style={{ position: 'relative' }}>
|
||||
</div>
|
||||
{*/}
|
||||
{ add && (
|
||||
<Form companies={ companies } onForm={ this._onFormEdit }/>
|
||||
) }
|
||||
{/*}
|
||||
{*/}
|
||||
</div>
|
||||
) }
|
||||
{*/}
|
||||
{/*}
|
||||
<div className="table_row">
|
||||
<div className="table_cell" data-title="ФИО пользователя">Иванов Иван Иванович</div>
|
||||
<div className="table_cell" data-title="Почта">iivanov@mail.com</div>
|
||||
<div className="table_cell" data-title="Роль">Администратор</div>
|
||||
<div className="table_cell" data-title="Доступные организации">Все организации</div>
|
||||
<div className="table_cell" data-title="Статус">Активен</div>
|
||||
<div className="table_cell delete" style={{ position: 'relative' }}>
|
||||
<button className="delete_user" title="Удалить пользователя"></button>
|
||||
</div>
|
||||
</div>
|
||||
{*/}
|
||||
{ add && (
|
||||
<Form companies={ companies } onForm={ this._onFormEdit }/>
|
||||
) }
|
||||
{/*}
|
||||
{*/}
|
||||
</div>
|
||||
</>
|
||||
) }
|
||||
</article>
|
||||
</div>
|
||||
</AccountLayout>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user