Skip to content

Commit

Permalink
Merge pull request #3084 from LiteFarmOrg/hotfix/3.6.2
Browse files Browse the repository at this point in the history
Hotfix 3.6.2
  • Loading branch information
kathyavini authored Jan 17, 2024
2 parents 86f73e0 + b7fcddc commit d8919c4
Show file tree
Hide file tree
Showing 29 changed files with 238 additions and 160 deletions.
2 changes: 1 addition & 1 deletion packages/api/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "litefarm-api",
"version": "3.6.1",
"version": "3.6.2",
"description": "LiteFarm API server",
"main": "./api/src/server.js",
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ if (process.env.SENTRY_DSN && environment !== 'development') {
// Automatically instrument Node.js libraries and frameworks
...Sentry.autoDiscoverNodePerformanceMonitoringIntegrations(),
],
release: '3.6.1',
release: '3.6.2',
// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
Expand Down
2 changes: 1 addition & 1 deletion packages/webapp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "litefarm-webapp",
"version": "3.6.1",
"version": "3.6.2",
"description": "LiteFarm Web application",
"type": "module",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,25 @@ import useIsAboveBreakpoint from '../../../hooks/useIsAboveBreakpoint';
import DropdownButton from '../../Form/DropDownButton';
import FloatingButtonMenu from '../../Menu/FloatingButtonMenu';
import FloatingMenu from '../../Menu/FloatingButtonMenu/FloatingMenu';
import {
ADD_EXPENSE_URL,
ADD_REVENUE_URL,
EXPENSE_CATEGORIES_URL,
REVENUE_TYPES_URL,
} from '../../../util/siteMapConstants';

