mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-30 19:52:20 +01:00
(ui) Add label for user profil form gender field
This commit is contained in:
parent
940ee06e58
commit
abc5fa6691
@ -7,12 +7,13 @@ import { useTranslation } from 'react-i18next';
|
|||||||
interface GenderInputProps<TFieldValues> {
|
interface GenderInputProps<TFieldValues> {
|
||||||
register: UseFormRegister<TFieldValues>,
|
register: UseFormRegister<TFieldValues>,
|
||||||
disabled?: boolean|((id: string) => boolean),
|
disabled?: boolean|((id: string) => boolean),
|
||||||
|
required?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Input component to set the gender for the user
|
* Input component to set the gender for the user
|
||||||
*/
|
*/
|
||||||
export const GenderInput = <TFieldValues extends FieldValues>({ register, disabled = false }: GenderInputProps<TFieldValues>) => {
|
export const GenderInput = <TFieldValues extends FieldValues>({ register, disabled = false, required }: GenderInputProps<TFieldValues>) => {
|
||||||
const { t } = useTranslation('shared');
|
const { t } = useTranslation('shared');
|
||||||
|
|
||||||
const [isDisabled, setIsDisabled] = useState<boolean>(false);
|
const [isDisabled, setIsDisabled] = useState<boolean>(false);
|
||||||
@ -26,21 +27,25 @@ export const GenderInput = <TFieldValues extends FieldValues>({ register, disabl
|
|||||||
}, [disabled]);
|
}, [disabled]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="gender-input">
|
<fieldset className="gender-input">
|
||||||
|
<legend className={required ? 'is-required' : ''}>{t('app.shared.gender_input.label')}</legend>
|
||||||
<label>
|
<label>
|
||||||
<p>{t('app.shared.gender_input.man')}</p>
|
<p>{t('app.shared.gender_input.man')}</p>
|
||||||
<input type="radio"
|
<input type="radio"
|
||||||
|
name='gender'
|
||||||
value="true"
|
value="true"
|
||||||
|
required={required}
|
||||||
disabled={isDisabled}
|
disabled={isDisabled}
|
||||||
{...register('statistic_profile_attributes.gender' as FieldPath<TFieldValues>)} />
|
{...register('statistic_profile_attributes.gender' as FieldPath<TFieldValues>)} />
|
||||||
</label>
|
</label>
|
||||||
<label>
|
<label>
|
||||||
<p>{t('app.shared.gender_input.woman')}</p>
|
<p>{t('app.shared.gender_input.woman')}</p>
|
||||||
<input type="radio"
|
<input type="radio"
|
||||||
|
name='gender'
|
||||||
value="false"
|
value="false"
|
||||||
disabled={isDisabled}
|
disabled={isDisabled}
|
||||||
{...register('statistic_profile_attributes.gender' as FieldPath<TFieldValues>)} />
|
{...register('statistic_profile_attributes.gender' as FieldPath<TFieldValues>)} />
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</fieldset>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -184,7 +184,7 @@ export const UserProfileForm: React.FC<UserProfileFormProps> = ({ action, size,
|
|||||||
<div className="fields-group">
|
<div className="fields-group">
|
||||||
<div className="personnal-data">
|
<div className="personnal-data">
|
||||||
<h4>{t('app.shared.user_profile_form.personal_data')}</h4>
|
<h4>{t('app.shared.user_profile_form.personal_data')}</h4>
|
||||||
<GenderInput register={register} disabled={isDisabled} />
|
<GenderInput register={register} disabled={isDisabled} required />
|
||||||
<div className="names">
|
<div className="names">
|
||||||
<FormInput id="profile_attributes.last_name"
|
<FormInput id="profile_attributes.last_name"
|
||||||
register={register}
|
register={register}
|
||||||
|
@ -1,5 +1,17 @@
|
|||||||
.gender-input {
|
.gender-input {
|
||||||
margin-bottom: 1.6rem;
|
margin-bottom: 1.6rem;
|
||||||
|
legend {
|
||||||
|
@include text-sm;
|
||||||
|
margin: 0 0 0.8rem;
|
||||||
|
border: none;
|
||||||
|
cursor: pointer;
|
||||||
|
&::first-letter { text-transform: uppercase; }
|
||||||
|
&.is-required::after {
|
||||||
|
content: "*";
|
||||||
|
margin-left: 0.5ch;
|
||||||
|
color: var(--alert);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
label {
|
label {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
|
@ -103,6 +103,7 @@ de:
|
|||||||
must_accept_terms: "You must accept the terms and conditions"
|
must_accept_terms: "You must accept the terms and conditions"
|
||||||
save: "Save"
|
save: "Save"
|
||||||
gender_input:
|
gender_input:
|
||||||
|
label: "Gender"
|
||||||
man: "Man"
|
man: "Man"
|
||||||
woman: "Woman"
|
woman: "Woman"
|
||||||
change_password:
|
change_password:
|
||||||
|
@ -103,6 +103,7 @@ en:
|
|||||||
must_accept_terms: "You must accept the terms and conditions"
|
must_accept_terms: "You must accept the terms and conditions"
|
||||||
save: "Save"
|
save: "Save"
|
||||||
gender_input:
|
gender_input:
|
||||||
|
label: "Gender"
|
||||||
man: "Man"
|
man: "Man"
|
||||||
woman: "Woman"
|
woman: "Woman"
|
||||||
change_password:
|
change_password:
|
||||||
|
@ -103,6 +103,7 @@ es:
|
|||||||
must_accept_terms: "You must accept the terms and conditions"
|
must_accept_terms: "You must accept the terms and conditions"
|
||||||
save: "Save"
|
save: "Save"
|
||||||
gender_input:
|
gender_input:
|
||||||
|
label: "Gender"
|
||||||
man: "Man"
|
man: "Man"
|
||||||
woman: "Woman"
|
woman: "Woman"
|
||||||
change_password:
|
change_password:
|
||||||
|
@ -103,6 +103,7 @@ fr:
|
|||||||
must_accept_terms: "Vous devez accepter les conditions générales"
|
must_accept_terms: "Vous devez accepter les conditions générales"
|
||||||
save: "Enregistrer"
|
save: "Enregistrer"
|
||||||
gender_input:
|
gender_input:
|
||||||
|
label: "Genre"
|
||||||
man: "Homme"
|
man: "Homme"
|
||||||
woman: "Femme"
|
woman: "Femme"
|
||||||
change_password:
|
change_password:
|
||||||
|
@ -103,6 +103,7 @@
|
|||||||
must_accept_terms: "You must accept the terms and conditions"
|
must_accept_terms: "You must accept the terms and conditions"
|
||||||
save: "Save"
|
save: "Save"
|
||||||
gender_input:
|
gender_input:
|
||||||
|
label: "Gender"
|
||||||
man: "Man"
|
man: "Man"
|
||||||
woman: "Woman"
|
woman: "Woman"
|
||||||
change_password:
|
change_password:
|
||||||
|
@ -103,6 +103,7 @@ pt:
|
|||||||
must_accept_terms: "Você deve aceitar os termos e condições"
|
must_accept_terms: "Você deve aceitar os termos e condições"
|
||||||
save: "Salvar"
|
save: "Salvar"
|
||||||
gender_input:
|
gender_input:
|
||||||
|
label: "Gender"
|
||||||
man: "Homem"
|
man: "Homem"
|
||||||
woman: "Mulher"
|
woman: "Mulher"
|
||||||
change_password:
|
change_password:
|
||||||
|
@ -103,6 +103,7 @@ zu:
|
|||||||
must_accept_terms: "crwdns28700:0crwdne28700:0"
|
must_accept_terms: "crwdns28700:0crwdne28700:0"
|
||||||
save: "crwdns28702:0crwdne28702:0"
|
save: "crwdns28702:0crwdne28702:0"
|
||||||
gender_input:
|
gender_input:
|
||||||
|
label: "crwdns37591:0crwdne37591:0"
|
||||||
man: "crwdns28704:0crwdne28704:0"
|
man: "crwdns28704:0crwdne28704:0"
|
||||||
woman: "crwdns28706:0crwdne28706:0"
|
woman: "crwdns28706:0crwdne28706:0"
|
||||||
change_password:
|
change_password:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user