From 43fbf2ac8dec29fe161dd94617cbdaba59e73823 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Tue, 4 Oct 2022 16:59:51 +0200 Subject: [PATCH] (feat) withdrawal instructions in order ready email --- .../base/text-editor/fab-text-editor.tsx | 10 +++++++--- .../src/javascript/components/cart/store-cart.tsx | 2 +- .../javascript/components/store/order-actions.tsx | 15 +++++++-------- .../javascript/components/store/show-order.tsx | 5 +++-- app/frontend/src/stylesheets/application.scss | 1 + .../stylesheets/modules/store/order-actions.scss | 6 ++++++ app/services/orders/order_service.rb | 2 +- .../notify_user_order_is_ready.erb | 2 +- config/locales/app.shared.en.yml | 12 ++++++------ config/locales/mails.en.yml | 1 + 10 files changed, 34 insertions(+), 22 deletions(-) create mode 100644 app/frontend/src/stylesheets/modules/store/order-actions.scss diff --git a/app/frontend/src/javascript/components/base/text-editor/fab-text-editor.tsx b/app/frontend/src/javascript/components/base/text-editor/fab-text-editor.tsx index 0e712265d..8b3aa4a67 100644 --- a/app/frontend/src/javascript/components/base/text-editor/fab-text-editor.tsx +++ b/app/frontend/src/javascript/components/base/text-editor/fab-text-editor.tsx @@ -33,7 +33,7 @@ export interface FabTextEditorRef { /** * This component is a WYSIWYG text editor */ -export const FabTextEditor: React.ForwardRefRenderFunction = ({ heading, bulletList, blockquote, content, limit = 400, video, image, link, onChange, placeholder, error, disabled = false }, ref: RefObject) => { +const FabTextEditor: React.ForwardRefRenderFunction = ({ heading, bulletList, blockquote, content, limit = 400, video, image, link, onChange, placeholder, error, disabled = false }, ref: RefObject) => { const { t } = useTranslation('shared'); const placeholderText = placeholder || t('app.shared.text_editor.fab_text_editor.text_placeholder'); // TODO: Add ctrl+click on link to visit @@ -75,7 +75,11 @@ export const FabTextEditor: React.ForwardRefRenderFunction { - onChange(editor.getHTML()); + if (editor.isEmpty) { + onChange(''); + } else { + onChange(editor.getHTML()); + } } }); @@ -94,7 +98,7 @@ export const FabTextEditor: React.ForwardRefRenderFunction +
diff --git a/app/frontend/src/javascript/components/cart/store-cart.tsx b/app/frontend/src/javascript/components/cart/store-cart.tsx index 290ab007e..a94e31a7e 100644 --- a/app/frontend/src/javascript/components/cart/store-cart.tsx +++ b/app/frontend/src/javascript/components/cart/store-cart.tsx @@ -249,7 +249,7 @@ const StoreCart: React.FC = ({ onSuccess, onError, currentUser, */ const withdrawalInstructions = (): string => { const instructions = settings?.get('store_withdrawal_instructions'); - if (instructions) { + if (!_.isEmpty(instructions)) { return instructions; } return t('app.public.store_cart.please_contact_FABLAB', { FABLAB: settings?.get('fablab_name') }); diff --git a/app/frontend/src/javascript/components/store/order-actions.tsx b/app/frontend/src/javascript/components/store/order-actions.tsx index 0afdeea9a..97f0137ec 100644 --- a/app/frontend/src/javascript/components/store/order-actions.tsx +++ b/app/frontend/src/javascript/components/store/order-actions.tsx @@ -1,9 +1,11 @@ -import React, { useState, BaseSyntheticEvent } from 'react'; +import React, { useState } from 'react'; import { useTranslation } from 'react-i18next'; import Select from 'react-select'; import { FabModal } from '../base/fab-modal'; import OrderAPI from '../../api/order'; import { Order } from '../../models/order'; +import FabTextEditor from '../base/text-editor/fab-text-editor'; +import { HtmlTranslate } from '../base/html-translate'; interface OrderActionsProps { order: Order, @@ -115,15 +117,12 @@ export const OrderActions: React.FC = ({ order, onSuccess, on confirmButton={t('app.shared.store.order_actions.confirm')} onConfirm={handleActionConfirmation} className="order-actions-confirmation-modal"> -

{t(`app.shared.store.order_actions.confirm_order_${currentAction?.value}`)}

+ {currentAction?.value === 'ready' && -