diff --git a/packages/apps/purchase/src/components/templates/RequestCreationQuantityCard/RequestCreationQuantityCard.tsx b/packages/apps/purchase/src/components/templates/RequestCreationQuantityCard/RequestCreationQuantityCard.tsx index 62b74d0f4e..35f4f1f148 100644 --- a/packages/apps/purchase/src/components/templates/RequestCreationQuantityCard/RequestCreationQuantityCard.tsx +++ b/packages/apps/purchase/src/components/templates/RequestCreationQuantityCard/RequestCreationQuantityCard.tsx @@ -16,9 +16,9 @@ * along with this program. If not, see . */ -import React from 'react'; +import React, {useMemo} from 'react'; import {useTranslator} from '@axelor/aos-mobile-core'; -import {QuantityCard, Text} from '@axelor/aos-mobile-ui'; +import {checkNullString, QuantityCard, Text} from '@axelor/aos-mobile-ui'; interface RequestCreationQuantityCardProps { quantity: number; @@ -36,18 +36,23 @@ const RequestCreationQuantityCard = ({ }: RequestCreationQuantityCardProps) => { const I18n = useTranslator(); + const isProductName = useMemo( + () => !checkNullString(productName), + [productName], + ); + return ( - {productName} + {isProductName && {productName}} ); }; diff --git a/packages/apps/purchase/src/screens/RequestCreationScreen.tsx b/packages/apps/purchase/src/screens/RequestCreationScreen.tsx index 368e861c6d..aac4990c74 100644 --- a/packages/apps/purchase/src/screens/RequestCreationScreen.tsx +++ b/packages/apps/purchase/src/screens/RequestCreationScreen.tsx @@ -72,7 +72,9 @@ const RequestCreationScreen = () => { handleReset(RequestCreation.step.addLine); } else { setNewLine(_value); + setProductTitle(_value.name); setUnit(_value?.unit); + setIsCustomProduct(false); setCurrentStep(RequestCreation.step.validateLine); } }, @@ -144,49 +146,35 @@ const RequestCreationScreen = () => { handleEditLine={handleEditLine} translator={I18n.t} /> - {currentStep === RequestCreation.step.addLine && !isCustomProduct && ( - - )} - {currentStep < RequestCreation.step.validateLine && ( - - )} - {(currentStep === RequestCreation.step.addLine || - (RequestCreation.step.validateLine && isCustomProduct)) && ( - { - handleCustomProductInput(value); - if (value) { - setCurrentStep(RequestCreation.step.validateLine); - } - }} - /> - )} - {currentStep === RequestCreation.step.validateLine && ( - <> - handleReset(RequestCreation.step.addLine)} - productName={newLine?.name || productTitle} - productUnit={unit?.name || newLine?.product?.unit?.name} - /> - - - )} + + + { + handleCustomProductInput(value); + if (value) { + setCurrentStep(RequestCreation.step.validateLine); + } + }} + /> + handleReset(RequestCreation.step.addLine)} + productName={newLine?.name || productTitle} + productUnit={unit?.name || newLine?.product?.unit?.name} + /> + ); @@ -198,7 +186,7 @@ const styles = StyleSheet.create({ paddingTop: 10, }, rule: { - marginVertical: 15, + marginTop: 5, width: '80%', }, });