Skip to content
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
1 change: 0 additions & 1 deletion packages/api/src/controllers/productController.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ const productController = {

// LF-4963 - confirm property that will distinguish custom from library products
const isLibraryProduct = product.product_translation_key;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flip flopped on this for a second but I see some benefit in it staying


if (!isLibraryProduct && isUnusedByTasks) {
await baseController.delete(ProductModel, product_id, req, { trx });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import Input, { getInputErrors } from '../../Form/Input';
import ProductDetails, { type ProductDetailsProps } from '../../Form/ProductDetails';
import { hookFormMaxCharsValidation } from '../../Form/hookformValidationUtils';
import { getSoilAmendmentFormValues } from '../../Form/ProductDetails/utils';
import { isLibraryProduct } from '../../../util/product';
// LF-4970
// import { isLibraryProduct } from '../../../util/product';
import { productDefaultValuesByType } from '../../../containers/ProductInventory/ProductForm/constants';
import { TASK_TYPES } from '../../../containers/Task/constants';
import { PRODUCT_FIELD_NAMES } from '../../Task/AddSoilAmendmentProducts/types';
Expand Down Expand Up @@ -81,9 +82,8 @@ const PureSoilAmendmentProductForm = ({
}, [mode]);

const customProductNames = useMemo(() => {
return products
.filter((product) => !product.removed && !isLibraryProduct(product))
.map(({ name }) => name);
// LF-4970 -> .filter((product) => !product.removed && !isLibraryProduct(product))
return products.filter((product) => !product.removed).map(({ name }) => name);
}, [products]);

return (
Expand Down
45 changes: 23 additions & 22 deletions packages/webapp/src/containers/Filter/ProductInventory/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import FilterGroup from '../../../components/Filter/FilterGroup';
import type { ReduxFilterEntity, ContainerOnChangeCallback, FilterState } from '../types';
import { FilterType, type ComponentFilter } from '../../../components/Filter/types';
import { useGetSoilAmendmentFertiliserTypesQuery } from '../../../store/api/apiSlice';
import { ProductCategory, InventoryFilterKeys } from './types';
import { InventoryFilterKeys } from './types';
import { sortFilterOptions } from '../../../components/Filter/utils';

interface ProductInventoryFilterContentProps {
Expand All @@ -37,27 +37,28 @@ const ProductInventoryFilterContent = ({
const { data: fertiliserTypes = [] } = useGetSoilAmendmentFertiliserTypesQuery();

const filters: ComponentFilter[] = [
{
subject: t('filter:INVENTORY.CUSTOM_OR_LITEFARM_LIBRARY'),
type: FilterType.SEARCHABLE_MULTI_SELECT,
filterKey: InventoryFilterKeys.CUSTOM_OR_LIBRARY,
options: [
{
value: ProductCategory.CUSTOM,
default:
inventoryFilter[InventoryFilterKeys.CUSTOM_OR_LIBRARY][ProductCategory.CUSTOM]
?.active ?? false,
label: t('filter:INVENTORY.CUSTOM'),
},
{
value: ProductCategory.LIBRARY,
default:
inventoryFilter[InventoryFilterKeys.CUSTOM_OR_LIBRARY][ProductCategory.LIBRARY]
?.active ?? false,
label: t('filter:INVENTORY.LITEFARM_LIBRARY'),
},
],
},
// LF-4970
// {
// subject: t('filter:INVENTORY.CUSTOM_OR_LITEFARM_LIBRARY'),
// type: FilterType.SEARCHABLE_MULTI_SELECT,
// filterKey: InventoryFilterKeys.CUSTOM_OR_LIBRARY,
// options: [
// {
// value: ProductCategory.CUSTOM,
// default:
// inventoryFilter[InventoryFilterKeys.CUSTOM_OR_LIBRARY][ProductCategory.CUSTOM]
// ?.active ?? false,
// label: t('filter:INVENTORY.CUSTOM'),
// },
// {
// value: ProductCategory.LIBRARY,
// default:
// inventoryFilter[InventoryFilterKeys.CUSTOM_OR_LIBRARY][ProductCategory.LIBRARY]
// ?.active ?? false,
// label: t('filter:INVENTORY.LITEFARM_LIBRARY'),
// },
// ],
// },
{
subject: t('filter:INVENTORY.FERTILISER_TYPE'),
type: FilterType.SEARCHABLE_MULTI_SELECT,
Expand Down
8 changes: 4 additions & 4 deletions packages/webapp/src/containers/ProductInventory/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { useFilteredInventory } from './useFilteredInventory';

export type TableProduct = SoilAmendmentProduct & {
id: Extract<Product['product_id'], number>;
isLibraryProduct: boolean;
// LF-4970 - isLibraryProduct: boolean;
};

const PRODUCT_TYPE_LABELS: Partial<Record<Product['type'], string>> = {
Expand Down Expand Up @@ -73,8 +73,8 @@ export default function ProductInventory() {
.map((product) => ({
...product,
id: product.product_id,
/* Placeholder until library products are defined */
isLibraryProduct: product.product_id % 2 === 0,
/* LF-4970 - Placeholder until library products are defined */
// isLibraryProduct: product.product_id % 2 === 0,
}));

const filteredInventory = useFilteredInventory(inventory);
Expand Down Expand Up @@ -132,7 +132,7 @@ export default function ProductInventory() {
// Custom JSX used over <IconCell /> to reduce style override complexity
<div className={styles.nameContainer}>
<div className={styles.nameAndIcon}>
{d.isLibraryProduct && <BookIcon />}
{/* LF-4970 {d.isLibraryProduct && <BookIcon />} */}
<span className={styles.name}>{d.name}</span>
</div>
<span className={styles.supplierMobile}>{d.supplier}</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export const useFilteredInventory = (inventory: TableProduct[]) => {

const filterMatches = useMemo(() => {
return inventory.filter((product) => {
const key = product.isLibraryProduct ? ProductCategory.LIBRARY : ProductCategory.CUSTOM;
// LF-4970 - const key = product.isLibraryProduct ? ProductCategory.LIBRARY : ProductCategory.CUSTOM;
const key = ProductCategory.CUSTOM;
const customOrLibraryMatches =
isInactive(customOrLibraryFilter) || customOrLibraryFilter[key]?.active;

Expand Down
1 change: 0 additions & 1 deletion packages/webapp/src/containers/productSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { createEntityAdapter, createSlice } from '@reduxjs/toolkit';
import { loginSelector, onLoadingFail, onLoadingStart } from './userFarmSlice';
import { pick } from '../util/pick';
import { createSelector } from 'reselect';
import { isLibraryProduct } from '../util/product';
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused import


export const getProduct = (obj) => {
return pick(obj, [
Expand Down
2 changes: 1 addition & 1 deletion packages/webapp/src/util/product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import { Product } from '../store/api/types';

// LF-4963 - confirm property that will distinguish custom from library products
// LF-4970, LF-4963 - confirm property that will distinguish custom from library products
export const isLibraryProduct = (product: Product) => {
return !!product.product_translation_key;
};
Loading