mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 07:10:33 +00:00
fix(webapp): Switch between uncategorized transactions tabs
This commit is contained in:
@@ -1,6 +1,9 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import { Tag } from '@blueprintjs/core';
|
import { Tag } from '@blueprintjs/core';
|
||||||
|
import { useAppQueryString } from '@/hooks';
|
||||||
|
import { useUncontrolled } from '@/hooks/useUncontrolled';
|
||||||
|
import { Group } from '@/components';
|
||||||
|
|
||||||
const Root = styled.div`
|
const Root = styled.div`
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -23,15 +26,56 @@ const FilterTag = styled(Tag)`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
export function AccountTransactionsUncategorizeFilter() {
|
export function AccountTransactionsUncategorizeFilter() {
|
||||||
|
const [locationQuery, setLocationQuery] = useAppQueryString();
|
||||||
|
|
||||||
|
const handleTabsChange = (value) => {
|
||||||
|
setLocationQuery({ uncategorizedFilter: value });
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Group position={'apart'}>
|
||||||
|
<SegmentedTabs
|
||||||
|
options={[
|
||||||
|
{ value: 'all', label: 'All' },
|
||||||
|
{ value: 'recognized', label: 'Recognized' },
|
||||||
|
]}
|
||||||
|
value={locationQuery?.uncategorizedFilter || 'all'}
|
||||||
|
onValueChange={handleTabsChange}
|
||||||
|
/>
|
||||||
|
<SegmentedTabs
|
||||||
|
options={[{ value: 'excluded', label: 'Excluded' }]}
|
||||||
|
value={locationQuery?.uncategorizedFilter || 'all'}
|
||||||
|
onValueChange={handleTabsChange}
|
||||||
|
/>
|
||||||
|
</Group>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface SegmentedTabs {
|
||||||
|
options: Array<{ label: string; value: string }>;
|
||||||
|
initialValue?: string;
|
||||||
|
value?: string;
|
||||||
|
onValueChange?: (value: string) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
function SegmentedTabs({ options, initialValue, value, onValueChange }) {
|
||||||
|
const [_value, handleChange] = useUncontrolled({
|
||||||
|
initialValue,
|
||||||
|
value,
|
||||||
|
onChange: onValueChange,
|
||||||
|
});
|
||||||
return (
|
return (
|
||||||
<Root>
|
<Root>
|
||||||
<FilterTag round interactive>
|
{options.map((option) => (
|
||||||
All <strong>(2)</strong>
|
<FilterTag
|
||||||
</FilterTag>
|
round
|
||||||
|
interactive
|
||||||
<FilterTag round minimal interactive>
|
onClick={() => handleChange(option.value)}
|
||||||
Recognized <strong>(0)</strong>
|
minimal={option.value !== _value}
|
||||||
</FilterTag>
|
>
|
||||||
|
{option.label}
|
||||||
|
</FilterTag>
|
||||||
|
))}
|
||||||
</Root>
|
</Root>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import { useEffect } from 'react';
|
import { useEffect, lazy } from 'react';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import * as R from 'ramda';
|
import * as R from 'ramda';
|
||||||
|
|
||||||
@@ -7,29 +7,16 @@ import '@/style/pages/CashFlow/AccountTransactions/List.scss';
|
|||||||
|
|
||||||
import { AccountTransactionsUncategorizeFilter } from './AccountTransactionsUncategorizeFilter';
|
import { AccountTransactionsUncategorizeFilter } from './AccountTransactionsUncategorizeFilter';
|
||||||
import { UncategorizedTransactionsFilterProvider } from './AccountUncategorizedTransactionsFilterProvider';
|
import { UncategorizedTransactionsFilterProvider } from './AccountUncategorizedTransactionsFilterProvider';
|
||||||
import { RecognizedTransactionsTableBoot } from './RecognizedTransactions/RecognizedTransactionsTableBoot';
|
|
||||||
import { RecognizedTransactionsTable } from './RecognizedTransactions/RecognizedTransactionsTable';
|
|
||||||
import {
|
import {
|
||||||
WithBankingActionsProps,
|
WithBankingActionsProps,
|
||||||
withBankingActions,
|
withBankingActions,
|
||||||
} from '../withBankingActions';
|
} from '../withBankingActions';
|
||||||
import { AccountUncategorizedTransactionsBoot } from './AllTransactionsUncategorizedBoot';
|
import { useAppQueryString } from '@/hooks';
|
||||||
import AccountTransactionsUncategorizedTable from './AccountTransactionsUncategorizedTable';
|
|
||||||
import { ExcludedBankTransactionsTableBoot } from './ExcludedTransactions/ExcludedTransactionsTableBoot';
|
|
||||||
import { ExcludedTransactionsTable } from './ExcludedTransactions/ExcludedTransactionsTable';
|
|
||||||
|
|
||||||
const Box = styled.div`
|
const Box = styled.div`
|
||||||
margin: 30px 15px;
|
margin: 30px 15px;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const CashflowTransactionsTableCard = styled.div`
|
|
||||||
border: 2px solid #f0f0f0;
|
|
||||||
border-radius: 10px;
|
|
||||||
padding: 30px 18px;
|
|
||||||
background: #fff;
|
|
||||||
flex: 0 1;
|
|
||||||
`;
|
|
||||||
|
|
||||||
interface AllTransactionsUncategorizedProps extends WithBankingActionsProps {}
|
interface AllTransactionsUncategorizedProps extends WithBankingActionsProps {}
|
||||||
|
|
||||||
function AllTransactionsUncategorizedRoot({
|
function AllTransactionsUncategorizedRoot({
|
||||||
@@ -47,27 +34,45 @@ function AllTransactionsUncategorizedRoot({
|
|||||||
<UncategorizedTransactionsFilterProvider>
|
<UncategorizedTransactionsFilterProvider>
|
||||||
<Box>
|
<Box>
|
||||||
<AccountTransactionsUncategorizeFilter />
|
<AccountTransactionsUncategorizeFilter />
|
||||||
|
<AccountTransactionsSwitcher />
|
||||||
<ExcludedBankTransactionsTableBoot>
|
|
||||||
<CashflowTransactionsTableCard>
|
|
||||||
<ExcludedTransactionsTable />
|
|
||||||
</CashflowTransactionsTableCard>
|
|
||||||
</ExcludedBankTransactionsTableBoot>
|
|
||||||
|
|
||||||
{/* <RecognizedTransactionsTableBoot>
|
|
||||||
<CashflowTransactionsTableCard>
|
|
||||||
<RecognizedTransactionsTable />
|
|
||||||
</CashflowTransactionsTableCard>
|
|
||||||
</RecognizedTransactionsTableBoot> */}
|
|
||||||
|
|
||||||
{/* <AccountUncategorizedTransactionsBoot>
|
|
||||||
<CashflowTransactionsTableCard>
|
|
||||||
<AccountTransactionsUncategorizedTable />
|
|
||||||
</CashflowTransactionsTableCard>
|
|
||||||
</AccountUncategorizedTransactionsBoot> */}
|
|
||||||
</Box>
|
</Box>
|
||||||
</UncategorizedTransactionsFilterProvider>
|
</UncategorizedTransactionsFilterProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const AccountExcludedTransactins = lazy(() =>
|
||||||
|
import('./UncategorizedTransactions/AccountExcludedTransactions').then(
|
||||||
|
(module) => ({ default: module.AccountExcludedTransactions }),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const AccountRecognizedTransactions = lazy(() =>
|
||||||
|
import('./UncategorizedTransactions/AccountRecgonizedTranasctions').then(
|
||||||
|
(module) => ({ default: module.AccountRecognizedTransactions }),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const AccountUncategorizedTransactions = lazy(() =>
|
||||||
|
import(
|
||||||
|
'./UncategorizedTransactions/AccountUncategorizedTransactionsAll'
|
||||||
|
).then((module) => ({ default: module.AccountUncategorizedTransactionsAll })),
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Switches between the account transactions tables.
|
||||||
|
* @returns {React.ReactNode}
|
||||||
|
*/
|
||||||
|
function AccountTransactionsSwitcher() {
|
||||||
|
const [locationQuery] = useAppQueryString();
|
||||||
|
const uncategorizedTab = locationQuery?.uncategorizedFilter;
|
||||||
|
|
||||||
|
switch (uncategorizedTab) {
|
||||||
|
case 'excluded':
|
||||||
|
return <AccountExcludedTransactins />;
|
||||||
|
case 'recognized':
|
||||||
|
return <AccountRecognizedTransactions />;
|
||||||
|
case 'all':
|
||||||
|
default:
|
||||||
|
return <AccountUncategorizedTransactions />;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default R.compose(withBankingActions)(AllTransactionsUncategorizedRoot);
|
export default R.compose(withBankingActions)(AllTransactionsUncategorizedRoot);
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import { ExcludedTransactionsTable } from "../ExcludedTransactions/ExcludedTransactionsTable";
|
||||||
|
import { ExcludedBankTransactionsTableBoot } from "../ExcludedTransactions/ExcludedTransactionsTableBoot";
|
||||||
|
import { AccountTransactionsCard } from "./AccountTransactionsCard";
|
||||||
|
|
||||||
|
export function AccountExcludedTransactions() {
|
||||||
|
return (
|
||||||
|
<ExcludedBankTransactionsTableBoot>
|
||||||
|
<AccountTransactionsCard>
|
||||||
|
<ExcludedTransactionsTable />
|
||||||
|
</AccountTransactionsCard>
|
||||||
|
</ExcludedBankTransactionsTableBoot>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { RecognizedTransactionsTableBoot } from '../RecognizedTransactions/RecognizedTransactionsTableBoot';
|
||||||
|
import { RecognizedTransactionsTable } from '../RecognizedTransactions/RecognizedTransactionsTable';
|
||||||
|
import { AccountTransactionsCard } from './AccountTransactionsCard';
|
||||||
|
|
||||||
|
export function AccountRecognizedTransactions() {
|
||||||
|
return (
|
||||||
|
<RecognizedTransactionsTableBoot>
|
||||||
|
<AccountTransactionsCard>
|
||||||
|
<RecognizedTransactionsTable />
|
||||||
|
</AccountTransactionsCard>
|
||||||
|
</RecognizedTransactionsTableBoot>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import styled from 'styled-components';
|
||||||
|
|
||||||
|
|
||||||
|
export const AccountTransactionsCard = styled.div`
|
||||||
|
border: 2px solid #f0f0f0;
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 30px 18px;
|
||||||
|
background: #fff;
|
||||||
|
flex: 0 1;
|
||||||
|
`;
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import AccountTransactionsUncategorizedTable from '../AccountTransactionsUncategorizedTable';
|
||||||
|
import { AccountUncategorizedTransactionsBoot } from '../AllTransactionsUncategorizedBoot';
|
||||||
|
import { AccountTransactionsCard } from './AccountTransactionsCard';
|
||||||
|
|
||||||
|
export function AccountUncategorizedTransactionsAll() {
|
||||||
|
return (
|
||||||
|
<AccountUncategorizedTransactionsBoot>
|
||||||
|
<AccountTransactionsCard>
|
||||||
|
<AccountTransactionsUncategorizedTable />
|
||||||
|
</AccountTransactionsCard>
|
||||||
|
</AccountUncategorizedTransactionsBoot>
|
||||||
|
);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user