mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-18 07:52:23 +01:00
(quality) rename proof-of-identity to supporting-documents in notifications
This commit is contained in:
parent
63e9e6b12a
commit
979042078d
@ -4,8 +4,8 @@ import { NotificationTypeIndexFilter, NotificationType } from '../models/notific
|
||||
import ApiLib from '../lib/api';
|
||||
|
||||
export default class NotificationTypesAPI {
|
||||
static async index (isConfigurable?:NotificationTypeIndexFilter): Promise<Array<NotificationType>> {
|
||||
const res: AxiosResponse<Array<NotificationType>> = await apiClient.get(`/api/notification_types${ApiLib.filtersToQuery(isConfigurable)}`);
|
||||
static async index (filters?:NotificationTypeIndexFilter): Promise<Array<NotificationType>> {
|
||||
const res: AxiosResponse<Array<NotificationType>> = await apiClient.get(`/api/notification_types${ApiLib.filtersToQuery(filters)}`);
|
||||
return res?.data;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
import { Loader } from '../base/loader';
|
||||
import { useEffect, useState } from 'react';
|
||||
import NotificationPreferencesAPI from '../../api/notification_preference';
|
||||
import { NotificationPreference, NotificationCategoryNames, NotificationPreferencesByCategories } from '../../models/notification-preference';
|
||||
import { NotificationPreference, NotificationPreferencesByCategories } from '../../models/notification-preference';
|
||||
import { NotificationCategoryNames } from '../../models/notification-type';
|
||||
import { NotificationsCategory } from './notifications-category';
|
||||
import NotificationTypesAPI from '../../api/notification_types';
|
||||
|
||||
@ -28,7 +29,7 @@ const NotificationsSettings: React.FC<NotificationsSettingsProps> = ({ onError }
|
||||
|
||||
NotificationTypesAPI.index({ is_configurable: true })
|
||||
.then(notificationTypes => {
|
||||
// Initialize an object with every categories as keys
|
||||
// Initialize an object with every category as keys
|
||||
const newPreferencesByCategories: NotificationPreferencesByCategories = {};
|
||||
for (const categoryName of NotificationCategoryNames) {
|
||||
newPreferencesByCategories[categoryName] = [];
|
||||
|
@ -1,25 +1,10 @@
|
||||
import { NotificationTypeName, NotificationCategoryName } from './notification-type';
|
||||
|
||||
export interface NotificationPreference {
|
||||
id: number,
|
||||
notification_type: string,
|
||||
notification_type: NotificationTypeName,
|
||||
email: boolean,
|
||||
in_system: boolean
|
||||
}
|
||||
|
||||
// This controls the order of the categories' display in the notification center
|
||||
export const NotificationCategoryNames = [
|
||||
'users_accounts',
|
||||
'proof_of_identity',
|
||||
'agenda',
|
||||
'subscriptions',
|
||||
'payments',
|
||||
'wallet',
|
||||
'shop',
|
||||
'projects',
|
||||
'accountings',
|
||||
'trainings',
|
||||
'app_management'
|
||||
] as const;
|
||||
|
||||
export type NotificationCategoryName = typeof NotificationCategoryNames[number];
|
||||
|
||||
export type NotificationPreferencesByCategories = Record<NotificationCategoryName, Array<NotificationPreference>> | Record<never, never>
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { ApiFilter } from '../models/api';
|
||||
import { ApiFilter } from './api';
|
||||
|
||||
export interface NotificationType {
|
||||
id: number,
|
||||
name: typeof notificationTypeNames[number],
|
||||
category: string,
|
||||
name: NotificationTypeName,
|
||||
category: NotificationCategoryName,
|
||||
is_configurable: boolean
|
||||
}
|
||||
|
||||
@ -69,15 +69,34 @@ export const notificationTypeNames = [
|
||||
'notify_member_payment_schedule_error',
|
||||
'notify_admin_payment_schedule_gateway_canceled',
|
||||
'notify_member_payment_schedule_gateway_canceled',
|
||||
'notify_admin_user_proof_of_identity_files_created',
|
||||
'notify_admin_user_proof_of_identity_files_updated',
|
||||
'notify_admin_user_supporting_document_files_created',
|
||||
'notify_admin_user_supporting_document_files_updated',
|
||||
'notify_user_is_validated',
|
||||
'notify_user_is_invalidated',
|
||||
'notify_user_proof_of_identity_refusal',
|
||||
'notify_admin_user_proof_of_identity_refusal',
|
||||
'notify_admin_user_supporting_document_refusal',
|
||||
'notify_user_order_is_ready',
|
||||
'notify_user_order_is_canceled',
|
||||
'notify_user_order_is_refunded',
|
||||
'notify_admin_low_stock_threshold',
|
||||
'notify_admin_training_auto_cancelled'
|
||||
] as const;
|
||||
|
||||
export type NotificationTypeName = typeof notificationTypeNames[number];
|
||||
|
||||
// This controls the order of the categories' display in the notification center
|
||||
export const NotificationCategoryNames = [
|
||||
'users_accounts',
|
||||
'supporting_documents',
|
||||
'agenda',
|
||||
'subscriptions',
|
||||
'payments',
|
||||
'wallet',
|
||||
'shop',
|
||||
'projects',
|
||||
'accountings',
|
||||
'trainings',
|
||||
'app_management'
|
||||
] as const;
|
||||
|
||||
export type NotificationCategoryName = typeof NotificationCategoryNames[number];
|
||||
|
@ -12,6 +12,7 @@ class NotificationType < ApplicationRecord
|
||||
has_many :notification_preferences, dependent: :destroy
|
||||
|
||||
validates :name, uniqueness: true, presence: true
|
||||
validates :category, presence: true
|
||||
validates :category, presence: true, inclusion: { in: %w[subscriptions user projects deprecated exports agenda trainings accountings
|
||||
app_management wallet payments users_accounts supporting_documents shop] }
|
||||
validates :is_configurable, inclusion: { in: [true, false] }
|
||||
end
|
||||
|
@ -4,10 +4,8 @@
|
||||
class ProofOfIdentityFileService
|
||||
def self.list(operator, filters = {})
|
||||
files = []
|
||||
if filters[:user_id].present?
|
||||
if operator.privileged? || filters[:user_id].to_i == operator.id
|
||||
files = ProofOfIdentityFile.where(user_id: filters[:user_id])
|
||||
end
|
||||
if filters[:user_id].present? && (operator.privileged? || filters[:user_id].to_i == operator.id)
|
||||
files = ProofOfIdentityFile.where(user_id: filters[:user_id])
|
||||
end
|
||||
files
|
||||
end
|
||||
@ -20,12 +18,10 @@ class ProofOfIdentityFileService
|
||||
all_files_are_upload = true
|
||||
user.group.proof_of_identity_types.each do |type|
|
||||
file = type.proof_of_identity_files.find_by(user_id: proof_of_identity_file.user_id)
|
||||
unless file
|
||||
all_files_are_upload = false
|
||||
end
|
||||
all_files_are_upload = false unless file
|
||||
end
|
||||
if all_files_are_upload
|
||||
NotificationCenter.call type: 'notify_admin_user_proof_of_identity_files_created',
|
||||
NotificationCenter.call type: 'notify_admin_user_supporting_document_files_created',
|
||||
receiver: User.admins_and_managers,
|
||||
attached_object: user
|
||||
end
|
||||
@ -40,12 +36,10 @@ class ProofOfIdentityFileService
|
||||
all_files_are_upload = true
|
||||
user.group.proof_of_identity_types.each do |type|
|
||||
file = type.proof_of_identity_files.find_by(user_id: proof_of_identity_file.user_id)
|
||||
unless file
|
||||
all_files_are_upload = false
|
||||
end
|
||||
all_files_are_upload = false unless file
|
||||
end
|
||||
if all_files_are_upload && !user.validated_at?
|
||||
NotificationCenter.call type: 'notify_admin_user_proof_of_identity_files_updated',
|
||||
NotificationCenter.call type: 'notify_admin_user_supporting_document_files_updated',
|
||||
receiver: User.admins_and_managers,
|
||||
attached_object: proof_of_identity_file
|
||||
end
|
||||
|
@ -4,9 +4,7 @@
|
||||
class ProofOfIdentityRefusalService
|
||||
def self.list(filters = {})
|
||||
refusals = []
|
||||
if filters[:user_id].present?
|
||||
files = ProofOfIdentityRefusal.where(user_id: filters[:user_id])
|
||||
end
|
||||
refusals = ProofOfIdentityRefusal.where(user_id: filters[:user_id]) if filters[:user_id].present?
|
||||
refusals
|
||||
end
|
||||
|
||||
@ -14,7 +12,7 @@ class ProofOfIdentityRefusalService
|
||||
saved = proof_of_identity_refusal.save
|
||||
|
||||
if saved
|
||||
NotificationCenter.call type: 'notify_admin_user_proof_of_identity_refusal',
|
||||
NotificationCenter.call type: 'notify_admin_user_supporting_document_refusal',
|
||||
receiver: User.admins_and_managers,
|
||||
attached_object: proof_of_identity_refusal
|
||||
NotificationCenter.call type: 'notify_user_proof_of_identity_refusal',
|
||||
|
@ -1,3 +1,3 @@
|
||||
json.title notification.notification_type
|
||||
json.description t('.proof_of_identity_files_uploaded',
|
||||
json.description t('.supporting_document_files_uploaded',
|
||||
NAME: notification.attached_object&.profile&.full_name || t('api.notifications.deleted_user'))
|
@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
json.title notification.notification_type
|
||||
json.description t('.proof_of_identity_files_uploaded',
|
||||
json.description t('.supporting_document_files_uploaded',
|
||||
NAME: notification.attached_object&.user&.profile&.full_name || t('api.notifications.deleted_user'))
|
@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
json.title notification.notification_type
|
||||
json.description t('.refusal',
|
||||
NAME: notification.attached_object&.user&.profile&.full_name || t('api.notifications.deleted_user'))
|
@ -1,7 +1,7 @@
|
||||
<%= render 'notifications_mailer/shared/hello', recipient: @recipient %>
|
||||
|
||||
<p>
|
||||
<%= t('.body.proof_of_identity_files_uploaded_below',
|
||||
<%= t('.body.supporting_document_files_uploaded_below',
|
||||
NAME: @attached_object&.profile&.full_name || t('api.notifications.deleted_user')) %>
|
||||
</p>
|
||||
<ul>
|
@ -1,7 +1,7 @@
|
||||
<%= render 'notifications_mailer/shared/hello', recipient: @recipient %>
|
||||
|
||||
<p>
|
||||
<%= t('.body.user_update_proof_of_identity_file',
|
||||
<%= t('.body.user_update_supporting_document_file',
|
||||
NAME: @attached_object&.user&.profile&.full_name || t('api.notifications.deleted_user')) %>
|
||||
</p>
|
||||
<ul>
|
@ -1,7 +1,7 @@
|
||||
<%= render 'notifications_mailer/shared/hello', recipient: @recipient %>
|
||||
|
||||
<p>
|
||||
<%= t('.body.user_proof_of_identity_files_refusal',
|
||||
<%= t('.body.user_supporting_document_files_refusal',
|
||||
NAME: @attached_object&.user&.profile&.full_name || t('api.notifications.deleted_user'),
|
||||
OPERATOR: @attached_object&.operator&.profile&.full_name || t('api.notifications.deleted_user')) %>
|
||||
</p>
|
@ -270,7 +270,7 @@ en:
|
||||
disable_all: "Disable all"
|
||||
notify_me_when: "I wish to be notified when"
|
||||
users_accounts: "Concerning users notifications"
|
||||
proof_of_identity: "Concerning identity proofs notifications"
|
||||
supporting_documents: "Concerning supporting documents notifications"
|
||||
agenda: "Concerning agenda notifications"
|
||||
subscriptions: "Concerning subscriptions notifications"
|
||||
payments: "Concerning payment schedules notifications"
|
||||
@ -288,9 +288,9 @@ en:
|
||||
notify_admins_role_update: "The role of a user has changed"
|
||||
notify_admin_import_complete: "An import is done"
|
||||
notify_admin_user_group_changed: "A group has changed"
|
||||
notify_admin_user_proof_of_identity_refusal: "A proof of identity has been rejected"
|
||||
notify_admin_user_proof_of_identity_files_created: "A user has uploaded a proof of identity"
|
||||
notify_admin_user_proof_of_identity_files_updated: "A user has updated a proof of identity"
|
||||
notify_admin_user_supporting_document_refusal: "A supporting document has been rejected"
|
||||
notify_admin_user_supporting_document_files_created: "A user has uploaded a supporting document"
|
||||
notify_admin_user_supporting_document_files_updated: "A user has updated a supporting document"
|
||||
notify_admin_member_create_reservation: "A member creates a reservation"
|
||||
notify_admin_slot_is_modified: "A reservation slot has been modified"
|
||||
notify_admin_slot_is_canceled: "A reservation has been cancelled"
|
||||
|
@ -432,18 +432,18 @@ en:
|
||||
schedule_deadline: "You must cash the check for the %{DATE} deadline, for schedule %{REFERENCE}"
|
||||
notify_admin_payment_schedule_transfer_deadline:
|
||||
schedule_deadline: "You must confirm the bank direct debit for the %{DATE} deadline, for schedule %{REFERENCE}"
|
||||
notify_admin_user_proof_of_identity_files_created:
|
||||
proof_of_identity_files_uploaded: "Proof of identity uploaded by member <strong><em>%{NAME}</strong></em>."
|
||||
notify_admin_user_proof_of_identity_files_updated:
|
||||
proof_of_identity_files_uploaded: "Proof of identity changed by Member <strong><em>%{NAME}</strong></em>."
|
||||
notify_admin_user_supporting_document_files_created:
|
||||
supporting_document_files_uploaded: "Supporting document uploaded by member <strong><em>%{NAME}</strong></em>."
|
||||
notify_admin_user_supporting_document_files_updated:
|
||||
supporting_document_files_uploaded: "Supporting document changed by member <strong><em>%{NAME}</strong></em>."
|
||||
notify_user_is_validated:
|
||||
account_validated: "Your account is valid."
|
||||
notify_user_is_invalidated:
|
||||
account_invalidated: "Your account is invalid."
|
||||
notify_user_proof_of_identity_refusal:
|
||||
refusal: "Your proof of identity are not accepted"
|
||||
notify_admin_user_proof_of_identity_refusal:
|
||||
refusal: "Member's proof of identity <strong><em>%{NAME}</strong></em> refused."
|
||||
notify_admin_user_supporting_document_refusal:
|
||||
refusal: "Member's supporting document <strong><em>%{NAME}</strong></em> was refused."
|
||||
notify_user_order_is_ready:
|
||||
order_ready: "Your command %{REFERENCE} is ready"
|
||||
notify_user_order_is_canceled:
|
||||
|
@ -370,15 +370,15 @@ en:
|
||||
remember: "In accordance with your %{REFERENCE} payment schedule, %{AMOUNT} was due to be debited on %{DATE}."
|
||||
date: "This is a reminder to verify that the direct bank debit was successfull."
|
||||
confirm: "Please confirm the receipt of funds in your payment schedule management interface, so that the corresponding invoice will be generated."
|
||||
notify_admin_user_proof_of_identity_files_created:
|
||||
notify_admin_user_supporting_document_files_created:
|
||||
subject: "Supporting documents uploaded by a member"
|
||||
body:
|
||||
proof_of_identity_files_uploaded_below: "Member %{NAME} has uploaded the following supporting documents:"
|
||||
supporting_document_files_uploaded_below: "Member %{NAME} has uploaded the following supporting documents:"
|
||||
validate_user: "Please validate this account"
|
||||
notify_admin_user_proof_of_identity_files_updated:
|
||||
notify_admin_user_supporting_document_files_updated:
|
||||
subject: "Member's supporting documents have changed"
|
||||
body:
|
||||
user_update_proof_of_identity_file: "Member %{NAME} has modified the supporting documents below:"
|
||||
user_update_supporting_document_file: "Member %{NAME} has modified the supporting documents below:"
|
||||
validate_user: "Please validate this account"
|
||||
notify_user_is_validated:
|
||||
subject: "Account validated"
|
||||
@ -393,10 +393,10 @@ en:
|
||||
body:
|
||||
user_proof_of_identity_files_refusal: "Your supporting documents were refused:"
|
||||
action: "Please re-upload some new supporting documents."
|
||||
notify_admin_user_proof_of_identity_refusal:
|
||||
notify_admin_user_supporting_document_refusal:
|
||||
subject: "A member's supporting documents were refused"
|
||||
body:
|
||||
user_proof_of_identity_files_refusal: "Member %{NAME}'s supporting documents were rejected by %{OPERATOR}:"
|
||||
user_supporting_document_files_refusal: "Member %{NAME}'s supporting documents were rejected by %{OPERATOR}:"
|
||||
shared:
|
||||
hello: "Hello %{user_name}"
|
||||
notify_user_order_is_ready:
|
||||
|
@ -70,19 +70,19 @@ class CreateNotificationTypes < ActiveRecord::Migration[5.2]
|
||||
{ id: 55, name: 'notify_member_payment_schedule_error', category: 'payments', is_configurable: false },
|
||||
{ id: 56, name: 'notify_admin_payment_schedule_gateway_canceled', category: 'payments', is_configurable: true },
|
||||
{ id: 57, name: 'notify_member_payment_schedule_gateway_canceled', category: 'payments', is_configurable: false },
|
||||
{ id: 58, name: 'notify_admin_user_proof_of_identity_files_created', category: 'proof_of_identity', is_configurable: true },
|
||||
{ id: 59, name: 'notify_admin_user_proof_of_identity_files_updated', category: 'proof_of_identity', is_configurable: true },
|
||||
{ id: 58, name: 'notify_admin_user_supporting_document_files_created', category: 'supporting_documents', is_configurable: true },
|
||||
{ id: 59, name: 'notify_admin_user_supporting_document_files_updated', category: 'supporting_documents', is_configurable: true },
|
||||
|
||||
{ id: 60, name: 'notify_user_is_validated', category: 'users_accounts', is_configurable: false },
|
||||
{ id: 61, name: 'notify_user_is_invalidated', category: 'users_accounts', is_configurable: false },
|
||||
{ id: 62, name: 'notify_user_proof_of_identity_refusal', category: 'proof_of_identity', is_configurable: false },
|
||||
{ id: 63, name: 'notify_admin_user_proof_of_identity_refusal', category: 'proof_of_identity', is_configurable: true },
|
||||
{ id: 62, name: 'notify_user_proof_of_identity_refusal', category: 'supporting_documents', is_configurable: false },
|
||||
{ id: 63, name: 'notify_admin_user_supporting_document_refusal', category: 'supporting_documents', is_configurable: true },
|
||||
{ id: 64, name: 'notify_user_order_is_ready', category: 'shop', is_configurable: true },
|
||||
{ id: 65, name: 'notify_user_order_is_canceled', category: 'shop', is_configurable: true },
|
||||
{ id: 66, name: 'notify_user_order_is_refunded', category: 'shop', is_configurable: true },
|
||||
{ id: 67, name: 'notify_admin_low_stock_threshold', category: 'shop', is_configurable: true },
|
||||
{ id: 68, name: 'notify_admin_training_auto_cancelled', category: 'trainings', is_configurable: true },
|
||||
{ id: 69, name: 'notify_member_training_auto_cancelled', category: 'trainings', is_configurable: true }
|
||||
{ id: 69, name: 'notify_member_training_auto_cancelled', category: 'trainings', is_configurable: false }
|
||||
].freeze
|
||||
|
||||
def up
|
||||
|
17
db/seeds/notification_types.rb
Normal file
17
db/seeds/notification_types.rb
Normal file
@ -0,0 +1,17 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
unless NotificationType.find_by(name: 'notify_member_training_authorization_expired')
|
||||
NotificationType.create!(
|
||||
name: 'notify_member_training_authorization_expired',
|
||||
category: 'trainings',
|
||||
is_configurable: false
|
||||
)
|
||||
end
|
||||
|
||||
unless NotificationType.find_by(name: 'notify_member_training_invalidated')
|
||||
NotificationType.create!(
|
||||
name: 'notify_member_training_invalidated',
|
||||
category: 'trainings',
|
||||
is_configurable: false
|
||||
)
|
||||
end
|
14
test/fixtures/notification_types.yml
vendored
14
test/fixtures/notification_types.yml
vendored
@ -456,16 +456,16 @@ notification_type_57:
|
||||
|
||||
notification_type_58:
|
||||
id: 58
|
||||
name: notify_admin_user_proof_of_identity_files_created
|
||||
category: proof_of_identity
|
||||
name: notify_admin_user_supporting_document_files_created
|
||||
category: supporting_documents
|
||||
is_configurable: true
|
||||
created_at: 2023-02-02 08:25:33.435886000 Z
|
||||
updated_at: 2023-02-02 08:25:33.435886000 Z
|
||||
|
||||
notification_type_59:
|
||||
id: 59
|
||||
name: notify_admin_user_proof_of_identity_files_updated
|
||||
category: proof_of_identity
|
||||
name: notify_admin_user_supporting_document_files_updated
|
||||
category: supporting_documents
|
||||
is_configurable: true
|
||||
created_at: 2023-02-02 08:25:33.436627000 Z
|
||||
updated_at: 2023-02-02 08:25:33.436627000 Z
|
||||
@ -489,15 +489,15 @@ notification_type_61:
|
||||
notification_type_62:
|
||||
id: 62
|
||||
name: notify_user_proof_of_identity_refusal
|
||||
category: proof_of_identity
|
||||
category: supporting_documents
|
||||
is_configurable: false
|
||||
created_at: 2023-02-02 08:25:33.439078000 Z
|
||||
updated_at: 2023-02-02 08:25:33.439078000 Z
|
||||
|
||||
notification_type_63:
|
||||
id: 63
|
||||
name: notify_admin_user_proof_of_identity_refusal
|
||||
category: proof_of_identity
|
||||
name: notify_admin_user_supporting_document_refusal
|
||||
category: supporting_documents
|
||||
is_configurable: true
|
||||
created_at: 2023-02-02 08:25:33.439926000 Z
|
||||
updated_at: 2023-02-02 08:25:33.439926000 Z
|
||||
|
Loading…
x
Reference in New Issue
Block a user