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
6 changes: 1 addition & 5 deletions components/AccountingCategorySelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,7 @@ export const getCategoryLabel = (
/**
* Returns true if the category is supported for the given expense type. Host admins can select any category.
*/
export const isSupportedExpenseCategory = (
expenseType: ExpenseType,
category: AccountingCategory,
isHostAdmin: boolean,
) => {
const isSupportedExpenseCategory = (expenseType: ExpenseType, category: AccountingCategory, isHostAdmin: boolean) => {
return (
category?.kind === AccountingCategoryKind.EXPENSE &&
(isHostAdmin || !category?.expensesTypes || category.expensesTypes.includes(expenseType))
Expand Down
7 changes: 0 additions & 7 deletions components/I18nAddressFields.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,6 @@ const wrangleAddressData = addressInfo => {
return addressFormFields;
};

export const serializeAddress = address => {
return Object.keys(address)
.sort()
.map(k => address[k])
.join('\n');
};

/** Upon changing selectedCountry, if previous address fields are no longer needed,
* it clears them i.e. changing from Canada to Germany in the Expense form we no
* longer need 'zone' in our payeeLocation.address object.
Expand Down
45 changes: 7 additions & 38 deletions components/collective-navbar/ActionsMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,11 @@ import { AttachMoney } from '@styled-icons/material/AttachMoney';
import { Settings } from '@styled-icons/material/Settings';
import { Stack } from '@styled-icons/remix-line/Stack';
import { pickBy } from 'lodash';
import { useRouter } from 'next/router';
import { FormattedMessage } from 'react-intl';
import styled, { css } from 'styled-components';

import { getContributeRoute } from '../../lib/collective';
import { isSupportedExpenseType } from '../../lib/expenses';
import { ExpenseType } from '../../lib/graphql/types/v2/graphql';
import { PREVIEW_FEATURE_KEYS } from '../../lib/preview-features';
import { getCollectivePageRoute, getDashboardRoute } from '../../lib/url-helpers';
import { parseToBoolean } from '@/lib/utils';

import ActionButton from '../ActionButton';
import AddFundsBtn from '../AddFundsBtn';
Expand Down Expand Up @@ -183,16 +178,6 @@ const CollectiveNavbarActionsMenu = ({
const enabledCTAs = Object.keys(pickBy(callsToAction, Boolean));
const isEmpty = enabledCTAs.length < 1;
const hasOnlyOneHiddenCTA = enabledCTAs.length === 1 && hiddenActionForNonMobile === enabledCTAs[0];
const router = useRouter();

const newExpenseFlowOptedOut = parseToBoolean(router?.query?.forceLegacyFlow);
const isNewGrantFlowEnabled =
!newExpenseFlowOptedOut && LoggedInUser?.hasPreviewFeatureEnabled(PREVIEW_FEATURE_KEYS.NEW_EXPENSE_FLOW);

const isNewExpenseFlowEnabled =
!newExpenseFlowOptedOut &&
LoggedInUser?.hasPreviewFeatureEnabled(PREVIEW_FEATURE_KEYS.NEW_EXPENSE_FLOW) &&
(!isSupportedExpenseType(collective, ExpenseType.GRANT) || isNewGrantFlowEnabled);

// Do not render the menu if there are no available CTAs
if (isEmpty) {
Expand Down Expand Up @@ -241,33 +226,17 @@ const CollectiveNavbarActionsMenu = ({
)}
{callsToAction.hasSubmitExpense && (
<MenuItem isHiddenOnMobile={hiddenActionForNonMobile === NAVBAR_ACTION_TYPE.SUBMIT_EXPENSE}>
{isNewExpenseFlowEnabled ? (
<StyledLink onClick={onOpenSubmitExpenseModalClick}>
<Container p={ITEM_PADDING}>
<Receipt size="20px" />
<FormattedMessage id="ExpenseForm.Submit" defaultMessage="Submit expense" />
</Container>
</StyledLink>
) : (
<StyledLink
data-cy="submit-expense-dropdown"
as={Link}
href={`${getCollectivePageRoute(collective)}/expenses/new?forceLegacyFlow=true`}
>
<Container p={ITEM_PADDING}>
<Receipt size="20px" />
<FormattedMessage id="ExpenseForm.Submit" defaultMessage="Submit expense" />
</Container>
</StyledLink>
)}
<StyledLink onClick={onOpenSubmitExpenseModalClick}>
<Container p={ITEM_PADDING}>
<Receipt size="20px" />
<FormattedMessage id="ExpenseForm.Submit" defaultMessage="Submit expense" />
</Container>
</StyledLink>
</MenuItem>
)}
{callsToAction.hasRequestGrant && (
<MenuItem py={1} isHiddenOnMobile={hiddenActionForNonMobile === NAVBAR_ACTION_TYPE.REQUEST_GRANT}>
<StyledLink
as={Link}
href={`${getCollectivePageRoute(collective)}/${isNewGrantFlowEnabled ? 'grants' : 'expenses'}/new`}
>
<StyledLink as={Link} href={`${getCollectivePageRoute(collective)}/grants/new`}>
<Container p={ITEM_PADDING}>
<MoneyCheckAlt size="20px" />
<FormattedMessage id="ExpenseForm.Type.Request" defaultMessage="Request Grant" />
Expand Down
26 changes: 3 additions & 23 deletions components/collective-navbar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ import EXPENSE_TYPE from '../../lib/constants/expenseTypes';
import roles from '../../lib/constants/roles';
import { isSupportedExpenseType } from '../../lib/expenses';
import { API_V2_CONTEXT, gql } from '../../lib/graphql/helpers';
import { ExpenseType } from '../../lib/graphql/types/v2/graphql';
import useGlobalBlur from '../../lib/hooks/useGlobalBlur';
import useLoggedInUser from '../../lib/hooks/useLoggedInUser';
import { PREVIEW_FEATURE_KEYS } from '../../lib/preview-features';
import { getCollectivePageRoute, getDashboardRoute } from '../../lib/url-helpers';

import ActionButton from '../ActionButton';
Expand Down Expand Up @@ -508,12 +506,6 @@ const CollectiveNavbar = ({

const loading = isLoading || dataLoading;

const isNewGrantFlowEnabled = LoggedInUser?.hasPreviewFeatureEnabled(PREVIEW_FEATURE_KEYS.NEW_EXPENSE_FLOW);

const isNewExpenseFlowEnabled =
LoggedInUser?.hasPreviewFeatureEnabled(PREVIEW_FEATURE_KEYS.NEW_EXPENSE_FLOW) &&
(!isSupportedExpenseType(collective, ExpenseType.GRANT) || isNewGrantFlowEnabled);

const isAllowedAddFunds = Boolean(data?.account?.permissions?.addFunds?.allowed);
const sections = React.useMemo(() => {
return sectionsFromParent || getFilteredSectionsForCollective(collective, isAdmin, isHostAdmin);
Expand All @@ -531,23 +523,11 @@ const CollectiveNavbar = ({
...callsToAction,
};
const actionsArray = Object.keys(pickBy(callsToAction, Boolean));
const mainAction = getMainAction(
collective,
actionsArray,
LoggedInUser,
isNewExpenseFlowEnabled,
isNewGrantFlowEnabled,
() => setIsSubmitExpenseModalOpen(true),
);
const mainAction = getMainAction(collective, actionsArray, LoggedInUser, () => setIsSubmitExpenseModalOpen(true));
const secondAction =
actionsArray.length === 2 &&
getMainAction(
collective,
without(actionsArray, mainAction?.type),
LoggedInUser,
isNewExpenseFlowEnabled,
isNewGrantFlowEnabled,
() => setIsSubmitExpenseModalOpen(true),
getMainAction(collective, without(actionsArray, mainAction?.type), LoggedInUser, () =>
setIsSubmitExpenseModalOpen(true),
);
const navbarRef = useRef(undefined);
const mainContainerRef = useRef(undefined);
Expand Down
14 changes: 3 additions & 11 deletions components/dashboard/sections/expenses/ReceivedExpenses.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
ExpenseType,
PayoutMethodType,
} from '../../../../lib/graphql/types/v2/schema';
import useLoggedInUser from '../../../../lib/hooks/useLoggedInUser';
import useQueryFilter from '../../../../lib/hooks/useQueryFilter';
import { PREVIEW_FEATURE_KEYS } from '../../../../lib/preview-features';
import { i18nExpenseType } from '@/lib/i18n/expense';
import { sortSelectOptions } from '@/lib/utils';

Expand Down Expand Up @@ -111,7 +109,6 @@
const ReceivedExpenses = ({ accountSlug }: DashboardSectionProps) => {
const router = useRouter();
const [isExpenseFlowOpen, setIsExpenseFlowOpen] = React.useState(false);
const { LoggedInUser } = useLoggedInUser();

const {
data: metadata,
Expand Down Expand Up @@ -161,9 +158,6 @@
context: API_V2_CONTEXT,
});

const hasNewSubmitExpenseFlow =
LoggedInUser?.hasPreviewFeatureEnabled(PREVIEW_FEATURE_KEYS.NEW_EXPENSE_FLOW) || router.query.newExpenseFlowEnabled;

const pageRoute = `/dashboard/${accountSlug}/expenses`;

return (
Expand All @@ -173,11 +167,9 @@
title={<FormattedMessage defaultMessage="Received Expenses" id="1c0Y31" />}
description={<FormattedMessage defaultMessage="Expenses submitted to your account." id="0I3Lbj" />}
actions={
hasNewSubmitExpenseFlow ? (
<Button onClick={() => setIsExpenseFlowOpen(true)} size="sm" className="gap-1">
<FormattedMessage defaultMessage="New expense" id="pNn/g+" />
</Button>
) : null
<Button onClick={() => setIsExpenseFlowOpen(true)} size="sm" className="gap-1">
<FormattedMessage defaultMessage="New expense" id="pNn/g+" />
</Button>
}
/>
{isSelfHosted && (
Expand Down Expand Up @@ -242,7 +234,7 @@
)}
</div>
{isExpenseFlowOpen && (
<SubmitExpenseFlow

Check failure on line 237 in components/dashboard/sections/expenses/ReceivedExpenses.tsx

View workflow job for this annotation

GitHub Actions / typescript

Property 'customData' is missing in type '{ onClose: (submittedExpense: boolean) => void; submitExpenseTo: string; }' but required in type 'SubmitExpenseFlowProps'.
onClose={submittedExpense => {
setIsExpenseFlowOpen(false);
if (submittedExpense) {
Expand Down
26 changes: 10 additions & 16 deletions components/dashboard/sections/expenses/SubmittedExpenses.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import { API_V2_CONTEXT } from '../../../../lib/graphql/helpers';
import useLoggedInUser from '../../../../lib/hooks/useLoggedInUser';
import useQueryFilter from '../../../../lib/hooks/useQueryFilter';
import { PREVIEW_FEATURE_KEYS } from '../../../../lib/preview-features';
import type { FilterComponentConfigs } from '@/lib/filters/filter-types';
import type { Currency } from '@/lib/graphql/types/v2/schema';
import { ExpenseType } from '@/lib/graphql/types/v2/schema';
Expand Down Expand Up @@ -94,9 +93,6 @@
accountingCategoryKinds: ExpenseAccountingCategoryKinds,
};

const hasNewSubmitExpenseFlow =
LoggedInUser?.hasPreviewFeatureEnabled(PREVIEW_FEATURE_KEYS.NEW_EXPENSE_FLOW) || router.query.newExpenseFlowEnabled;

const pageRoute = `/dashboard/${accountSlug}/submitted-expenses`;

if (error) {
Expand All @@ -112,18 +108,16 @@
<FormattedMessage defaultMessage="Expenses that you have submitted to other accounts." id="aKfm6V" />
}
actions={
hasNewSubmitExpenseFlow ? (
<Button
onClick={() => {
setDuplicateExpenseId(null);
setIsExpenseFlowOpen(true);
}}
size="sm"
className="gap-1"
>
<FormattedMessage defaultMessage="New expense" id="pNn/g+" />
</Button>
) : null
<Button
onClick={() => {
setDuplicateExpenseId(null);
setIsExpenseFlowOpen(true);
}}
size="sm"
className="gap-1"
>
<FormattedMessage defaultMessage="New expense" id="pNn/g+" />
</Button>
}
/>
<Filterbar {...queryFilter} meta={filterMeta} />
Expand Down Expand Up @@ -167,7 +161,7 @@
)}
</div>
{isExpenseFlowOpen && (
<SubmitExpenseFlow

Check failure on line 164 in components/dashboard/sections/expenses/SubmittedExpenses.tsx

View workflow job for this annotation

GitHub Actions / typescript

Property 'customData' is missing in type '{ onClose: (submittedExpense: boolean) => void; expenseId: any; duplicateExpense: boolean; }' but required in type 'SubmitExpenseFlowProps'.
onClose={submittedExpense => {
setDuplicateExpenseId(null);
setIsExpenseFlowOpen(false);
Expand Down
86 changes: 0 additions & 86 deletions components/expenses/AddNewAttachedFilesButton.tsx

This file was deleted.

35 changes: 0 additions & 35 deletions components/expenses/ConfirmOCRValues.tsx

This file was deleted.

Loading
Loading