Skip to content

Commit 71aaab5

Browse files
authored
Merge pull request #737 from IT-Academy-BCN/feature/43-toast-draft-saved
feat(challenge): add toast notification on draft save (IT Challanges #43)
2 parents 8820bbc + 80fc341 commit 71aaab5

File tree

8 files changed

+27
-7
lines changed

8 files changed

+27
-7
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
44
and this project adheres to
55
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
### [ita-challenges-frontend-3.27.0-RELEASE] - 2026-02-16
8+
### Added
9+
- Feedback to user when saving solution.
10+
711
### [itachallenge-frontend-3.26.0-RELEASE] - 2026-02-16
812

913
### Changed

conf/.env.CI.dev

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
MICROSERVICE_DEPLOY=ita-challenges-frontend
2-
MICROSERVICE_VERSION=3.26.0-RELEASE
2+
MICROSERVICE_VERSION=3.27.0-RELEASE

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ita-challenges-frontend",
3-
"version": "3.26.0-RELEASE",
3+
"version": "3.27.0-RELEASE",
44
"scripts": {
55
"ng": "ng",
66
"start": "ng serve --proxy-config proxy.conf.dev.json",

src/app/modules/challenge/components/challenge-header/challenge-header.component.spec.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { SolutionStatus } from 'src/app/models/user-solution-status.enum';
1717
import { CommonModalService } from 'src/app/services/common-modal.service';
1818
import { SolutionAction } from 'src/app/models/user-solution-action.enum';
1919
import { UserSolution } from 'src/app/models/user-solution.interface';
20+
import { ToastrService } from 'ngx-toastr';
2021

2122
describe('ChallengeHeaderComponent', () => {
2223
let component: ChallengeHeaderComponent;
@@ -27,6 +28,7 @@ describe('ChallengeHeaderComponent', () => {
2728
let authService: jest.Mocked<AuthService>;
2829
let solutionService: jest.Mocked<SolutionService>;
2930
let mockCommonModalService: jest.Mocked<CommonModalService>;
31+
let mockToastrService: any;
3032

3133
beforeEach(async () => {
3234
const mockRouter = { navigate: jest.fn() } as any;
@@ -65,6 +67,13 @@ describe('ChallengeHeaderComponent', () => {
6567
completeChallenge: jest.fn(),
6668
} as any
6769

70+
mockToastrService = {
71+
success: jest.fn(),
72+
error: jest.fn(),
73+
info: jest.fn(),
74+
warning: jest.fn()
75+
};
76+
6877
await TestBed.configureTestingModule({
6978
declarations: [ChallengeHeaderComponent],
7079
imports: [I18nModule, DynamicTranslatePipe, CustomDatePipe],
@@ -80,6 +89,7 @@ describe('ChallengeHeaderComponent', () => {
8089
{ provide: AuthService, useValue: authService },
8190
{ provide: SolutionService, useValue: solutionService },
8291
{ provide: CommonModalService, useValue: mockCommonModalService },
92+
{ provide: ToastrService, useValue: mockToastrService },
8393
],
8494
}).compileComponents();
8595

@@ -296,6 +306,7 @@ describe('ChallengeHeaderComponent', () => {
296306
component.userId = 'user1';
297307
component.saveChallenge();
298308
expect(spy).toHaveBeenCalledWith('challenge1', 'lang1', 'user1', SolutionAction.SAVE_DRAFT, 'solution');
309+
expect(mockToastrService.success).toHaveBeenCalledWith('messages.success.draft_saved')
299310
});
300311

301312
it('should not save challenge if data is missing', () => {

src/app/modules/challenge/components/challenge-header/challenge-header.component.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { CommonModalService } from "src/app/services/common-modal.service";
1313
import { SolutionAction } from 'src/app/models/user-solution-action.enum'
1414
import { UserSolution } from 'src/app/models/user-solution.interface'
1515
import { ShowSolutionModalComponent } from 'src/app/modules/modals/show-solution-modal/show-solution-modal.component'
16+
import { ToastrService } from 'ngx-toastr'
1617

1718
@Component({
1819
selector: 'app-challenge-header',
@@ -32,8 +33,8 @@ export class ChallengeHeaderComponent implements OnInit {
3233
private readonly challengeService = inject(ChallengeService)
3334
private readonly solutionService = inject(SolutionService)
3435
private readonly authService = inject(AuthService)
35-
private readonly commonModalService = inject(CommonModalService)
36-
36+
private readonly commonModalService = inject(CommonModalService)
37+
private readonly toastr = inject(ToastrService)
3738

3839
public userId: string | null = null;
3940
public userRole: string | null = null;
@@ -216,6 +217,7 @@ export class ChallengeHeaderComponent implements OnInit {
216217
).subscribe({
217218
next: (response: UserSolution) => {
218219
this.solutionState = response.status;
220+
this.toastr.success(this.translate.instant('messages.success.draft_saved'))
219221
},
220222
error: (err) => {
221223
console.error(' Error saving solution', err);

src/assets/i18n/ca.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,8 @@
228228
},
229229
"success": {
230230
"welcome": "Benvingut! Redirigint...",
231-
"logout": "Tancament de sessió correcte"
231+
"logout": "Tancament de sessió correcte",
232+
"draft_saved": "Esborrany desat. Pots continuar treballant en la solució més tard."
232233
}
233234
},
234235
"status": {

src/assets/i18n/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,8 @@
228228
},
229229
"success": {
230230
"welcome": "Welcome! Redirecting...",
231-
"logout": "Logout successful"
231+
"logout": "Logout successful",
232+
"draft_saved": "Draft saved. You can continue working on your solution later."
232233
}
233234
},
234235
"status": {

src/assets/i18n/es.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,8 @@
229229
},
230230
"success": {
231231
"welcome": "¡Bienvenido! Redirigiendo...",
232-
"logout": "Cierre de sesión exitoso"
232+
"logout": "Cierre de sesión exitoso",
233+
"draft_saved": "Borrador guardado. Puedes continuar trabajando en tu solución más tarde."
233234
}
234235
},
235236
"status": {

0 commit comments

Comments
 (0)