Skip to content

Commit

Permalink
Properly fix error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
duncte123 committed Apr 12, 2024
1 parent b7314bd commit 500132d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "webapp",
"version": "2024.04.01",
"version": "2024.04.12",
"scripts": {
"ng": "ng",
"start": "ng serve --hmr true",
Expand Down
11 changes: 10 additions & 1 deletion src/app/auth/sign-up/sign-up.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ActivatedRoute } from '@angular/router';
import { SignupDto } from '../../../model/dto/signup-dto';
import { faEnvelope, faEye, faEyeSlash, faLock, faUser } from '@fortawesome/free-solid-svg-icons';
import { AuthService } from '../../../services/auth.service';
import { NwbAlertService } from '@wizishop/ng-wizi-bulma';

@Component({
selector: 'app-sign-up',
Expand Down Expand Up @@ -36,6 +37,7 @@ export class SignUpComponent {
constructor(
private route: ActivatedRoute,
private authService: AuthService,
private toastr: NwbAlertService,
) {
this.route.queryParams.subscribe(params => {
this.data.username = (params['username'] || '').toLowerCase();
Expand All @@ -58,7 +60,14 @@ export class SignUpComponent {
this.showNextStep = true;
}
} catch (e: any) {
const errors: { field: string; defaultMessage: string }[] = e.error.errors || {};
this.toastr.open({
message: 'Something went wrong, please check for validation errors. If the issue persists, please contact support in discord.',
duration: 5000,
position: 'is-right',
color: 'is-error'
});

const errors: { field: string; defaultMessage: string }[] = e.error.errors ?? [];

errors.forEach(({ field, defaultMessage }) => {
this.errors[field] = defaultMessage;
Expand Down
4 changes: 2 additions & 2 deletions src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export const environment = {
// this is the base of the website where the users will land
baseSite: 'http://localhost:4200',
// the api that the front-end talks to
api: '/api',
// api: 'https://oengus.dev/api',
// api: '/api',
api: 'https://oengus.dev/api',
// api: 'https://oengus.io/api',
// Optional, in case of a custom hosted patreon api, will use api by default
// patronApi: 'http://localhost:9000',
Expand Down

0 comments on commit 500132d

Please sign in to comment.