1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-23 12:52:20 +01:00

(feat) some improvements for family account

This commit is contained in:
Du Peng 2023-06-28 18:23:07 +02:00
parent 9dafc9f221
commit 59fb10753d
13 changed files with 37 additions and 26 deletions

View File

@ -116,6 +116,7 @@ export const ChildForm: React.FC<ChildFormProps> = ({ child, onSubmit, supportin
defaultFile={sf as FileType} defaultFile={sf as FileType}
id={`supporting_document_files_attributes.${index}`} id={`supporting_document_files_attributes.${index}`}
accept="application/pdf" accept="application/pdf"
rules={{ required: true }}
setValue={setValue} setValue={setValue}
label={getSupportingDocumentsTypeName(sf.supporting_document_type_id)} label={getSupportingDocumentsTypeName(sf.supporting_document_type_id)}
showRemoveButton={false} showRemoveButton={false}

View File

@ -28,14 +28,15 @@ export const ChildModal: React.FC<ChildModalProps> = ({ child, isOpen, toggleMod
* Save the child to the API * Save the child to the API
*/ */
const handleSaveChild = async (data: Child): Promise<void> => { const handleSaveChild = async (data: Child): Promise<void> => {
let c: Child = data;
try { try {
if (child?.id) { if (child?.id) {
await ChildAPI.update(data); c = await ChildAPI.update(data);
} else { } else {
await ChildAPI.create(data); c = await ChildAPI.create(data);
} }
toggleModal(); toggleModal();
onSuccess(data, ''); onSuccess(c, '');
} catch (error) { } catch (error) {
onError(error); onError(error);
} }
@ -56,7 +57,7 @@ export const ChildModal: React.FC<ChildModalProps> = ({ child, isOpen, toggleMod
onSubmit={handleSaveChild} onSubmit={handleSaveChild}
supportingDocumentsTypes={supportingDocumentsTypes} supportingDocumentsTypes={supportingDocumentsTypes}
operator={operator} operator={operator}
onSuccess={onSuccess} onSuccess={(msg) => onSuccess(child, msg)}
onError={onError} onError={onError}
/> />
</FabModal> </FabModal>

View File

@ -9,7 +9,7 @@ import { TDateISO } from '../../typings/date-iso';
interface ChildValidationProps { interface ChildValidationProps {
child: Child child: Child
onSuccess: (message: string) => void, onSuccess: (child: Child, msg: string) => void;
onError: (message: string) => void, onError: (message: string) => void,
} }
@ -37,8 +37,8 @@ export const ChildValidation: React.FC<ChildValidationProps> = ({ child, onSucce
_child.validated_at = null; _child.validated_at = null;
} }
ChildAPI.validate(_child) ChildAPI.validate(_child)
.then(() => { .then((c) => {
onSuccess(t(`app.admin.child_validation.${_value ? 'validate' : 'invalidate'}_child_success`)); onSuccess(c, t(`app.admin.child_validation.${_value ? 'validate' : 'invalidate'}_child_success`));
}).catch(err => { }).catch(err => {
setValue(!_value); setValue(!_value);
onError(t(`app.admin.child_validation.${_value ? 'validate' : 'invalidate'}_child_error`) + err); onError(t(`app.admin.child_validation.${_value ? 'validate' : 'invalidate'}_child_error`) + err);

View File

@ -30,8 +30,15 @@ export const MembersListItem: React.FC<MembersListItemProps> = ({ member, onErro
window.location.href = `/#!/admin/members/${memberId}/edit`; 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 ( return (
<div key={member.id} className={`members-list-item ${member.validated_at ? 'is-validated' : ''} ${member.need_completion ? 'is-incomplet' : ''}`}> <div key={member.id} className={`members-list-item ${memberIsValidated() ? 'is-validated' : ''} ${member.need_completion ? 'is-incomplet' : ''}`}>
<div className="left-col"> <div className="left-col">
<div className='status'> <div className='status'>
{(member.children.length > 0) {(member.children.length > 0)

View File

@ -322,7 +322,6 @@ Application.Controllers.controller('AdminMembersController', ['$scope', '$sce',
} }
return c; return c;
}); });
console.log(member.children);
return member; return member;
} }
return member; return member;

View File

@ -50,10 +50,10 @@
</td> </td>
<td> <td>
<span ng-if="event.event_type === 'standard'" class="v-middle badge text-base bg-stage" translate="">{{ 'app.admin.events.event_type.standard' }}</span> <span ng-if="event.event_type === 'standard'" class="v-middle badge text-sm bg-stage" translate="">{{ 'app.admin.events.event_type.standard' }}</span>
<span ng-if="event.event_type === 'nominative'" class="v-middle badge text-base bg-event" translate="">{{ 'app.admin.events.event_type.nominative' }}</span> <span ng-if="event.event_type === 'nominative'" class="v-middle badge text-sm bg-event" translate="">{{ 'app.admin.events.event_type.nominative' }}</span>
<span ng-if="event.event_type === 'family'" class="v-middle badge text-base bg-atelier" translate="">{{ 'app.admin.events.event_type.family' }}</span> <span ng-if="event.event_type === 'family'" class="v-middle badge text-sm bg-atelier" translate="">{{ 'app.admin.events.event_type.family' }}</span>
<span ng-if="event.pre_registration" class="v-middle badge text-base bg-info" translate="">{{ 'app.admin.events.pre_registration' }}</span> <span ng-if="event.pre_registration" class="v-middle badge text-sm bg-info" translate="">{{ 'app.admin.events.pre_registration' }}</span>
</td> </td>
<td style="vertical-align:middle"> <td style="vertical-align:middle">

View File

@ -46,10 +46,10 @@
<span ng-repeat="ticket in reservation.tickets_attributes">{{ticket.event_price_category.price_category.name}} : {{ticket.booked}}</span> <span ng-repeat="ticket in reservation.tickets_attributes">{{ticket.event_price_category.price_category.name}} : {{ticket.booked}}</span>
</td> </td>
<td ng-if="event.pre_registration"> <td ng-if="event.pre_registration">
<span ng-if="!isValidated(reservation) && !isCancelled(reservation) && !reservation.is_paid" class="v-middle badge text-base bg-info" translate="">{{ 'app.admin.event_reservations.event_status.pre_registered' }}</span> <span ng-if="!isValidated(reservation) && !isCancelled(reservation) && !reservation.is_paid" class="v-middle badge text-sm bg-info" translate="">{{ 'app.admin.event_reservations.event_status.pre_registered' }}</span>
<span ng-if="isValidated(reservation) && !isCancelled(reservation) && !reservation.is_paid" class="v-middle badge text-base bg-stage" translate="">{{ 'app.admin.event_reservations.event_status.to_pay' }}</span> <span ng-if="isValidated(reservation) && !isCancelled(reservation) && !reservation.is_paid" class="v-middle badge text-sm bg-stage" translate="">{{ 'app.admin.event_reservations.event_status.to_pay' }}</span>
<span ng-if="reservation.is_paid && !isCancelled(reservation)" class="v-middle badge text-base bg-success" translate="">{{ 'app.admin.event_reservations.event_status.paid' }}</span> <span ng-if="reservation.is_paid && !isCancelled(reservation)" class="v-middle badge text-sm bg-success" translate="">{{ 'app.admin.event_reservations.event_status.paid' }}</span>
<span ng-if="isCancelled(reservation)" class="v-middle badge text-base bg-event" translate="">{{ 'app.admin.event_reservations.event_status.canceled' }}</span> <span ng-if="isCancelled(reservation)" class="v-middle badge text-sm bg-event" translate="">{{ 'app.admin.event_reservations.event_status.canceled' }}</span>
</td> </td>
<td ng-if="event.pre_registration"> <td ng-if="event.pre_registration">
<button class="btn btn-default" ng-click="validateReservation(reservation)" ng-if="!isValidated(reservation) && !isCancelled(reservation) && !reservation.is_paid" translate> <button class="btn btn-default" ng-click="validateReservation(reservation)" ng-if="!isValidated(reservation) && !isCancelled(reservation) && !reservation.is_paid" translate>

View File

@ -73,9 +73,9 @@
<div class="panel-content wrapper"> <div class="panel-content wrapper">
<div> <div>
<span ng-if="event.event_type === 'nominative'" class="v-middle badge text-base bg-event" translate="">{{ 'app.public.events_show.event_type.nominative' }}</span> <span ng-if="event.event_type === 'nominative'" class="v-middle badge text-xs bg-event" translate="">{{ 'app.public.events_show.event_type.nominative' }}</span>
<span ng-if="event.event_type === 'family'" class="v-middle badge text-base bg-event" translate="">{{ 'app.public.events_show.event_type.family' }}</span> <span ng-if="event.event_type === 'family'" class="v-middle badge text-xs bg-event" translate="">{{ 'app.public.events_show.event_type.family' }}</span>
<span ng-if="event.pre_registration" class="v-middle badge text-base bg-info" translate="">{{ 'app.public.events_show.pre_registration' }}</span> <span ng-if="event.pre_registration" class="v-middle badge text-xs bg-info" translate="">{{ 'app.public.events_show.pre_registration' }}</span>
</div> </div>
<dl class="text-sm"> <dl class="text-sm">

View File

@ -1824,8 +1824,9 @@ en:
public_registrations: "Public registrations" public_registrations: "Public registrations"
show_username_in_admin_list: "Show the username in the list" show_username_in_admin_list: "Show the username in the list"
family_account: "family account" family_account: "family account"
family_account_info_html: "By activating this option, you offer your members the possibility to add their child(ren) to their own account. You can also request proof if you wish to validate them." family_account_info_html: "The Family account allows your members to add their children under 18 years old to their own account and directly register them for Family events. You can also request supporting documents for each child and validate their account."
enable_family_account: "Enable the Family Account option" enable_family_account: "Enable the Family Account option"
child_validation_required: "the account validation option for children"
child_validation_required_label: "Activate the account validation option for children" child_validation_required_label: "Activate the account validation option for children"
overlapping_options: overlapping_options:
training_reservations: "Trainings" training_reservations: "Trainings"

View File

@ -1816,8 +1816,9 @@ fr:
public_registrations: "Inscriptions publiques" public_registrations: "Inscriptions publiques"
show_username_in_admin_list: "Afficher le nom d'utilisateur dans la liste" show_username_in_admin_list: "Afficher le nom d'utilisateur dans la liste"
family_account: "Compte famille" family_account: "Compte famille"
family_account_info_html: "En activant cette option, vous offrez à vos membres la possibilité d'ajouter sur leur propre compte leur(s) enfants. Vous pouvez aussi demander un justificatif si vous souhaitez les valider." family_account_info_html: "Le compte Famille permet à vos membres d'ajouter leurs enfants de moins de 18 ans sur leur propre compte et de les inscrire directement aux évènements de type Famille. Vous pouvez aussi demander des justificatifs pour chaque enfant et valider leur compte."
enable_family_account: "Activer l'option Compte Famille" enable_family_account: "Activer l'option Compte Famille"
child_validation_required: "l'option de validation des comptes enfants"
child_validation_required_label: "Activer l'option de validation des comptes enfants" child_validation_required_label: "Activer l'option de validation des comptes enfants"
overlapping_options: overlapping_options:
training_reservations: "Formations" training_reservations: "Formations"

View File

@ -494,7 +494,7 @@ en:
edit_child: "Edit child" edit_child: "Edit child"
new_child: "New child" new_child: "New child"
child_form: child_form:
child_form_info: "Please note that you can only add a child under the age of 18. Supporting documents are requested by your administrator, they will be useful to validate your child's account and authorize the reservation of events." child_form_info: "Only children under 18 years old can be added to your Family account. Supporting documents may be requested to validate your child's account and allow you to register them for events."
first_name: "First name" first_name: "First name"
last_name: "Last name" last_name: "Last name"
birthday: "Birthday" birthday: "Birthday"

View File

@ -487,13 +487,14 @@ fr:
select_a_member: "Sélectionnez un membre" select_a_member: "Sélectionnez un membre"
start_typing: "Commencez à écrire..." start_typing: "Commencez à écrire..."
children_dashboard: children_dashboard:
heading: "Mes enfants" heading: "Enfants"
member_heading: "Mes enfants"
add_child: "Ajouter un enfant" add_child: "Ajouter un enfant"
child_modal: child_modal:
edit_child: "Modifier un enfant" edit_child: "Modifier un enfant"
new_child: "Ajouter un enfant" new_child: "Ajouter un enfant"
child_form: child_form:
child_form_info: "Notez que vous ne pouvez ajouter que vos enfants de moins de 18 ans. Des pièces justificatives sont demandés par votre administrateur, elles lui seront utiles pour valider le compte de votre enfant et ainsi autoriser la réservation d'événements." child_form_info: "Seuls les enfants de moins de 18 ans peuvent être ajoutés au sein de votre compte Famille. Des justificatifs peuvent être demandés afin de valider le compte de votre enfant et de vous permettre ensuite de l'inscrire à des évènements."
first_name: "Prénom" first_name: "Prénom"
last_name: "Nom" last_name: "Nom"
birthday: "Date de naissance" birthday: "Date de naissance"

View File

@ -317,7 +317,7 @@ fr:
notify_admin_when_user_is_created: notify_admin_when_user_is_created:
a_new_user_account_has_been_created_NAME_EMAIL_html: "Un nouveau compte utilisateur vient d'être créé : <strong><em>%{NAME} &lt;%{EMAIL}&gt;</strong></em>." a_new_user_account_has_been_created_NAME_EMAIL_html: "Un nouveau compte utilisateur vient d'être créé : <strong><em>%{NAME} &lt;%{EMAIL}&gt;</strong></em>."
notify_admin_child_created: notify_admin_child_created:
a_new_child_has_been_created_NAME_html: "Un nouveau enfant vient d'être créé : <strong><em>%{NAME}</em></strong>." a_new_child_has_been_created_NAME_html: "Un nouvel enfant vient d'être créé : <strong><em>%{NAME}</em></strong>."
notify_admin_when_user_is_imported: notify_admin_when_user_is_imported:
a_new_user_account_has_been_imported_from_PROVIDER_UID_html: "Un nouveau compte utilisateur vient d'être importé depuis : <strong><em>%{PROVIDER}</strong> (%{UID})</em>." a_new_user_account_has_been_imported_from_PROVIDER_UID_html: "Un nouveau compte utilisateur vient d'être importé depuis : <strong><em>%{PROVIDER}</strong> (%{UID})</em>."
notify_member_create_reservation: notify_member_create_reservation: