1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-29 10:24:20 +01:00

(feat) withdrawal instructions in order ready email

This commit is contained in:
Sylvain 2022-10-04 16:59:51 +02:00
parent 72d55a6a0b
commit 43fbf2ac8d
10 changed files with 34 additions and 22 deletions

View File

@ -33,7 +33,7 @@ export interface FabTextEditorRef {
/** /**
* This component is a WYSIWYG text editor * This component is a WYSIWYG text editor
*/ */
export const FabTextEditor: React.ForwardRefRenderFunction<FabTextEditorRef, FabTextEditorProps> = ({ heading, bulletList, blockquote, content, limit = 400, video, image, link, onChange, placeholder, error, disabled = false }, ref: RefObject<FabTextEditorRef>) => { const FabTextEditor: React.ForwardRefRenderFunction<FabTextEditorRef, FabTextEditorProps> = ({ heading, bulletList, blockquote, content, limit = 400, video, image, link, onChange, placeholder, error, disabled = false }, ref: RefObject<FabTextEditorRef>) => {
const { t } = useTranslation('shared'); const { t } = useTranslation('shared');
const placeholderText = placeholder || t('app.shared.text_editor.fab_text_editor.text_placeholder'); const placeholderText = placeholder || t('app.shared.text_editor.fab_text_editor.text_placeholder');
// TODO: Add ctrl+click on link to visit // TODO: Add ctrl+click on link to visit
@ -75,7 +75,11 @@ export const FabTextEditor: React.ForwardRefRenderFunction<FabTextEditorRef, Fab
], ],
content, content,
onUpdate: ({ editor }) => { onUpdate: ({ editor }) => {
onChange(editor.getHTML()); if (editor.isEmpty) {
onChange('');
} else {
onChange(editor.getHTML());
}
} }
}); });
@ -94,7 +98,7 @@ export const FabTextEditor: React.ForwardRefRenderFunction<FabTextEditorRef, Fab
editorRef.current = editor; editorRef.current = editor;
return ( return (
<div className={`fab-text-editor ${disabled && 'is-disabled'}`}> <div className={`fab-text-editor ${disabled ? 'is-disabled' : ''}`}>
<MenuBar editor={editor} heading={heading} bulletList={bulletList} blockquote={blockquote} video={video} image={image} link={link} disabled={disabled} /> <MenuBar editor={editor} heading={heading} bulletList={bulletList} blockquote={blockquote} video={video} image={image} link={link} disabled={disabled} />
<EditorContent editor={editor} /> <EditorContent editor={editor} />
<div className="fab-text-editor-character-count"> <div className="fab-text-editor-character-count">

View File

@ -249,7 +249,7 @@ const StoreCart: React.FC<StoreCartProps> = ({ onSuccess, onError, currentUser,
*/ */
const withdrawalInstructions = (): string => { const withdrawalInstructions = (): string => {
const instructions = settings?.get('store_withdrawal_instructions'); const instructions = settings?.get('store_withdrawal_instructions');
if (instructions) { if (!_.isEmpty(instructions)) {
return instructions; return instructions;
} }
return t('app.public.store_cart.please_contact_FABLAB', { FABLAB: settings?.get('fablab_name') }); return t('app.public.store_cart.please_contact_FABLAB', { FABLAB: settings?.get('fablab_name') });

View File

@ -1,9 +1,11 @@
import React, { useState, BaseSyntheticEvent } from 'react'; import React, { useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import Select from 'react-select'; import Select from 'react-select';
import { FabModal } from '../base/fab-modal'; import { FabModal } from '../base/fab-modal';
import OrderAPI from '../../api/order'; import OrderAPI from '../../api/order';
import { Order } from '../../models/order'; import { Order } from '../../models/order';
import FabTextEditor from '../base/text-editor/fab-text-editor';
import { HtmlTranslate } from '../base/html-translate';
interface OrderActionsProps { interface OrderActionsProps {
order: Order, order: Order,
@ -115,15 +117,12 @@ export const OrderActions: React.FC<OrderActionsProps> = ({ order, onSuccess, on
confirmButton={t('app.shared.store.order_actions.confirm')} confirmButton={t('app.shared.store.order_actions.confirm')}
onConfirm={handleActionConfirmation} onConfirm={handleActionConfirmation}
className="order-actions-confirmation-modal"> className="order-actions-confirmation-modal">
<p>{t(`app.shared.store.order_actions.confirm_order_${currentAction?.value}`)}</p> <HtmlTranslate trKey={`app.shared.store.order_actions.confirm_order_${currentAction?.value}_html`} />
{currentAction?.value === 'ready' && {currentAction?.value === 'ready' &&
<textarea <FabTextEditor
id="order-ready-note" content={readyNote}
value={readyNote}
placeholder={t('app.shared.store.order_actions.order_ready_note')} placeholder={t('app.shared.store.order_actions.order_ready_note')}
onChange={(e: BaseSyntheticEvent) => setReadyNote(e.target.value)} onChange={setReadyNote} />
style={{ width: '100%' }}
rows={5} />
} }
</FabModal> </FabModal>
</> </>

View File

@ -1,5 +1,6 @@
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import _ from 'lodash';
import { IApplication } from '../../models/application'; import { IApplication } from '../../models/application';
import { User } from '../../models/user'; import { User } from '../../models/user';
import { react2angular } from 'react2angular'; import { react2angular } from 'react2angular';
@ -83,7 +84,7 @@ export const ShowOrder: React.FC<ShowOrderProps> = ({ orderId, currentUser, onSu
*/ */
const withdrawalInstructions = (): string => { const withdrawalInstructions = (): string => {
const instructions = settings?.get('store_withdrawal_instructions'); const instructions = settings?.get('store_withdrawal_instructions');
if (instructions) { if (!_.isEmpty(instructions)) {
return instructions; return instructions;
} }
return t('app.shared.store.show_order.please_contact_FABLAB', { FABLAB: settings?.get('fablab_name') }); return t('app.shared.store.show_order.please_contact_FABLAB', { FABLAB: settings?.get('fablab_name') });
@ -149,7 +150,7 @@ export const ShowOrder: React.FC<ShowOrderProps> = ({ orderId, currentUser, onSu
{order.order_items_attributes.map(item => ( {order.order_items_attributes.map(item => (
<article className='store-cart-list-item' key={item.id}> <article className='store-cart-list-item' key={item.id}>
<div className='picture'> <div className='picture'>
<img alt=''src={item.orderable_main_image_url || noImage} /> <img alt='' src={item.orderable_main_image_url || noImage} />
</div> </div>
<div className="ref"> <div className="ref">
<span>{t('app.shared.store.show_order.reference_short')} {item.orderable_ref || ''}</span> <span>{t('app.shared.store.show_order.reference_short')} {item.orderable_ref || ''}</span>

View File

@ -95,6 +95,7 @@
@import "modules/settings/user-validation-setting"; @import "modules/settings/user-validation-setting";
@import "modules/socials/fab-socials"; @import "modules/socials/fab-socials";
@import "modules/store/_utilities"; @import "modules/store/_utilities";
@import "modules/store/order-actions.scss";
@import "modules/store/order-item"; @import "modules/store/order-item";
@import "modules/store/orders-dashboard"; @import "modules/store/orders-dashboard";
@import "modules/store/orders"; @import "modules/store/orders";

View File

@ -0,0 +1,6 @@
.order-actions-confirmation-modal {
.fab-text-editor,
span > p {
margin-top: 1rem;
}
}

View File

@ -6,7 +6,7 @@ class Orders::OrderService
ORDERS_PER_PAGE = 20 ORDERS_PER_PAGE = 20
def list(filters, current_user) def list(filters, current_user)
orders = Order.includes([:statistic_profile]).where(nil) orders = Order.includes(statistic_profile: [:user]).where(nil)
orders = filter_by_user(orders, filters, current_user) orders = filter_by_user(orders, filters, current_user)
orders = filter_by_reference(orders, filters, current_user) orders = filter_by_reference(orders, filters, current_user)
orders = filter_by_state(orders, filters) orders = filter_by_state(orders, filters)

View File

@ -4,5 +4,5 @@
<%= t('.body.notify_user_order_is_ready', REFERENCE: @attached_object.order.reference) %> <%= t('.body.notify_user_order_is_ready', REFERENCE: @attached_object.order.reference) %>
</p> </p>
<p> <p>
<%= @attached_object.note %> <%= sanitize @attached_object.note.presence || Setting.get('store_withdrawal_istructions').presence || _t('notify_user_order_is_ready.body.please_contact_FABLAB', FABLAB: Setting.get('fablab_name')) %>
</p> </p>

View File

@ -623,16 +623,16 @@ en:
delivered: "Delivered" delivered: "Delivered"
confirm: 'Confirm' confirm: 'Confirm'
confirmation_required: "Confirmation required" confirmation_required: "Confirmation required"
confirm_order_in_progress: "Is this order in the process of being prepared?" confirm_order_in_progress_html: "Please confirm this order in being prepared."
order_in_progress_success: "Order is under preparation" order_in_progress_success: "Order is under preparation"
confirm_order_ready: "Is this order ready?" confirm_order_ready_html: "Please confirm this order is ready."
order_ready_note: 'Leave your message' order_ready_note: 'You can leave a message to the customer about withdrawal instructions'
order_ready_success: "Order is ready" order_ready_success: "Order is ready"
confirm_order_delivered: "Is this order delivered?" confirm_order_delivered_html: "Please confirm this order was delivered."
order_delivered_success: "Order was delivered" order_delivered_success: "Order was delivered"
confirm_order_canceled: "Do you want to cancel this order? You can modify product stock in stock manage." confirm_order_canceled_html: "<strong>Do you really want to cancel this order?</strong><p>If this impacts stock, please reflect the change in <em>edit product &gt; stock management</em>. This won't be automatic.</p>"
order_canceled_success: "Order was canceled" order_canceled_success: "Order was canceled"
confirm_order_refunded: "Do you want to refund this order? You can modify product stock in stock manage." confirm_order_refunded_html: "<stong>Do you really want to refund this order?</strong><p>If this impacts stock, please reflect the change in <em>edit product &gt; stock management</em>. This won't be automatic.</p>"
order_refunded_success: "Order was refunded" order_refunded_success: "Order was refunded"
unsaved_form_alert: unsaved_form_alert:
modal_title: "You have some unsaved changes" modal_title: "You have some unsaved changes"

View File

@ -378,6 +378,7 @@ en:
subject: "Your command is ready" subject: "Your command is ready"
body: body:
notify_user_order_is_ready: "Your command %{REFERENCE} is ready:" notify_user_order_is_ready: "Your command %{REFERENCE} is ready:"
please_contact_FABLAB: "Please contact {FABLAB, select, undefined{us} other{{FABLAB}}} for withdrawal instructions."
notify_user_order_is_canceled: notify_user_order_is_canceled:
subject: "Your command is canceled" subject: "Your command is canceled"
body: body: