mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
refactor(webapp): invite and user form with new blueprintjs-formik components
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
// @ts-nocheck
|
||||
import React, { useMemo } from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
import styled from 'styled-components';
|
||||
import {
|
||||
Menu,
|
||||
Popover,
|
||||
@@ -9,6 +10,7 @@ import {
|
||||
MenuItem,
|
||||
MenuDivider,
|
||||
Intent,
|
||||
Tag,
|
||||
} from '@blueprintjs/core';
|
||||
import { Icon } from '@/components';
|
||||
import { safeCallback } from '@/utils';
|
||||
@@ -52,12 +54,25 @@ export const ActionsCell = (props) => {
|
||||
);
|
||||
};
|
||||
|
||||
export const CurrencyNameAccessor = (value) => {
|
||||
return (
|
||||
<CurrencyNameRoot>
|
||||
{value.currency_name} {value.is_base_currency && <Tag>Base Currency</Tag>}
|
||||
</CurrencyNameRoot>
|
||||
);
|
||||
};
|
||||
|
||||
const CurrencyNameRoot = styled.div`
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
`;
|
||||
|
||||
export function useCurrenciesTableColumns() {
|
||||
return useMemo(
|
||||
() => [
|
||||
{
|
||||
Header: intl.get('currency_name'),
|
||||
accessor: 'currency_name',
|
||||
accessor: CurrencyNameAccessor,
|
||||
width: 150,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -22,6 +22,14 @@ function UsersDataTable({
|
||||
// #withAlertActions
|
||||
openAlert,
|
||||
}) {
|
||||
const { mutateAsync: resendInviation } = useResendInvitation();
|
||||
|
||||
// Users list columns.
|
||||
const columns = useUsersListColumns();
|
||||
|
||||
// Users list context.
|
||||
const { users, isUsersLoading, isUsersFetching } = useUsersListContext();
|
||||
|
||||
// Handle edit user action.
|
||||
const handleEditUserAction = useCallback(
|
||||
(user) => {
|
||||
@@ -50,9 +58,6 @@ function UsersDataTable({
|
||||
},
|
||||
[openAlert],
|
||||
);
|
||||
|
||||
const { mutateAsync: resendInviation } = useResendInvitation();
|
||||
|
||||
const handleResendInvitation = useCallback((user) => {
|
||||
resendInviation(user.id)
|
||||
.then(() => {
|
||||
@@ -71,17 +76,12 @@ function UsersDataTable({
|
||||
AppToaster.show({
|
||||
message:
|
||||
'This person was recently invited. No need to invite them again just yet.',
|
||||
intent: Intent.DANGER,
|
||||
intent: Intent.WARNING,
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
// Users list columns.
|
||||
const columns = useUsersListColumns();
|
||||
|
||||
// Users list context.
|
||||
const { users, isUsersLoading, isUsersFetching } = useUsersListContext();
|
||||
|
||||
return (
|
||||
<DataTable
|
||||
|
||||
@@ -132,15 +132,9 @@ export const useUsersListColumns = () => {
|
||||
{
|
||||
id: 'role_name',
|
||||
Header: intl.get('users.column.role_name'),
|
||||
accessor: 'role.name',
|
||||
accessor: 'role_name',
|
||||
width: 120,
|
||||
},
|
||||
// {
|
||||
// id: 'phone_number',
|
||||
// Header: intl.get('phone_number'),
|
||||
// accessor: 'phone_number',
|
||||
// width: 120,
|
||||
// },
|
||||
{
|
||||
id: 'status',
|
||||
Header: intl.get('status'),
|
||||
|
||||
Reference in New Issue
Block a user