From e2e0e8eb62f5741d49ad8ed6948c8155d32d294a Mon Sep 17 00:00:00 2001 From: Gregory <117281520+gca-axelor@users.noreply.github.com> Date: Fri, 13 Dec 2024 10:20:13 +0100 Subject: [PATCH] feat: add button --- .../atoms/RequestHeader/RequestHeader.tsx | 13 ++-- .../RequestValidationButton.tsx | 62 +++++++++++++++++++ .../purchase/src/components/atoms/index.ts | 1 + .../RequestDropdownCards.tsx | 3 +- packages/apps/purchase/src/i18n/en.json | 5 +- packages/apps/purchase/src/i18n/fr.json | 5 +- ...tailsView.tsx => RequestDetailsScreen.tsx} | 27 ++++++-- packages/apps/purchase/src/screens/index.ts | 7 ++- 8 files changed, 105 insertions(+), 18 deletions(-) create mode 100644 packages/apps/purchase/src/components/atoms/RequestValidationButton/RequestValidationButton.tsx rename packages/apps/purchase/src/screens/{RequestDetailsView.tsx => RequestDetailsScreen.tsx} (75%) diff --git a/packages/apps/purchase/src/components/atoms/RequestHeader/RequestHeader.tsx b/packages/apps/purchase/src/components/atoms/RequestHeader/RequestHeader.tsx index 5ce838b1c..92d1f0fa3 100644 --- a/packages/apps/purchase/src/components/atoms/RequestHeader/RequestHeader.tsx +++ b/packages/apps/purchase/src/components/atoms/RequestHeader/RequestHeader.tsx @@ -18,13 +18,12 @@ import React from 'react'; import {StyleSheet, View} from 'react-native'; -import {Text, LabelText, Badge, useThemeColor} from '@axelor/aos-mobile-ui'; +import {Text, LabelText, Badge} from '@axelor/aos-mobile-ui'; import {useSelector, useTypeHelpers, useTypes} from '@axelor/aos-mobile-core'; const RequestHeader = ({}) => { - const Colors = useThemeColor(); const {PurchaseRequest} = useTypes(); - const {getItemTitle} = useTypeHelpers(); + const {getItemColor, getItemTitle} = useTypeHelpers(); const {purchaseRequest} = useSelector( state => state.purchase_purchaseRequest, @@ -39,7 +38,10 @@ const RequestHeader = ({}) => { PurchaseRequest?.statusSelect, purchaseRequest.statusSelect, )} - color={Colors.infoColor} + color={getItemColor( + PurchaseRequest?.statusSelect, + purchaseRequest.statusSelect, + )} /> { const styles = StyleSheet.create({ container: { - marginHorizontal: 15, + marginHorizontal: 24, + marginBottom: 5, }, chlidrenContainer: { flexDirection: 'row', diff --git a/packages/apps/purchase/src/components/atoms/RequestValidationButton/RequestValidationButton.tsx b/packages/apps/purchase/src/components/atoms/RequestValidationButton/RequestValidationButton.tsx new file mode 100644 index 000000000..6bbde386d --- /dev/null +++ b/packages/apps/purchase/src/components/atoms/RequestValidationButton/RequestValidationButton.tsx @@ -0,0 +1,62 @@ +/* + * Axelor Business Solutions + * + * Copyright (C) 2024 Axelor (). + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +import React from 'react'; +import {View, StyleSheet} from 'react-native'; + +import {Button, useThemeColor} from '@axelor/aos-mobile-ui'; +import {useSelector, useTranslator, useTypes} from '@axelor/aos-mobile-core'; + +const RequestValidationButton = ({}) => { + const Colors = useThemeColor(); + const I18n = useTranslator(); + const {PurchaseRequest} = useTypes(); + const {purchaseRequest} = useSelector( + state => state.purchase_purchaseRequest, + ); + + if (purchaseRequest.statusSelect === PurchaseRequest?.statusSelect.Draft) { + return ( + +