chore: add husky pre-commit hook and lint-staged configuration

- Created a pre-commit hook in .husky to run lint-staged.
- Added .lintstagedrc.mjs to format frontend files with Prettier and apply Spotless to backend Java files.
- Introduced .prettierignore to exclude specific directories from formatting.
This commit is contained in:
nessar committed 2026-08-17 14:18:16 +02:00
1 parent 5d2d85aa8c
commit 878da155bd
564 files changed
+61467 -47179

No files matched your search

@@ -1,141 +1,141 @@
:host {
display: block;
display: block;
}
.settings-card {
overflow: hidden;
overflow: hidden;
}
.settings-card h2 {
margin-bottom: 9px;
font-size: 1.35rem;
letter-spacing: -0.035em;
margin-bottom: 9px;
font-size: 1.35rem;
letter-spacing: -0.035em;
}
.settings-card p:not(.eyebrow) {
color: var(--text-muted);
line-height: 1.55;
color: var(--text-muted);
line-height: 1.55;
}
.settings-copy {
display: flex;
gap: 15px;
padding: 22px;
border-bottom: 1px solid var(--border);
display: flex;
gap: 15px;
padding: 22px;
border-bottom: 1px solid var(--border);
}
.settings-icon {
display: grid;
width: 46px;
height: 46px;
flex: 0 0 46px;
place-items: center;
border-radius: 16px;
background: var(--surface-accent);
color: var(--accent);
display: grid;
width: 46px;
height: 46px;
flex: 0 0 46px;
place-items: center;
border-radius: 16px;
background: var(--surface-accent);
color: var(--accent);
}
.settings-icon fa-icon {
display: flex;
width: 24px;
height: 24px;
display: flex;
width: 24px;
height: 24px;
}
.settings-icon fa-icon svg {
width: 100%;
height: 100%;
width: 100%;
height: 100%;
}
.settings-copy h2 {
margin-bottom: 5px;
margin-bottom: 5px;
}
.settings-copy p:last-child {
margin-bottom: 0;
font-size: 0.88rem;
margin-bottom: 0;
font-size: 0.88rem;
}
.theme-options {
display: grid;
padding: 8px;
display: grid;
padding: 8px;
}
.theme-options mat-radio-button {
border-radius: 14px;
border-radius: 14px;
}
.theme-options mat-radio-button:hover {
background: var(--surface-soft);
background: var(--surface-soft);
}
.theme-option-copy {
display: flex;
flex-direction: column;
padding: 12px 8px;
display: flex;
flex-direction: column;
padding: 12px 8px;
}
.theme-option-copy strong {
color: var(--text);
color: var(--text);
}
.theme-option-copy small {
margin-top: 3px;
color: var(--text-muted);
white-space: normal;
margin-top: 3px;
color: var(--text-muted);
white-space: normal;
}
.session-settings {
margin-top: 16px;
margin-top: 16px;
}
.landlord-profile {
margin-top: 16px;
margin-top: 16px;
}
.profile-content {
padding: 22px;
padding: 22px;
}
.profile-loading,
.profile-message {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 12px;
min-height: 72px;
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 12px;
min-height: 72px;
}
.profile-message {
align-items: flex-start;
flex-direction: column;
align-items: flex-start;
flex-direction: column;
}
.profile-message .alert-error,
.profile-success {
margin: 0 0 16px;
margin: 0 0 16px;
}
.profile-success {
color: var(--accent-strong, #0a5f59);
font-weight: 600;
color: var(--accent-strong, #0a5f59);
font-weight: 600;
}
.session-action {
display: flex;
flex-direction: column;
align-items: stretch;
gap: 18px;
padding: 22px;
display: flex;
flex-direction: column;
align-items: stretch;
gap: 18px;
padding: 22px;
}
.session-action > div {
display: flex;
min-width: 0;
flex-direction: column;
display: flex;
min-width: 0;
flex-direction: column;
}
.session-action strong,
.session-action span {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.session-action span {
margin-top: 3px;
color: var(--text-muted);
font-size: 0.82rem;
margin-top: 3px;
color: var(--text-muted);
font-size: 0.82rem;
}
.session-action .mat-mdc-outlined-button {
--mdc-outlined-button-label-text-color: var(--danger);
--mdc-outlined-button-outline-color: var(--border-strong);
border-radius: 12px;
--mdc-outlined-button-label-text-color: var(--danger);
--mdc-outlined-button-outline-color: var(--border-strong);
border-radius: 12px;
}
@media (min-width: 960px) {
.settings-card {
display: grid;
grid-template-columns: minmax(280px, 0.8fr) minmax(360px, 1.2fr);
}
.settings-copy {
border-right: 1px solid var(--border);
border-bottom: 0;
}
.session-action {
align-items: flex-start;
justify-content: center;
}
.settings-card {
display: grid;
grid-template-columns: minmax(280px, 0.8fr) minmax(360px, 1.2fr);
}
.settings-copy {
border-right: 1px solid var(--border);
border-bottom: 0;
}
.session-action {
align-items: flex-start;
justify-content: center;
}
}
@@ -1,94 +1,98 @@
<section class="page-section settings-page">
<header class="page-heading">
<div>
<p class="eyebrow">Préférences</p>
<h1>Réglages</h1>
<p>Adaptez LMNP Organizer à votre façon de travailler.</p>
</div>
</header>
<article class="settings-card" aria-labelledby="appearance-heading">
<div class="settings-copy">
<span class="settings-icon" aria-hidden="true"><fa-icon [icon]="faMoon" /></span>
<div>
<p class="eyebrow">Interface</p>
<h2 id="appearance-heading">Apparence</h2>
<p>Le réglage est mémorisé uniquement sur cet appareil.</p>
</div>
</div>
<mat-radio-group
class="theme-options"
aria-label="Thème de l'application"
[value]="theme.preference()"
(change)="theme.setPreference($event.value)"
>
<mat-radio-button value="light"
><span class="theme-option-copy"
><strong>Clair</strong><small>Une interface lumineuse et douce.</small></span
></mat-radio-button
>
<mat-radio-button value="dark"
><span class="theme-option-copy"
><strong>Sombre</strong><small>Un contraste réduit en faible lumière.</small></span
></mat-radio-button
>
<mat-radio-button value="system"
><span class="theme-option-copy"
><strong>Système</strong><small>Suit automatiquement votre appareil.</small></span
></mat-radio-button
>
</mat-radio-group>
</article>
<article class="settings-card landlord-profile" aria-labelledby="profile-heading">
<div class="settings-copy">
<span class="settings-icon" aria-hidden="true"><fa-icon [icon]="faAddressCard" /></span>
<div>
<p class="eyebrow">Bailleur</p>
<h2 id="profile-heading">Profil personnel</h2>
<p>Ces coordonnées sont utilisées dans vos baux et vos quittances.</p>
</div>
</div>
<div class="profile-content">
@if (profileStatus() === 'loading') {
<div class="profile-loading" role="status" aria-live="polite">
<mat-spinner diameter="24" aria-hidden="true" /> Chargement de votre profil…
</div>
} @else if (profileStatus() === 'error') {
<div class="profile-message">
<p class="alert-error" role="alert">{{ profileError() }}</p>
<button mat-stroked-button type="button" (click)="loadProfile()">Réessayer</button>
</div>
} @else {
@if (saveSuccess()) {
<p class="profile-success" role="status">{{ saveSuccess() }}</p>
}
<app-landlord-profile-form
[profile]="profileModel()"
[saving]="saving()"
[saveError]="saveError()"
(saveRequested)="save($event)"
/>
}
</div>
</article>
<article
class="settings-card session-settings"
data-testid="session-settings"
aria-labelledby="session-heading"
>
<div class="settings-copy">
<span class="settings-icon" aria-hidden="true"><fa-icon [icon]="faUser" /></span>
<div>
<p class="eyebrow">Compte</p>
<h2 id="session-heading">Session</h2>
<p>Gérez la session ouverte sur cet appareil.</p>
</div>
</div>
<div class="session-action">
<div>
<strong>{{ session.username() }}</strong
><span>{{ session.email() }}</span>
</div>
<button mat-stroked-button type="button" (click)="logout()">Déconnexion</button>
</div>
</article>
<header class="page-heading">
<div>
<p class="eyebrow">Préférences</p>
<h1>Réglages</h1>
<p>Adaptez LMNP Organizer à votre façon de travailler.</p>
</div>
</header>
<article class="settings-card" aria-labelledby="appearance-heading">
<div class="settings-copy">
<span class="settings-icon" aria-hidden="true"><fa-icon [icon]="faMoon" /></span>
<div>
<p class="eyebrow">Interface</p>
<h2 id="appearance-heading">Apparence</h2>
<p>Le réglage est mémorisé uniquement sur cet appareil.</p>
</div>
</div>
<mat-radio-group
class="theme-options"
aria-label="Thème de l'application"
[value]="theme.preference()"
(change)="theme.setPreference($event.value)"
>
<mat-radio-button value="light"
><span class="theme-option-copy"
><strong>Clair</strong><small>Une interface lumineuse et douce.</small></span
></mat-radio-button
>
<mat-radio-button value="dark"
><span class="theme-option-copy"
><strong>Sombre</strong
><small>Un contraste réduit en faible lumière.</small></span
></mat-radio-button
>
<mat-radio-button value="system"
><span class="theme-option-copy"
><strong>Système</strong
><small>Suit automatiquement votre appareil.</small></span
></mat-radio-button
>
</mat-radio-group>
</article>
<article class="settings-card landlord-profile" aria-labelledby="profile-heading">
<div class="settings-copy">
<span class="settings-icon" aria-hidden="true"><fa-icon [icon]="faAddressCard" /></span>
<div>
<p class="eyebrow">Bailleur</p>
<h2 id="profile-heading">Profil personnel</h2>
<p>Ces coordonnées sont utilisées dans vos baux et vos quittances.</p>
</div>
</div>
<div class="profile-content">
@if (profileStatus() === 'loading') {
<div class="profile-loading" role="status" aria-live="polite">
<mat-spinner diameter="24" aria-hidden="true" /> Chargement de votre profil…
</div>
} @else if (profileStatus() === 'error') {
<div class="profile-message">
<p class="alert-error" role="alert">{{ profileError() }}</p>
<button mat-stroked-button type="button" (click)="loadProfile()">
Réessayer
</button>
</div>
} @else {
@if (saveSuccess()) {
<p class="profile-success" role="status">{{ saveSuccess() }}</p>
}
<app-landlord-profile-form
[profile]="profileModel()"
[saving]="saving()"
[saveError]="saveError()"
(saveRequested)="save($event)"
/>
}
</div>
</article>
<article
class="settings-card session-settings"
data-testid="session-settings"
aria-labelledby="session-heading"
>
<div class="settings-copy">
<span class="settings-icon" aria-hidden="true"><fa-icon [icon]="faUser" /></span>
<div>
<p class="eyebrow">Compte</p>
<h2 id="session-heading">Session</h2>
<p>Gérez la session ouverte sur cet appareil.</p>
</div>
</div>
<div class="session-action">
<div>
<strong>{{ session.username() }}</strong
><span>{{ session.email() }}</span>
</div>
<button mat-stroked-button type="button" (click)="logout()">Déconnexion</button>
</div>
</article>
</section>
@@ -9,86 +9,92 @@ import { ThemeService } from '../../services/theme.service';
import { SettingsPage } from './settings-page';
describe('SettingsPage', () => {
const profile = {
getProfile: vi.fn(),
updateProfile: vi.fn(),
};
const session = {
username: signal('Camille Martin'),
email: signal('camille@example.com'),
logout: vi.fn(),
};
const theme = {
preference: signal('system'),
setPreference: vi.fn(),
};
const profile = {
getProfile: vi.fn(),
updateProfile: vi.fn(),
};
const session = {
username: signal('Camille Martin'),
email: signal('camille@example.com'),
logout: vi.fn(),
};
const theme = {
preference: signal('system'),
setPreference: vi.fn(),
};
beforeEach(() => {
vi.clearAllMocks();
profile.getProfile.mockReturnValue(
of({
firstName: 'Camille',
lastName: 'Martin',
email: 'camille@example.com',
phone: '+33600000000',
address: '1 rue de Paris',
}),
);
TestBed.configureTestingModule({
providers: [
{ provide: LandlordProfileService, useValue: profile },
{ provide: SessionService, useValue: session },
{ provide: ThemeService, useValue: theme },
],
});
});
beforeEach(() => {
vi.clearAllMocks();
profile.getProfile.mockReturnValue(
of({
firstName: 'Camille',
lastName: 'Martin',
email: 'camille@example.com',
phone: '+33600000000',
address: '1 rue de Paris',
}),
);
TestBed.configureTestingModule({
providers: [
{ provide: LandlordProfileService, useValue: profile },
{ provide: SessionService, useValue: session },
{ provide: ThemeService, useValue: theme },
],
});
});
it('prefills the landlord profile from the connected account', async () => {
const fixture = TestBed.createComponent(SettingsPage);
fixture.detectChanges();
await fixture.whenStable();
it('prefills the landlord profile from the connected account', async () => {
const fixture = TestBed.createComponent(SettingsPage);
fixture.detectChanges();
await fixture.whenStable();
expect(fixture.nativeElement.querySelector('input#profile-firstName').value).toBe('Camille');
expect(fixture.nativeElement.querySelector('input#profile-email').value).toBe(
'camille@example.com',
);
expect(fixture.nativeElement.querySelector('input#profile-address').value).toBe(
'1 rue de Paris',
);
});
expect(fixture.nativeElement.querySelector('input#profile-firstName').value).toBe(
'Camille',
);
expect(fixture.nativeElement.querySelector('input#profile-email').value).toBe(
'camille@example.com',
);
expect(fixture.nativeElement.querySelector('input#profile-address').value).toBe(
'1 rue de Paris',
);
});
it('keeps the entered values and explains a rejected profile save', async () => {
profile.updateProfile.mockReturnValue(
throwError(
() =>
new HttpErrorResponse({
error: { message: 'Cette adresse e-mail est déjà utilisée.' },
status: 409,
}),
),
);
const fixture = TestBed.createComponent(SettingsPage);
fixture.detectChanges();
await fixture.whenStable();
const email = fixture.nativeElement.querySelector('input#profile-email') as HTMLInputElement;
email.value = 'alex@example.com';
email.dispatchEvent(new Event('input'));
fixture.detectChanges();
it('keeps the entered values and explains a rejected profile save', async () => {
profile.updateProfile.mockReturnValue(
throwError(
() =>
new HttpErrorResponse({
error: { message: 'Cette adresse e-mail est déjà utilisée.' },
status: 409,
}),
),
);
const fixture = TestBed.createComponent(SettingsPage);
fixture.detectChanges();
await fixture.whenStable();
const email = fixture.nativeElement.querySelector(
'input#profile-email',
) as HTMLInputElement;
email.value = 'alex@example.com';
email.dispatchEvent(new Event('input'));
fixture.detectChanges();
fixture.nativeElement.querySelector('button.primary-action').click();
fixture.detectChanges();
await fixture.whenStable();
fixture.nativeElement.querySelector('button.primary-action').click();
fixture.detectChanges();
await fixture.whenStable();
expect(profile.updateProfile).toHaveBeenCalledWith({
firstName: 'Camille',
lastName: 'Martin',
email: 'alex@example.com',
phone: '+33600000000',
address: '1 rue de Paris',
});
expect(fixture.nativeElement.textContent).toContain('Cette adresse e-mail est déjà utilisée.');
expect(fixture.nativeElement.querySelector('input#profile-email').value).toBe(
'alex@example.com',
);
});
expect(profile.updateProfile).toHaveBeenCalledWith({
firstName: 'Camille',
lastName: 'Martin',
email: 'alex@example.com',
phone: '+33600000000',
address: '1 rue de Paris',
});
expect(fixture.nativeElement.textContent).toContain(
'Cette adresse e-mail est déjà utilisée.',
);
expect(fixture.nativeElement.querySelector('input#profile-email').value).toBe(
'alex@example.com',
);
});
});
@@ -12,87 +12,92 @@ import { SessionService } from '../../services/session.service';
import { ThemeService } from '../../services/theme.service';
@Component({
selector: 'app-settings-page',
imports: [
FontAwesomeModule,
MatButtonModule,
MatProgressSpinnerModule,
MatRadioModule,
LandlordProfileForm,
],
templateUrl: './settings-page.html',
styleUrl: './settings-page.css',
selector: 'app-settings-page',
imports: [
FontAwesomeModule,
MatButtonModule,
MatProgressSpinnerModule,
MatRadioModule,
LandlordProfileForm,
],
templateUrl: './settings-page.html',
styleUrl: './settings-page.css',
})
export class SettingsPage {
readonly faMoon = faMoon;
readonly faUser = faUser;
readonly faAddressCard = faAddressCard;
readonly session = inject(SessionService);
readonly theme = inject(ThemeService);
private readonly landlordProfile = inject(LandlordProfileService);
private readonly destroyRef = inject(DestroyRef);
readonly faMoon = faMoon;
readonly faUser = faUser;
readonly faAddressCard = faAddressCard;
readonly session = inject(SessionService);
readonly theme = inject(ThemeService);
private readonly landlordProfile = inject(LandlordProfileService);
private readonly destroyRef = inject(DestroyRef);
readonly profileStatus = signal<'loading' | 'ready' | 'error'>('loading');
readonly saving = signal(false);
readonly profileStatus = signal<'loading' | 'ready' | 'error'>('loading');
readonly saving = signal(false);
readonly profileModel = signal<LandlordProfile>({
firstName: '',
lastName: '',
email: '',
phone: '',
address: '',
});
readonly profileModel = signal<LandlordProfile>({
firstName: '',
lastName: '',
email: '',
phone: '',
address: '',
});
readonly profileError = signal('');
readonly saveError = signal('');
readonly saveSuccess = signal('');
readonly profileError = signal('');
readonly saveError = signal('');
readonly saveSuccess = signal('');
constructor() {
this.loadProfile();
}
constructor() {
this.loadProfile();
}
logout(): void {
this.session.logout();
}
logout(): void {
this.session.logout();
}
loadProfile(): void {
this.profileStatus.set('loading');
this.profileError.set('');
this.landlordProfile
.getProfile()
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe({
next: (profile) => {
this.profileModel.set(profile);
this.profileStatus.set('ready');
},
error: () => {
this.profileStatus.set('error');
this.profileError.set('Impossible de charger votre profil bailleur. Réessayez.');
},
});
}
loadProfile(): void {
this.profileStatus.set('loading');
this.profileError.set('');
this.landlordProfile
.getProfile()
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe({
next: (profile) => {
this.profileModel.set(profile);
this.profileStatus.set('ready');
},
error: () => {
this.profileStatus.set('error');
this.profileError.set(
'Impossible de charger votre profil bailleur. Réessayez.',
);
},
});
}
save(profile: LandlordProfile): void {
if (this.saving()) return;
this.saveSuccess.set('');
this.saveError.set('');
this.saving.set(true);
this.landlordProfile
.updateProfile(profile)
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe({
next: (savedProfile) => {
this.profileModel.set(savedProfile);
this.saveSuccess.set('Profil bailleur enregistré.');
this.saving.set(false);
},
error: (error: unknown) => {
this.saveError.set(
httpErrorMessage(error, 'Impossible d’enregistrer votre profil bailleur. Réessayez.'),
);
this.saving.set(false);
},
});
}
save(profile: LandlordProfile): void {
if (this.saving()) return;
this.saveSuccess.set('');
this.saveError.set('');
this.saving.set(true);
this.landlordProfile
.updateProfile(profile)
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe({
next: (savedProfile) => {
this.profileModel.set(savedProfile);
this.saveSuccess.set('Profil bailleur enregistré.');
this.saving.set(false);
},
error: (error: unknown) => {
this.saveError.set(
httpErrorMessage(
error,
'Impossible d’enregistrer votre profil bailleur. Réessayez.',
),
);
this.saving.set(false);
},
});
}
}