Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/components/forms/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ interface Props extends CommonProps {
behavior?: 'button' | 'submit';
disableWithoutIcon?: boolean;
noBackgroundColor?: boolean;
minimalTypePadding?: boolean;
}

const defaultProps: Props = {
Expand Down Expand Up @@ -75,9 +76,9 @@ export function Button(props: Props) {
className={classNames(
`border inline-flex items-center space-x-2 px-4 justify-center rounded text-sm ${props.className} disabled:cursor-not-allowed disabled:opacity-75`,
{
'py-2 px-4': props.type !== 'minimal',
'py-2 px-4': props.type !== 'minimal' && !props.minimalTypePadding,
'w-full': props.variant === 'block',
'p-0 m-0': props.type === 'minimal',
'p-0 m-0': props.type === 'minimal' || !props.minimalTypePadding,
}
)}
style={css}
Expand All @@ -99,9 +100,9 @@ export function Button(props: Props) {
className={classNames(
`border inline-flex items-center space-x-2 px-4 justify-center rounded text-sm ${props.className} disabled:cursor-not-allowed disabled:opacity-75`,
{
'py-2 px-4': props.type !== 'minimal',
'py-2 px-4': props.type !== 'minimal' && !props.minimalTypePadding,
'w-full': props.variant === 'block',
'p-0 m-0': props.type === 'minimal',
'p-0 m-0': props.type === 'minimal' || !props.minimalTypePadding,
}
)}
style={css}
Expand Down
33 changes: 33 additions & 0 deletions src/pages/dashboard/components/PastDueInvoices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@ import { Badge } from '$app/components/Badge';
import { useDisableNavigation } from '$app/common/hooks/useDisableNavigation';
import { useCurrentCompanyDateFormats } from '$app/common/hooks/useCurrentCompanyDateFormats';
import { DynamicLink } from '$app/components/DynamicLink';
import { useState } from 'react';
import { Button } from '$app/components/forms';

export function PastDueInvoices() {
const formatMoney = useFormatMoney();
const { dateFormat } = useCurrentCompanyDateFormats();

const disableNavigation = useDisableNavigation();

const [filter, setFilter] = useState<'filter_1' | 'filter_2'>();

const columns: DataTableColumns<Invoice> = [
{
id: 'number',
Expand Down Expand Up @@ -82,6 +86,35 @@ export function PastDueInvoices() {
className="h-96 relative"
withoutBodyPadding
withoutHeaderBorder
topRight={
<div className="flex space-x-3">
<Button
behavior="button"
type={filter === 'filter_1' ? 'primary' : 'minimal'}
onClick={() =>
setFilter((current) =>
current === 'filter_1' ? undefined : 'filter_1'
)
}
minimalTypePadding
>
{t('filter_1')}
</Button>

<Button
behavior="button"
type={filter === 'filter_2' ? 'primary' : 'minimal'}
onClick={() =>
setFilter((current) =>
current === 'filter_2' ? undefined : 'filter_2'
)
}
minimalTypePadding
>
{t('filter_2')}
</Button>
</div>
}
>
<div className="pl-6 pr-4">
<DataTable
Expand Down
34 changes: 34 additions & 0 deletions src/pages/dashboard/components/RecentPayments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@ import { date } from '$app/common/helpers';
import { useCurrentCompanyDateFormats } from '$app/common/hooks/useCurrentCompanyDateFormats';
import { useDisableNavigation } from '$app/common/hooks/useDisableNavigation';
import { DynamicLink } from '$app/components/DynamicLink';
import { Button } from '$app/components/forms';
import { useState } from 'react';

export function RecentPayments() {
const formatMoney = useFormatMoney();
const { dateFormat } = useCurrentCompanyDateFormats();

const disableNavigation = useDisableNavigation();

const [filter, setFilter] = useState<'filter_1' | 'filter_2'>();

const columns: DataTableColumns<Payment> = [
{
id: 'number',
Expand Down Expand Up @@ -95,6 +99,36 @@ export function RecentPayments() {
title={t('recent_payments')}
className="h-96 relative"
withoutBodyPadding
topRight={
<div className="flex space-x-3">
<Button
behavior="button"
type="minimal"
onClick={() => setFilter(undefined)}
minimalTypePadding
>
{t('both')}
</Button>

<Button
behavior="button"
type={filter === 'filter_1' ? 'primary' : 'minimal'}
onClick={() => setFilter('filter_1')}
minimalTypePadding
>
{t('filter_1')}
</Button>

<Button
behavior="button"
type={filter === 'filter_2' ? 'primary' : 'minimal'}
onClick={() => setFilter('filter_2')}
minimalTypePadding
>
{t('filter_2')}
</Button>
</div>
}
>
<div className="pl-6 pr-4">
<DataTable
Expand Down