Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(HostedCollectives): add 'Add expense' action #10795

Merged
merged 1 commit into from
Nov 14, 2024
Merged
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
16 changes: 15 additions & 1 deletion components/dashboard/sections/collectives/common.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
MoreHorizontal,
Pause,
Play,
Receipt,
ReceiptText,
SquareSigma,
Unlink,
Expand Down Expand Up @@ -39,6 +40,7 @@ import {
import { TableActionsButton } from '../../../ui/Table';
import { Tooltip, TooltipContent, TooltipTrigger } from '../../../ui/Tooltip';
import { DashboardContext } from '../../DashboardContext';
import { HostCreateExpenseModal } from '../expenses/HostCreateExpenseModal';

import AddFundsModal from './AddFundsModal';
import FreezeAccountModal from './FreezeAccountModal';
Expand Down Expand Up @@ -287,7 +289,7 @@ export const MoreActionsMenu = ({
const router = useRouter();
const { account } = React.useContext(DashboardContext);
const [openModal, setOpenModal] = React.useState<
null | 'ADD_FUNDS' | 'FREEZE' | 'UNHOST' | 'ADD_AGREEMENT' | 'CONTACT'
null | 'ADD_FUNDS' | 'ADD_EXPENSE' | 'FREEZE' | 'UNHOST' | 'ADD_AGREEMENT' | 'CONTACT'
>(null);

return (
Expand Down Expand Up @@ -322,6 +324,15 @@ export const MoreActionsMenu = ({
<FormattedMessage id="menu.addFunds" defaultMessage="Add Funds" />
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem
className="cursor-pointer"
data-cy="actions-add-expense"
onClick={() => setOpenModal('ADD_EXPENSE')}
>
<Receipt className="mr-2" size="16" />
<FormattedMessage defaultMessage="Add expense" id="6/UjBO" />
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem
className="cursor-pointer"
data-cy="actions-add-agreement"
Expand Down Expand Up @@ -365,6 +376,9 @@ export const MoreActionsMenu = ({
{openModal === 'ADD_FUNDS' && (
<AddFundsModal collective={collective} onClose={() => setOpenModal(null)} onSuccess={onEdit} />
)}
{openModal === 'ADD_EXPENSE' && (
<HostCreateExpenseModal open setOpen={() => setOpenModal(null)} host={collective.host} />
)}
{openModal === 'FREEZE' && (
<FreezeAccountModal collective={collective} onClose={() => setOpenModal(null)} onSuccess={onEdit} />
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ export const HostCreateExpenseModal = ({
host,
...props
}: {
transactionsImport: TransactionsImport;
transactionsImportRow: TransactionsImportRow;
host: Account;
transactionsImport?: TransactionsImport;
transactionsImportRow?: TransactionsImportRow;
} & BaseModalProps) => {
const intl = useIntl();
const [createExpense, { client }] = useMutation(hostCreateExpenseMutation, { context: API_V2_CONTEXT });
Expand Down
Loading