const Menu = forwardRef((props, ref) => {
const { t } = useTranslation();
const dispatch = useDispatch();

const handleAddRevenueClick = () => {
dispatch(setPersistedPaths(['/revenue_types', '/add_sale']));
history.push('/revenue_types');
dispatch(setPersistedPaths([REVENUE_TYPES_URL, ADD_REVENUE_URL]));
history.push(REVENUE_TYPES_URL);
};

const handleAddExpenseClick = () => {
dispatch(setPersistedPaths(['/expense_categories', '/add_expense']));
history.push('/expense_categories');
dispatch(setPersistedPaths([EXPENSE_CATEGORIES_URL, ADD_EXPENSE_URL]));
history.push(EXPENSE_CATEGORIES_URL);
};

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ import styles from './styles.module.scss';
import { Semibold, Text } from '../../Typography';
import clsx from 'clsx';
import TextButton from '../../Form/Button/TextButton';
import {
ESTIMATED_REVENUE_URL,
LABOUR_URL,
OTHER_EXPENSE_URL,
} from '../../../util/siteMapConstants';

ChartJS.register(ArcElement, Tooltip);

Expand Down Expand Up @@ -143,7 +148,7 @@ const FinancesCarrousel = ({
<div className={styles.expensesStatsContainer}>
<TextButton
className={clsx([styles.labourExpensesContainer, styles.clickableContainer])}
onClick={() => history.push('/labour')}
onClick={() => history.push(LABOUR_URL)}
>
<span>
<span className={styles.labourExpensesTitle}>
Expand All @@ -159,7 +164,7 @@ const FinancesCarrousel = ({
</TextButton>
<TextButton
className={clsx([styles.otherExpensesContainer, styles.clickableContainer])}
onClick={() => history.push('/other_expense')}
onClick={() => history.push(OTHER_EXPENSE_URL)}
>
<span>
<span className={styles.otherExpensesTitle}>{t('SALE.FINANCES.TOTAL_OTHER')}</span>
Expand Down Expand Up @@ -194,7 +199,7 @@ const FinancesCarrousel = ({
/>
<TextButton
className={clsx([styles.estimatedRevenueContainer, styles.clickableContainer])}
onClick={() => history.push('/estimated_revenue')}
onClick={() => history.push(ESTIMATED_REVENUE_URL)}
>
<span>
<span className={styles.estimatedRevenueTitle}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { useTranslation } from 'react-i18next';
import Table from '../../../Table/v2';
import history from '../../../../history';
import styles from './styles.module.scss';
import { createRevenueDetailsUrl } from '../../../../util/siteMapConstants';

const getColumns = (t, mobileView, totalAmount, quantityTotal, currencySymbol) => [
{
Expand Down Expand Up @@ -91,7 +92,7 @@ export default function CropSaleTable({ data, currencySymbol, mobileView }) {
? () => <FooterCell t={t} totalAmount={totalAmount} quantityTotal={quantityWithUnit} />
: null
}
onClickMore={() => history.push(`/revenue/${relatedId}`)}
onClickMore={() => history.push(createRevenueDetailsUrl(relatedId))}
/>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ import { useTranslation } from 'react-i18next';
import { BsChevronRight } from 'react-icons/bs';
import { transactionTypeEnum } from '../../../../containers/Finances/useTransactions';
import history from '../../../../history';
import {
createExpenseDetailsUrl,
createRevenueDetailsUrl,
LABOUR_URL,
} from '../../../../util/siteMapConstants';
import TextButton from '../../../Form/Button/TextButton';
import CropSaleTable from './CropSaleTable';
import GeneralTransactionTable from './GeneralTransactionTable';
Expand All @@ -32,10 +37,10 @@ const components = {

const getDetailPageLink = ({ transactionType, relatedId }) => {
return {
LABOUR_EXPENSE: '/labour',
EXPENSE: `/expense/${relatedId}`,
REVENUE: `/revenue/${relatedId}`,
CROP_REVENUE: `/revenue/${relatedId}`,
LABOUR_EXPENSE: LABOUR_URL,
EXPENSE: createExpenseDetailsUrl(relatedId),
REVENUE: createRevenueDetailsUrl(relatedId),
CROP_REVENUE: createRevenueDetailsUrl(relatedId),
}[transactionType];
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ import {
mapSalesToRevenueItems,
} from '../util';
import { getCropVarieties } from '../../saga';
import { ADD_REVENUE_URL, REVENUE_TYPES_URL } from '../../../util/siteMapConstants';

export default function ActualRevenue({ history, match }) {
const { t } = useTranslation();
const dispatch = useDispatch();
const onGoBack = () => history.back();
const onAddRevenue = () => {
dispatch(setPersistedPaths(['/revenue_types', '/add_sale']));
history.push('/revenue_types');
dispatch(setPersistedPaths([REVENUE_TYPES_URL, ADD_REVENUE_URL]));
history.push(REVENUE_TYPES_URL);
};
// TODO: refactor sale data after finance reducer is remade
const sales = useSelector(salesSelector);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useDispatch } from 'react-redux';
import FinanceGroup from '../../../components/Finances/FinanceGroup';
import { getManagementPlanCardDate } from '../../../util/moment';
import { setSelectedSale } from '../actions';
import { createRevenueDetailsUrl } from '../../../util/siteMapConstants';

const ActualRevenueItem = ({ revenueItem, history, ...props }) => {
const { sale_id, sale_date, customer_name } = revenueItem.sale;
Expand All @@ -12,7 +13,7 @@ const ActualRevenueItem = ({ revenueItem, history, ...props }) => {

const onClickForward = () => {
dispatch(setSelectedSale(revenueItem.sale));
history.push(`/revenue/${sale_id}`);
history.push(createRevenueDetailsUrl(sale_id));
};

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { hookFormPersistSelector } from '../../../hooks/useHookFormPersist/hookF
import ManageCustomRevenueTypesSpotlight from '../ManageCustomRevenueTypeSpotlight';
import useSortedRevenueTypes from './useSortedRevenueTypes';
import { getFinanceTypeSearchableStringFunc } from '../../util';
import { ADD_REVENUE_URL, MANAGE_CUSTOM_REVENUES_URL } from '../../../../util/siteMapConstants';

export const icons = {
CROP_SALE: <CropSaleIcon />,
Expand All @@ -39,7 +40,7 @@ export default function RevenueTypes({ useHookFormPersist, history }) {
const getOnTileClickFunc = (setValue) => {
return (typeId) => {
setValue('revenue_type_id', typeId);
history.push('/add_sale');
history.push(ADD_REVENUE_URL);
};
};

Expand Down Expand Up @@ -76,7 +77,7 @@ export default function RevenueTypes({ useHookFormPersist, history }) {
types={revenueTypes}
onGoBack={history.back}
progressValue={33}
onGoToManageCustomType={() => history.push('/manage_custom_revenues')}
onGoToManageCustomType={() => history.push(MANAGE_CUSTOM_REVENUES_URL)}
getFormatListItemDataFunc={getFormatListItemDataFunc}
listItemType={listItemTypes.ICON_DESCRIPTION}
useHookFormPersist={useHookFormPersist}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { useDispatch, useSelector } from 'react-redux';
import { retireCustomExpenseType } from '../saga';
import { expenseTypeByIdSelector } from '../selectors';
import { CUSTOM_EXPENSE_NAME } from './constants';
import { createEditCustomExpenseURL } from '../../../util/siteMapConstants';

function ReadOnlyCustomExpense({ history, match }) {
const expense_type_id = match.params.expense_type_id;
Expand All @@ -40,7 +41,7 @@ function ReadOnlyCustomExpense({ history, match }) {
};

const handleEdit = () => {
history.push(`/edit_custom_expense/${expense_type_id}`);
history.push(createEditCustomExpenseURL(expense_type_id));
};

const onRetire = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { revenueTypeByIdSelector } from '../../revenueTypeSlice';
import { CUSTOM_REVENUE_NAME, CROP_GENERATED } from './constants';
import { HookFormPersistProvider } from '../../hooks/useHookFormPersist/HookFormPersistProvider';
import CustomRevenueRadios from './CustomRevenueRadios';
import { createEditCustomRevenueUrl } from '../../../util/siteMapConstants';

function ReadOnlyCustomRevenue({ history, match }) {
const { revenue_type_id } = match.params;
Expand All @@ -41,7 +42,7 @@ function ReadOnlyCustomRevenue({ history, match }) {
};

const handleEdit = () => {
history.push(`/edit_custom_revenue/${revenue_type_id}`);
history.push(createEditCustomRevenueUrl(revenue_type_id));
};

const onRetire = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { cropVarietySelector } from '../../cropVarietySlice';
import { useTranslation } from 'react-i18next';
import { getTasksMinMaxDate } from '../../Task/getTasksMinMaxDate';
import { taskEntitiesByManagementPlanIdSelector } from '../../taskSlice';
import { createManagementPlanEstimatedRevenueURL } from '../../../util/siteMapConstants';

const EstimatedCropRevenue = ({ cropVarietyId, managementPlans, history, ...props }) => {
const dispatch = useDispatch();
Expand Down Expand Up @@ -41,7 +42,7 @@ const EstimatedCropRevenue = ({ cropVarietyId, managementPlans, history, ...prop
amount: plan.estimated_revenue || 0,
isPlan: true,
onClickForward: () =>
history.push(`/finances/estimated_revenue/plan/${plan.management_plan_id}`),
history.push(createManagementPlanEstimatedRevenueURL(plan.management_plan_id)),
};
})}
isDropDown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import PureExpenseDetail from '../../../components/Finances/PureExpenseDetail';
import { setPersistedPaths } from '../../hooks/useHookFormPersist/hookFormPersistSlice';
import useHookFormPersist from '../../hooks/useHookFormPersist';
import { updateExpense } from '../saga';
import { createEditExpenseDetailsUrl } from '../../../util/siteMapConstants';

const ExpenseDetail = ({ history, match }) => {
const { t } = useTranslation();
Expand Down Expand Up @@ -63,8 +64,8 @@ const ExpenseDetail = ({ history, match }) => {
};

const handleEdit = () => {
dispatch(setPersistedPaths([`/expense/${expense_id}/edit`]));
history.push(`/expense/${expense_id}/edit`);
dispatch(setPersistedPaths([createEditExpenseDetailsUrl(expense_id)]));
history.push(createEditExpenseDetailsUrl(expense_id));
};

const onRetire = () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/webapp/src/containers/Finances/Labour/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { setDateRange } from '../actions';
import { dateRangeOptions } from '../../../components/DateRangeSelector/constants';
import DateRange, { SUNDAY } from '../../../util/dateRange';
import { getManagementPlansAndTasks } from '../../saga';
import { FINANCES_HOME_URL } from '../../../util/siteMapConstants';

class Labour extends Component {
constructor(props) {
Expand Down Expand Up @@ -88,7 +89,7 @@ class Labour extends Component {

return (
<div className={defaultStyles.financesContainer}>
<PageTitle backUrl="/Finances" title={this.props.t('SALE.LABOUR.TITLE')} />
<PageTitle backUrl={FINANCES_HOME_URL} title={this.props.t('SALE.LABOUR.TITLE')} />
<DateRangeSelector />
<div className={styles.topButtonContainer}>
<Main>{this.props.t('SALE.LABOUR.BY')}</Main>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,21 @@ import { setPersistedPaths } from '../../hooks/useHookFormPersist/hookFormPersis
import { icons } from '../NewExpense/ExpenseCategories';
import labelIconStyles from '../../../components/Tile/styles.module.scss';
import useCustomExpenseTypeTileContents from '../useCustomExpenseTypeTileContents';
import {
ADD_CUSTOM_EXPENSE_URL,
ADD_EXPENSE_URL,
EXPENSE_CATEGORIES_URL,
FINANCES_HOME_URL,
MANAGE_CUSTOM_EXPENSES_URL,
createEditCustomExpenseURL,
createReadonlyCustomExpenseURL,
} from '../../../util/siteMapConstants';

const addCustomTypePath = '/add_custom_expense';
const addCustomTypePath = ADD_CUSTOM_EXPENSE_URL;

const getPaths = (typeId) => ({
readOnly: `/readonly_custom_expense/${typeId}`,
edit: `/edit_custom_expense/${typeId}`,
readOnly: createReadonlyCustomExpenseURL(typeId),
edit: createEditCustomExpenseURL(typeId),
});

export default function ManageExpenseTypes({ history }) {
Expand All @@ -41,20 +50,20 @@ export default function ManageExpenseTypes({ history }) {
};

useEffect(() => {
// Manipulate page navigation by pushing "/expense_categories" on top of "/Finances".
// Manipulate page navigation by pushing EXPENSE_CATEGORIES_URL on top of FINANCES_HOME_URL.
// When browser's back button or form's back button is clicked, we want to
// navigate the user to "/expense_categories" not "/Finances".
// navigate the user to EXPENSE_CATEGORIES_URL not FINANCES_HOME_URL.
const unlisten = history.listen(() => {
if (history.action === 'POP' && history.location.pathname === '/Finances') {
dispatch(setPersistedPaths(['/expense_categories', '/add_expense']));
if (history.action === 'POP' && history.location.pathname === FINANCES_HOME_URL) {
dispatch(setPersistedPaths([EXPENSE_CATEGORIES_URL, ADD_EXPENSE_URL]));
unlisten();
history.push('/expense_categories');
history.push(EXPENSE_CATEGORIES_URL);
} else if (
// unlisten when the user gets out of the page without going back to '/Finances'.
// unlisten when the user gets out of the page without going back to FINANCES_HOME_URL.
// pathname: "/manage_custom_expenses" happens when the user lands on this page.
!(
history.location.pathname === `/manage_custom_expenses` ||
(history.action === 'POP' && history.location.pathname === '/Finances')
history.location.pathname === MANAGE_CUSTOM_EXPENSES_URL ||
(history.action === 'POP' && history.location.pathname === FINANCES_HOME_URL)
)
) {
unlisten();
Expand Down
Loading

0 comments on commit d8919c4

Please sign in to comment.