From 59fb10753d42c5122d95608491b319a68a18f1c0 Mon Sep 17 00:00:00 2001 From: Du Peng Date: Wed, 28 Jun 2023 18:23:07 +0200 Subject: [PATCH] (feat) some improvements for family account --- .../javascript/components/family-account/child-form.tsx | 1 + .../javascript/components/family-account/child-modal.tsx | 9 +++++---- .../components/family-account/child-validation.tsx | 6 +++--- .../src/javascript/components/user/members-list-item.tsx | 9 ++++++++- app/frontend/src/javascript/controllers/admin/members.js | 1 - app/frontend/templates/admin/events/monitoring.html | 8 ++++---- app/frontend/templates/admin/events/reservations.html | 8 ++++---- app/frontend/templates/events/show.html | 6 +++--- config/locales/app.admin.en.yml | 3 ++- config/locales/app.admin.fr.yml | 3 ++- config/locales/app.public.en.yml | 2 +- config/locales/app.public.fr.yml | 5 +++-- config/locales/fr.yml | 2 +- 13 files changed, 37 insertions(+), 26 deletions(-) diff --git a/app/frontend/src/javascript/components/family-account/child-form.tsx b/app/frontend/src/javascript/components/family-account/child-form.tsx index bc7ab29c1..f9e9b4a53 100644 --- a/app/frontend/src/javascript/components/family-account/child-form.tsx +++ b/app/frontend/src/javascript/components/family-account/child-form.tsx @@ -116,6 +116,7 @@ export const ChildForm: React.FC = ({ child, onSubmit, supportin defaultFile={sf as FileType} id={`supporting_document_files_attributes.${index}`} accept="application/pdf" + rules={{ required: true }} setValue={setValue} label={getSupportingDocumentsTypeName(sf.supporting_document_type_id)} showRemoveButton={false} diff --git a/app/frontend/src/javascript/components/family-account/child-modal.tsx b/app/frontend/src/javascript/components/family-account/child-modal.tsx index f950e207e..942dc60a2 100644 --- a/app/frontend/src/javascript/components/family-account/child-modal.tsx +++ b/app/frontend/src/javascript/components/family-account/child-modal.tsx @@ -28,14 +28,15 @@ export const ChildModal: React.FC = ({ child, isOpen, toggleMod * Save the child to the API */ const handleSaveChild = async (data: Child): Promise => { + let c: Child = data; try { if (child?.id) { - await ChildAPI.update(data); + c = await ChildAPI.update(data); } else { - await ChildAPI.create(data); + c = await ChildAPI.create(data); } toggleModal(); - onSuccess(data, ''); + onSuccess(c, ''); } catch (error) { onError(error); } @@ -56,7 +57,7 @@ export const ChildModal: React.FC = ({ child, isOpen, toggleMod onSubmit={handleSaveChild} supportingDocumentsTypes={supportingDocumentsTypes} operator={operator} - onSuccess={onSuccess} + onSuccess={(msg) => onSuccess(child, msg)} onError={onError} /> diff --git a/app/frontend/src/javascript/components/family-account/child-validation.tsx b/app/frontend/src/javascript/components/family-account/child-validation.tsx index 1705ad6cf..92f6db8db 100644 --- a/app/frontend/src/javascript/components/family-account/child-validation.tsx +++ b/app/frontend/src/javascript/components/family-account/child-validation.tsx @@ -9,7 +9,7 @@ import { TDateISO } from '../../typings/date-iso'; interface ChildValidationProps { child: Child - onSuccess: (message: string) => void, + onSuccess: (child: Child, msg: string) => void; onError: (message: string) => void, } @@ -37,8 +37,8 @@ export const ChildValidation: React.FC = ({ child, onSucce _child.validated_at = null; } ChildAPI.validate(_child) - .then(() => { - onSuccess(t(`app.admin.child_validation.${_value ? 'validate' : 'invalidate'}_child_success`)); + .then((c) => { + onSuccess(c, t(`app.admin.child_validation.${_value ? 'validate' : 'invalidate'}_child_success`)); }).catch(err => { setValue(!_value); onError(t(`app.admin.child_validation.${_value ? 'validate' : 'invalidate'}_child_error`) + err); diff --git a/app/frontend/src/javascript/components/user/members-list-item.tsx b/app/frontend/src/javascript/components/user/members-list-item.tsx index 4d0bea4f0..51b2458af 100644 --- a/app/frontend/src/javascript/components/user/members-list-item.tsx +++ b/app/frontend/src/javascript/components/user/members-list-item.tsx @@ -30,8 +30,15 @@ export const MembersListItem: React.FC = ({ member, onErro window.location.href = `/#!/admin/members/${memberId}/edit`; }; + /** + * member and all his children are validated + */ + const memberIsValidated = (): boolean => { + return member.validated_at && member.children.every((child) => child.validated_at); + }; + return ( -
+
{(member.children.length > 0) diff --git a/app/frontend/src/javascript/controllers/admin/members.js b/app/frontend/src/javascript/controllers/admin/members.js index e7b388827..e5593977d 100644 --- a/app/frontend/src/javascript/controllers/admin/members.js +++ b/app/frontend/src/javascript/controllers/admin/members.js @@ -322,7 +322,6 @@ Application.Controllers.controller('AdminMembersController', ['$scope', '$sce', } return c; }); - console.log(member.children); return member; } return member; diff --git a/app/frontend/templates/admin/events/monitoring.html b/app/frontend/templates/admin/events/monitoring.html index 01d8e9285..ed4aa9d61 100644 --- a/app/frontend/templates/admin/events/monitoring.html +++ b/app/frontend/templates/admin/events/monitoring.html @@ -50,10 +50,10 @@ - {{ 'app.admin.events.event_type.standard' }} - {{ 'app.admin.events.event_type.nominative' }} - {{ 'app.admin.events.event_type.family' }} - {{ 'app.admin.events.pre_registration' }} + {{ 'app.admin.events.event_type.standard' }} + {{ 'app.admin.events.event_type.nominative' }} + {{ 'app.admin.events.event_type.family' }} + {{ 'app.admin.events.pre_registration' }} diff --git a/app/frontend/templates/admin/events/reservations.html b/app/frontend/templates/admin/events/reservations.html index 02fc0b260..b2dad5e8d 100644 --- a/app/frontend/templates/admin/events/reservations.html +++ b/app/frontend/templates/admin/events/reservations.html @@ -46,10 +46,10 @@ {{ticket.event_price_category.price_category.name}} : {{ticket.booked}} - {{ 'app.admin.event_reservations.event_status.pre_registered' }} - {{ 'app.admin.event_reservations.event_status.to_pay' }} - {{ 'app.admin.event_reservations.event_status.paid' }} - {{ 'app.admin.event_reservations.event_status.canceled' }} + {{ 'app.admin.event_reservations.event_status.pre_registered' }} + {{ 'app.admin.event_reservations.event_status.to_pay' }} + {{ 'app.admin.event_reservations.event_status.paid' }} + {{ 'app.admin.event_reservations.event_status.canceled' }}