Skip to content
This repository was archived by the owner on Nov 28, 2025. It is now read-only.

Commit cee4f2d

Browse files
committed
🚧 wip
1 parent 89bfe7c commit cee4f2d

File tree

5 files changed

+17
-5
lines changed

5 files changed

+17
-5
lines changed

src/app/modules/authentication/pages/login/login.component.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ <h2 class="mt-6 text-3xl font-semibold text-slate-900">Connectez-vous</h2>
66
</p>
77
</div>
88

9+
<!-- Validation Errors -->
10+
<cosna-errors *ngIf="error$ | async; let error" [message]="error" class="mt-4"></cosna-errors>
11+
912
<form [formGroup]="form" (submit)="submit()" class="mt-10 space-y-6">
1013
<!-- Email Address -->
1114
<div>
@@ -38,8 +41,8 @@ <h2 class="mt-6 text-3xl font-semibold text-slate-900">Connectez-vous</h2>
3841
</div>
3942

4043
<div>
41-
<cosna-button-primary type="submit" class="relative justify-center w-full group">
42-
<span class="absolute inset-y-0 left-0 flex items-center pl-3">
44+
<cosna-button-primary type="submit" class="relative justify-center w-full group disabled:opacity-50 disabled:cursor-not-allowed" [loading$]="(loading$)">
45+
<span *ngIf="!(loading$ | async)" class="absolute inset-y-0 left-0 flex items-center pl-3">
4346
<svg class="w-5 h-5 text-primary-500 group-hover:text-primary-400" viewBox="0 0 20 20" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
4447
<path fill-rule="evenodd" clip-rule="evenodd" d="M10 1C7.51472 1 5.5 3.01472 5.5 5.5V9H5C3.89543 9 3 9.89543 3 11V17C3 18.1046 3.89543 19 5 19H15C16.1046 19 17 18.1046 17 17V11C17 9.89543 16.1046 9 15 9H14.5V5.5C14.5 3.01472 12.4853 1 10 1ZM13 9V5.5C13 3.84315 11.6569 2.5 10 2.5C8.34315 2.5 7 3.84315 7 5.5V9H13Z" />
4548
</svg>

src/app/modules/authentication/pages/login/login.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Store } from '@ngrx/store';
44
import { Observable } from 'rxjs';
55

66
import { authenticateAction } from '../../store/auth.actions';
7-
import { selectError } from '../../store/auth.selectors';
7+
import { selectError, selectLoading } from '../../store/auth.selectors';
88

99
@Component({
1010
templateUrl: './login.component.html',
@@ -15,14 +15,14 @@ export class LoginComponent implements OnInit {
1515
password: ['', Validators.required],
1616
});
1717
public error$: Observable<string | null> = this.store.select(selectError);
18+
public loading$: Observable<boolean> = this.store.select(selectLoading);
1819

1920
constructor(private formBuilder: FormBuilder, private store: Store) {}
2021

2122
ngOnInit(): void {}
2223

2324
public submit() {
2425
if (this.form.valid) {
25-
// console.log(this.form.getRawValue());
2626
this.store.dispatch(authenticateAction({ credentials: this.form.getRawValue() }));
2727
}
2828
}

src/app/modules/authentication/store/auth.effects.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export class AuthEffects {
2424
catchError((error) => {
2525
return of(
2626
AuthActions.authenticateFailureAction({
27-
error: error?.message ?? 'Unknown error occurred',
27+
error: error.error?.message ?? 'Unknown error occurred',
2828
})
2929
)
3030
})

src/app/modules/user/interfaces/user.interface.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
export interface AuthResponse {
2+
user: User;
3+
access_token: string;
4+
token_type: string;
5+
expires_at: Date;
6+
}
7+
18
export interface User {
29
id: number;
310
name: string;

src/app/shared/shared.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ import { ThemeModule } from './themes/theme.module';
66

77
import { OverlapingLabelComponent } from './components/inputs/overlaping-label/overlaping-label.component';
88
import { PrimaryComponent as ButtonPrimary } from './components/buttons/primary/primary.component';
9+
import { ErrorComponent } from './components/error/error.component';
910

1011

1112
const MODULES = [CommonModule, ThemeModule];
1213
const DECLARATIONS = [
1314
ButtonPrimary,
1415
OverlapingLabelComponent,
16+
ErrorComponent,
1517
];
1618

1719
@NgModule({

0 commit comments

Comments
 (0)