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

add ProofOfIdentityFile max size in frontend

This commit is contained in:
Du Peng 2022-05-11 18:14:52 +02:00
parent 655f75a394
commit 01191f467c
10 changed files with 24 additions and 18 deletions

View File

@ -10,6 +10,9 @@ import { ProofOfIdentityType } from '../../models/proof-of-identity-type';
import { ProofOfIdentityFile } from '../../models/proof-of-identity-file';
import ProofOfIdentityTypeAPI from '../../api/proof-of-identity-type';
import ProofOfIdentityFileAPI from '../../api/proof-of-identity-file';
import { IFablab } from '../../models/fablab';
declare let Fablab: IFablab;
declare const Application: IApplication;
@ -29,6 +32,8 @@ interface FilesType {
const ProofOfIdentityFiles: React.FC<ProofOfIdentityFilesProps> = ({ currentUser, onSuccess, onError }) => {
const { t } = useTranslation('admin');
const maxProofOfIdentityFileSizeMb = (Fablab.maxProofOfIdentityFileSize / 1024 / 1024).toFixed();
// list of proof of identity type
const [proofOfIdentityTypes, setProofOfIdentityTypes] = useState<Array<ProofOfIdentityType>>([]);
const [proofOfIdentityFiles, setProofOfIdentityFiles] = useState<Array<ProofOfIdentityFile>>([]);
@ -64,8 +69,7 @@ const ProofOfIdentityFiles: React.FC<ProofOfIdentityFilesProps> = ({ currentUser
return (event) => {
const fileSize = event.target.files[0].size;
let _errors = errors;
// 5m max
if (fileSize > 5242880) {
if (fileSize > Fablab.maxProofOfIdentityFileSize) {
_errors = errors.concat(poitId);
setErrors(_errors);
} else {
@ -115,7 +119,7 @@ const ProofOfIdentityFiles: React.FC<ProofOfIdentityFilesProps> = ({ currentUser
<h3>{t('app.admin.members_edit.proof_of_identity_files')}</h3>
<p className="text-black font-sbold">{t('app.admin.members_edit.my_documents_info')}</p>
<div className="alert alert-warning">
<HtmlTranslate trKey="app.admin.members_edit.my_documents_alert" />
<HtmlTranslate trKey="app.admin.members_edit.my_documents_alert" options={{ SIZE: maxProofOfIdentityFileSizeMb }}/>
</div>
<div className="widget-content no-bg auto">
{proofOfIdentityTypes.map((poit: ProofOfIdentityType) => {
@ -146,7 +150,7 @@ const ProofOfIdentityFiles: React.FC<ProofOfIdentityFilesProps> = ({ currentUser
required />
</span>
</div>
{errors.includes(poit.id) && <span className="help-block">{t('app.admin.members_edit.proof_of_identity_file_size_error')}</span>}
{errors.includes(poit.id) && <span className="help-block">{t('app.admin.members_edit.proof_of_identity_file_size_error', { SIZE: maxProofOfIdentityFileSizeMb })}</span>}
</div>
);
})}

View File

@ -17,6 +17,7 @@ export interface IFablab {
weekStartingDay: string,
d3DateFormat: string,
uibDateFormat: string,
maxProofOfIdentityFileSize: number,
sessionTours: Array<string>,
translations: {
app: {

View File

@ -63,6 +63,7 @@
Fablab.weekStartingDay = <%= Date.parse(Rails.application.secrets.week_starting_day).strftime('%w') %>;
Fablab.d3DateFormat = "<%= Rails.application.secrets.d3_date_format %>";
Fablab.uibDateFormat = "<%= Rails.application.secrets.uib_date_format %>";
Fablab.maxProofOfIdentityFileSize = <%= Rails.application.secrets.max_proof_of_identity_file_size&.to_i || 5.megabytes.to_i %>;
// feature tour (used when feature_tour_display = session)
Fablab.sessionTours = [];

View File

@ -959,8 +959,8 @@ de:
cannot_extend_own_subscription: "Sie können Ihr eigenes Abonnement nicht erweitern. Bitte fragen Sie einen anderen Manager oder einen Administrator."
my_documents: "My documents"
my_documents_info: "Following the declaration of your profile, you must declare the proof of identity documents. Once submitted, these documents will be verified by the administrator."
proof_of_identity_file_size_error: "The weight limit is 5 MB max"
my_documents_alert: "Attention!</br>You can submit your documents in pdf or in image (jpg) under a weight limit of 5 Mb max"
proof_of_identity_file_size_error: "The weight limit is {SIZE} MB max"
my_documents_alert: "Attention!</br>You can submit your documents in pdf or in image (jpg) under a weight limit of {SIZE} Mb max"
proof_of_identity_files: "Proof of identity"
find_below_the_proof_of_identity_files: "You will find below the proof of identity documents submitted by the member."
save: "Save"

View File

@ -994,8 +994,8 @@ en:
update_success: "Member's profile successfully updated"
my_documents: "My documents"
my_documents_info: "Following the declaration of your profile, you must declare the proof of identity documents. Once submitted, these documents will be verified by the administrator."
proof_of_identity_file_size_error: "The weight limit is 5 MB max"
my_documents_alert: "Attention!</br>You can submit your documents in pdf or in image (jpg) under a weight limit of 5 Mb max"
proof_of_identity_file_size_error: "The weight limit is {SIZE} MB max"
my_documents_alert: "Attention!</br>You can submit your documents in pdf or in image (jpg) under a weight limit of {SIZE} Mb max"
proof_of_identity_files: "Proof of identity"
find_below_the_proof_of_identity_files: "You will find below the proof of identity documents submitted by the member."
save: "Save"

View File

@ -959,8 +959,8 @@ es:
cannot_extend_own_subscription: "You cannot extend your own subscription. Please ask another manager or an administrator to extend your subscription."
my_documents: "My documents"
my_documents_info: "Following the declaration of your profile, you must declare the proof of identity documents. Once submitted, these documents will be verified by the administrator."
proof_of_identity_file_size_error: "The weight limit is 5 MB max"
my_documents_alert: "Attention!</br>You can submit your documents in pdf or in image (jpg) under a weight limit of 5 Mb max"
proof_of_identity_file_size_error: "The weight limit is {SIZE} MB max"
my_documents_alert: "Attention!</br>You can submit your documents in pdf or in image (jpg) under a weight limit of {SIZE} Mb max"
proof_of_identity_files: "Proof of identity"
find_below_the_proof_of_identity_files: "You will find below the proof of identity documents submitted by the member."
save: "Save"

View File

@ -959,8 +959,8 @@ fr:
cannot_extend_own_subscription: "Vous ne pouvez pas prolonger votre propre abonnement. Veuillez demander à un autre gestionnaire ou à un administrateur de prolonger votre abonnement."
my_documents: "Mes documents"
my_documents_info: "Suite à la déclaration de votre profil, vous devez déclarer des justificatifs. Une fois déposé, ces documents vont être vérifiés par l'administrateur."
proof_of_identity_file_size_error: "La limite de poids est 5 Mo max"
my_documents_alert: "Attention ! </br>Vous pouvez déposer vos documents en pdf ou en image(jpg) sous une limite de poids de 5 Mo max"
proof_of_identity_file_size_error: "La limite de poids est {SIZE} Mo max"
my_documents_alert: "Attention ! </br>Vous pouvez déposer vos documents en pdf ou en image(jpg) sous une limite de poids de {SIZE} Mo max"
proof_of_identity_files: "Justificatifs"
find_below_the_proof_of_identity_files: "Retrouvez ci-dessous, les justificatifs déposés par le membre."
save: "Enregistrer"

View File

@ -959,8 +959,8 @@
cannot_extend_own_subscription: "Du kan ikke utvide ditt eget medlemskap. Be en annen leder eller en administrator om å utvide abonnementet."
my_documents: "My documents"
my_documents_info: "Following the declaration of your profile, you must declare the proof of identity documents. Once submitted, these documents will be verified by the administrator."
proof_of_identity_file_size_error: "The weight limit is 5 MB max"
my_documents_alert: "Attention!</br>You can submit your documents in pdf or in image (jpg) under a weight limit of 5 Mb max"
proof_of_identity_file_size_error: "The weight limit is {SIZE} MB max"
my_documents_alert: "Attention!</br>You can submit your documents in pdf or in image (jpg) under a weight limit of {SIZE} Mb max"
proof_of_identity_files: "Proof of identity"
find_below_the_proof_of_identity_files: "You will find below the proof of identity documents submitted by the member."
save: "Save"

View File

@ -959,8 +959,8 @@ pt:
cannot_extend_own_subscription: "Você não pode estender sua própria assinatura. Por favor, peça a outro gerente ou administrador para estender sua assinatura."
my_documents: "My documents"
my_documents_info: "Following the declaration of your profile, you must declare the proof of identity documents. Once submitted, these documents will be verified by the administrator."
proof_of_identity_file_size_error: "The weight limit is 5 MB max"
my_documents_alert: "Attention!</br>You can submit your documents in pdf or in image (jpg) under a weight limit of 5 Mb max"
proof_of_identity_file_size_error: "The weight limit is {SIZE} MB max"
my_documents_alert: "Attention!</br>You can submit your documents in pdf or in image (jpg) under a weight limit of {SIZE} Mb max"
proof_of_identity_files: "Proof of identity"
find_below_the_proof_of_identity_files: "You will find below the proof of identity documents submitted by the member."
save: "Save"

View File

@ -959,8 +959,8 @@ zu:
cannot_extend_own_subscription: "crwdns20346:0crwdne20346:0"
my_documents: "My documents"
my_documents_info: "Following the declaration of your profile, you must declare the proof of identity documents. Once submitted, these documents will be verified by the administrator."
proof_of_identity_file_size_error: "The weight limit is 5 MB max"
my_documents_alert: "Attention!</br>You can submit your documents in pdf or in image (jpg) under a weight limit of 5 Mb max"
proof_of_identity_file_size_error: "The weight limit is {SIZE} MB max"
my_documents_alert: "Attention!</br>You can submit your documents in pdf or in image (jpg) under a weight limit of {SIZE} Mb max"
proof_of_identity_files: "Proof of identity"
find_below_the_proof_of_identity_files: "You will find below the proof of identity documents submitted by the member."
save: "Save"