diff --git a/src/app/main/component/user/components/habit/add-new-habit/add-new-habit.component.scss b/src/app/main/component/user/components/habit/add-new-habit/add-new-habit.component.scss
index e21e28345a..5e08e97963 100644
--- a/src/app/main/component/user/components/habit/add-new-habit/add-new-habit.component.scss
+++ b/src/app/main/component/user/components/habit/add-new-habit/add-new-habit.component.scss
@@ -196,14 +196,14 @@
}
}
- .duration-shoping {
+ .duration-to-do {
display: flex;
width: 100%;
justify-content: space-between;
gap: 32px;
.duration,
- .shopping {
+ .to-do {
width: calc(50% - 16px);
background: var(--secondary-light-grey);
border-radius: 8px;
@@ -402,13 +402,13 @@
padding: 0;
gap: 24px;
- .duration-shoping {
+ .duration-to-do {
flex-direction: column;
height: auto;
gap: 24px;
.duration,
- .shopping {
+ .to-do {
width: 100%;
}
}
diff --git a/src/app/main/component/user/components/habit/add-new-habit/add-new-habit.component.spec.ts b/src/app/main/component/user/components/habit/add-new-habit/add-new-habit.component.spec.ts
index 6ba397933e..599717e5ca 100644
--- a/src/app/main/component/user/components/habit/add-new-habit/add-new-habit.component.spec.ts
+++ b/src/app/main/component/user/components/habit/add-new-habit/add-new-habit.component.spec.ts
@@ -6,7 +6,7 @@ import { AddNewHabitComponent } from './add-new-habit.component';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { TranslateModule } from '@ngx-translate/core';
import { LocalStorageService } from '@global-service/localstorage/local-storage.service';
-import { ShoppingListService } from './habit-edit-shopping-list/shopping-list.service';
+import { ToDoListService } from './habit-edit-to-do-list/to-do-list.service';
import { HabitService } from '@global-service/habit/habit.service';
import { HabitAssignService } from '@global-service/habit-assign/habit-assign.service';
import { of, Subject } from 'rxjs';
@@ -80,14 +80,14 @@ describe('AddNewHabitComponent', () => {
const matSnackBarMock: MatSnackBarComponent = jasmine.createSpyObj('MatSnackBarComponent', ['openSnackBar']);
- const fakeShoppingListService: ShoppingListService = jasmine.createSpyObj('fakeShoppingListService', [
- 'getHabitAllShopLists',
- 'getHabitShopList',
- 'updateHabitShopList'
+ const fakeToDoListService: ToDoListService = jasmine.createSpyObj('fakeToDoListService', [
+ 'getHabitAllToDoLists',
+ 'getHabitToDoList',
+ 'updateHabitToDoList'
]);
- fakeShoppingListService.getHabitAllShopLists = () => of();
- fakeShoppingListService.getHabitShopList = () => of();
- fakeShoppingListService.updateHabitShopList = () => of();
+ fakeToDoListService.getHabitAllToDoLists = () => of();
+ fakeToDoListService.getHabitToDoList = () => of();
+ fakeToDoListService.updateHabitToDoList = () => of();
matSnackBarMock.openSnackBar = (type: string) => type;
@@ -115,7 +115,7 @@ describe('AddNewHabitComponent', () => {
{ provide: HabitService, useValue: fakeHabitService },
{ provide: HabitAssignService, useValue: fakeHabitAssignService },
{ provide: EcoNewsService, useValue: ecoNewsServiceMock },
- { provide: ShoppingListService, useValue: fakeShoppingListService },
+ { provide: ToDoListService, useValue: fakeToDoListService },
{ provide: LocalStorageService, useValue: fakeLocalStorageService },
{ provide: ActivatedRoute, useValue: mockActivatedRoute },
{ provide: Location, useValue: locationMock },
@@ -144,8 +144,8 @@ describe('AddNewHabitComponent', () => {
it('should navigate back on onGoBack without call dialog', () => {
component.initialDuration = 1;
component.newDuration = 1;
- component.standardShopList = null;
- component.customShopList = null;
+ component.standardToDoList = null;
+ component.customToDoList = null;
const spy = spyOn(locationMock, 'back');
component.onGoBack();
expect(spy).toHaveBeenCalled();
@@ -169,22 +169,22 @@ describe('AddNewHabitComponent', () => {
expect(component.canAcquire).toBeTruthy();
});
- it('should set standardShopList', () => {
- component.getList(DEFAULTFULLINFOHABIT.shoppingListItems);
- expect(component.standardShopList).toEqual([{ id: 6, status: TodoStatus.active, text: 'TEST' }]);
- expect(component.customShopList).toEqual([]);
+ it('should set standardToDoList', () => {
+ component.getList(DEFAULTFULLINFOHABIT.toDoListItems);
+ expect(component.standardToDoList).toEqual([{ id: 6, status: TodoStatus.active, text: 'TEST' }]);
+ expect(component.customToDoList).toEqual([]);
});
- it('should set and customShopList', () => {
- component.getList(CUSTOMFULLINFOHABIT.shoppingListItems);
- expect(component.customShopList).toEqual([{ id: 6, status: TodoStatus.active, text: 'TEST', custom: true }]);
- expect(component.standardShopList).toEqual([]);
+ it('should set and customToDoList', () => {
+ component.getList(CUSTOMFULLINFOHABIT.toDoListItems);
+ expect(component.customToDoList).toEqual([{ id: 6, status: TodoStatus.active, text: 'TEST', custom: true }]);
+ expect(component.standardToDoList).toEqual([]);
});
- it('should set standardShopList and customShopList', () => {
- const shoppingListItems = DEFAULTFULLINFOHABIT.shoppingListItems.concat(CUSTOMFULLINFOHABIT.shoppingListItems);
- component.getList(shoppingListItems);
- expect(component.customShopList).toEqual(shoppingListItems.filter((item) => item.custom));
- expect(component.standardShopList).toEqual(shoppingListItems.filter((item) => !item.custom));
+ it('should set standardToDoList and customToDoList', () => {
+ const toDoListItems = DEFAULTFULLINFOHABIT.toDoListItems.concat(CUSTOMFULLINFOHABIT.toDoListItems);
+ component.getList(toDoListItems);
+ expect(component.customToDoList).toEqual(toDoListItems.filter((item) => item.custom));
+ expect(component.standardToDoList).toEqual(toDoListItems.filter((item) => !item.custom));
});
});
diff --git a/src/app/main/component/user/components/habit/add-new-habit/add-new-habit.component.ts b/src/app/main/component/user/components/habit/add-new-habit/add-new-habit.component.ts
index 73c597b027..9442a5cf1b 100644
--- a/src/app/main/component/user/components/habit/add-new-habit/add-new-habit.component.ts
+++ b/src/app/main/component/user/components/habit/add-new-habit/add-new-habit.component.ts
@@ -7,7 +7,7 @@ import { HabitService } from '@global-service/habit/habit.service';
import { LocalStorageService } from '@global-service/localstorage/local-storage.service';
import { TranslateService } from '@ngx-translate/core';
import { Subject } from 'rxjs';
-import { ShoppingListService } from './habit-edit-shopping-list/shopping-list.service';
+import { ToDoListService } from './habit-edit-to-do-list/to-do-list.service';
import { MatDialog, MatDialogRef } from '@angular/material/dialog';
import { WarningPopUpComponent } from '@shared/components';
import { Location } from '@angular/common';
@@ -20,7 +20,7 @@ import { HabitAcquireConfirm, HabitCongratulation, HabitGiveUp, HabitLeavePage }
import { WarningDialog } from '@global-user/models/warning-dialog.inteface';
import { HabitAssignInterface } from '../models/interfaces/habit-assign.interface';
import { HabitInterface, HabitListInterface } from '../models/interfaces/habit.interface';
-import { AllShoppingLists, HabitUpdateShopList, ShoppingList } from '@user-models/shoppinglist.interface';
+import { AllToDoLists, HabitUpdateToDoList, ToDoList } from '@global-user/models/to-do-list.interface';
import { UserFriendsService } from '@global-user/services/user-friends.service';
import { HabitAssignCustomPropertiesDto, HabitAssignPropertiesDto } from '@global-models/goal/HabitAssignCustomPropertiesDto';
import { singleNewsImages } from 'src/app/main/image-pathes/single-news-images';
@@ -37,9 +37,9 @@ export class AddNewHabitComponent implements OnInit, OnDestroy {
habitResponse: HabitInterface;
recommendedHabits: HabitInterface[];
recommendedNews: EcoNewsModel[];
- initialShoppingList: ShoppingList[] = [];
- standardShopList: ShoppingList[] = [];
- customShopList: ShoppingList[] = [];
+ initialToDoList: ToDoList[] = [];
+ standardToDoList: ToDoList[] = [];
+ customToDoList: ToDoList[] = [];
friendsIdsList: number[] = [];
newDuration = 7;
initialDuration: number;
@@ -73,7 +73,7 @@ export class AddNewHabitComponent implements OnInit, OnDestroy {
private snackBar: MatSnackBarComponent,
private habitAssignService: HabitAssignService,
private newsService: EcoNewsService,
- private shopListService: ShoppingListService,
+ private toDoListService: ToDoListService,
private localStorageService: LocalStorageService,
private translate: TranslateService,
private location: Location,
@@ -124,7 +124,7 @@ export class AddNewHabitComponent implements OnInit, OnDestroy {
this.isAcquired = this.assignedHabit.status === HabitStatus.ACQUIRED;
this.initialDuration = res.duration || res.habit.defaultDuration;
this.initHabitData(res.habit, res.duration || res.habit.defaultDuration);
- this.getCustomShopList();
+ this.getCustomToDoList();
});
} else {
this.getDefaultHabit();
@@ -169,10 +169,10 @@ export class AddNewHabitComponent implements OnInit, OnDestroy {
this.initHabitData(data);
this.isCustomHabit = data.isCustomHabit;
if (data.isCustomHabit) {
- data.customShoppingListItems?.forEach((item) => (item.custom = true));
- this.initialShoppingList = data.customShoppingListItems;
+ data.customToDoListItems?.forEach((item) => (item.custom = true));
+ this.initialToDoList = data.customToDoListItems;
} else {
- this.getStandardShopList();
+ this.getStandardToDoList();
}
});
}
@@ -196,7 +196,7 @@ export class AddNewHabitComponent implements OnInit, OnDestroy {
}
onGoBack(): void {
- const isHabitWasEdited = this.initialDuration !== this.newDuration || this.standardShopList || this.customShopList;
+ const isHabitWasEdited = this.initialDuration !== this.newDuration || this.standardToDoList || this.customToDoList;
if (isHabitWasEdited) {
const dialogRef = this.getOpenDialog(HabitLeavePage, false);
if (!dialogRef) {
@@ -230,28 +230,28 @@ export class AddNewHabitComponent implements OnInit, OnDestroy {
}
}
- getList(list: ShoppingList[]): void {
- this.standardShopList = list.filter((item) => !item.custom);
- this.customShopList = list.filter((item) => item.custom);
+ getList(list: ToDoList[]): void {
+ this.standardToDoList = list.filter((item) => !item.custom);
+ this.customToDoList = list.filter((item) => item.custom);
}
- private getStandardShopList(): void {
- this.shopListService
- .getHabitShopList(this.habitId)
+ private getStandardToDoList(): void {
+ this.toDoListService
+ .getHabitToDoList(this.habitId)
.pipe(take(1))
.subscribe((res) => {
- this.initialShoppingList = res;
+ this.initialToDoList = res;
});
}
- private getCustomShopList(): void {
- this.shopListService
- .getHabitAllShopLists(this.habitAssignId, this.currentLang)
+ private getCustomToDoList(): void {
+ this.toDoListService
+ .getHabitAllToDoLists(this.habitAssignId, this.currentLang)
.pipe(take(1))
- .subscribe((res: AllShoppingLists) => {
- res.customShoppingListItemDto?.forEach((item) => (item.custom = true));
- this.initialShoppingList = [...res.customShoppingListItemDto, ...res.userShoppingListItemDto];
- this.getList(this.initialShoppingList);
+ .subscribe((res: AllToDoLists) => {
+ res.customToDoListItemDto?.forEach((item) => (item.custom = true));
+ this.initialToDoList = [...res.customToDoListItemDto, ...res.userToDoListItemDto];
+ this.getList(this.initialToDoList);
});
}
@@ -289,14 +289,14 @@ export class AddNewHabitComponent implements OnInit, OnDestroy {
assignCustomHabit(): void {
this.friendsIdsList = this.userFriendsService.addedFriends?.map((friend) => friend.id);
const habitAssignPropertiesDto: HabitAssignPropertiesDto = {
- defaultShoppingListItems: this.standardShopList.filter((item) => item.selected === true).map((item) => item.id),
+ defaultToDoListItems: this.standardToDoList.filter((item) => item.selected === true).map((item) => item.id),
duration: this.newDuration,
isPrivate: this.isPrivate
};
const body: HabitAssignCustomPropertiesDto = {
friendsIdsList: this.friendsIdsList,
habitAssignPropertiesDto,
- customShoppingListItemList: this.customShopList.map((item) => ({ text: item.text }))
+ customToDoListItemList: this.customToDoList.map((item) => ({ text: item.text }))
};
this.habitAssignService
@@ -312,9 +312,9 @@ export class AddNewHabitComponent implements OnInit, OnDestroy {
.updateHabitDuration(this.habitAssignId, this.newDuration)
.pipe(take(1))
.subscribe(() => {
- if (this.customShopList || this.standardShopList) {
- this.convertShopLists();
- this.shopListService.updateHabitShopList(this.setHabitListForUpdate());
+ if (this.customToDoList || this.standardToDoList) {
+ this.convertToDoLists();
+ this.toDoListService.updateHabitToDoList(this.setHabitListForUpdate());
}
this.afterHabitWasChanged('habitUpdated');
});
@@ -334,12 +334,12 @@ export class AddNewHabitComponent implements OnInit, OnDestroy {
});
}
- private convertShopLists(): void {
- this.customShopList?.forEach((el) => {
+ private convertToDoLists(): void {
+ this.customToDoList?.forEach((el) => {
delete el.custom;
delete el.selected;
});
- this.standardShopList?.forEach((el) => {
+ this.standardToDoList?.forEach((el) => {
delete el.custom;
delete el.selected;
});
@@ -350,11 +350,11 @@ export class AddNewHabitComponent implements OnInit, OnDestroy {
this.snackBar.openSnackBar(kindOfChanges);
}
- private setHabitListForUpdate(): HabitUpdateShopList {
+ private setHabitListForUpdate(): HabitUpdateToDoList {
return {
habitAssignId: this.habitAssignId,
- customShopList: this.customShopList,
- standardShopList: this.standardShopList,
+ customToDoList: this.customToDoList,
+ standardToDoList: this.standardToDoList,
lang: this.currentLang
};
}
diff --git a/src/app/main/component/user/components/habit/add-new-habit/habit-edit-shopping-list/shopping-list.service.spec.ts b/src/app/main/component/user/components/habit/add-new-habit/habit-edit-shopping-list/shopping-list.service.spec.ts
deleted file mode 100644
index 4f073b5e63..0000000000
--- a/src/app/main/component/user/components/habit/add-new-habit/habit-edit-shopping-list/shopping-list.service.spec.ts
+++ /dev/null
@@ -1,88 +0,0 @@
-import { TestBed } from '@angular/core/testing';
-import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
-
-import { ShoppingListService } from './shopping-list.service';
-import { TranslateModule, TranslateService } from '@ngx-translate/core';
-import { environment } from '@environment/environment';
-import {
- ALLUSERSHOPLISTS,
- CUSTOMSHOPITEM,
- SHOPLIST,
- SHOPLISTITEMONE,
- SHOPLISTITEMTWO,
- UPDATEHABITSHOPLIST
-} from '../../mocks/shopping-list-mock';
-
-describe('ShoppingListService', () => {
- let service: ShoppingListService;
- let httpMock: HttpTestingController;
-
- const mainLink = environment.backendLink;
-
- beforeEach(() => {
- TestBed.configureTestingModule({
- imports: [HttpClientTestingModule, TranslateModule.forRoot()],
- providers: [ShoppingListService, TranslateService]
- });
-
- service = TestBed.inject(ShoppingListService);
- httpMock = TestBed.inject(HttpTestingController);
- });
-
- afterEach(() => {
- httpMock.verify();
- });
-
- it('should be created', () => {
- expect(service).toBeTruthy();
- });
-
- it('should return allShopList by habitId on getHabitAllShopLists', () => {
- service.getHabitAllShopLists(2, 'en').subscribe((data) => {
- expect(data).toEqual(ALLUSERSHOPLISTS);
- });
-
- const req = httpMock.expectOne(`${mainLink}habit/assign/2/allUserAndCustomList?lang=en`);
- expect(req.request.responseType).toEqual('json');
- expect(req.request.method).toBe('GET');
- req.flush(ALLUSERSHOPLISTS);
- });
-
- it('should return all user shopList by lang on getUserShoppingLists', () => {
- service.getUserShoppingLists('ua').subscribe((data) => {
- expect(data).toEqual([ALLUSERSHOPLISTS]);
- });
-
- const req = httpMock.expectOne(`${mainLink}habit/assign/allUserAndCustomShoppingListsInprogress?lang=ua`);
- expect(req.request.responseType).toEqual('json');
- expect(req.request.method).toBe('GET');
- req.flush([ALLUSERSHOPLISTS]);
- });
-
- it('should update Standard Shop Item Status', () => {
- service.updateStandardShopItemStatus(SHOPLISTITEMTWO, 'ua').subscribe((data) => {
- expect(data).toEqual([SHOPLISTITEMTWO]);
- });
- const req = httpMock.expectOne(`${mainLink}user/shopping-list-items/2/status/INPROGRESS?lang=ua`);
- expect(req.request.method).toBe('PATCH');
- req.flush([SHOPLISTITEMTWO]);
- });
-
- it('should update Custom Shop Item Status', () => {
- service.updateCustomShopItemStatus(1, SHOPLISTITEMTWO).subscribe((data) => {
- expect(data).toEqual(SHOPLISTITEMTWO);
- });
- const req = httpMock.expectOne(`${mainLink}custom/shopping-list-items/1/custom-shopping-list-items?itemId=2&status=INPROGRESS`);
- expect(req.request.method).toBe('PATCH');
- req.flush(SHOPLISTITEMTWO);
- });
-
- it('should update Habit Shop List', () => {
- service.updateHabitShopList(UPDATEHABITSHOPLIST).subscribe((data) => {
- expect(data).toEqual(null);
- });
- const req = httpMock.expectOne(`${mainLink}habit/assign/2/allUserAndCustomList?lang=ua`);
- expect(req.request.method).toBe('PUT');
- req.flush(null);
- });
-});
diff --git a/src/app/main/component/user/components/habit/add-new-habit/habit-edit-shopping-list/shopping-list.service.ts b/src/app/main/component/user/components/habit/add-new-habit/habit-edit-shopping-list/shopping-list.service.ts
deleted file mode 100644
index 119936cd04..0000000000
--- a/src/app/main/component/user/components/habit/add-new-habit/habit-edit-shopping-list/shopping-list.service.ts
+++ /dev/null
@@ -1,46 +0,0 @@
-import { Injectable } from '@angular/core';
-import { Observable } from 'rxjs';
-import { HttpClient } from '@angular/common/http';
-import { mainLink } from 'src/app/main/links';
-import { AllShoppingLists, HabitUpdateShopList, ShoppingList } from '@user-models/shoppinglist.interface';
-
-@Injectable({
- providedIn: 'root'
-})
-export class ShoppingListService {
- constructor(private http: HttpClient) {}
-
- getHabitShopList(habitId: number): Observable
{
- return this.http.get(`${mainLink}habit/${habitId}/shopping-list`);
- }
-
- getHabitAllShopLists(habitAssignId: number, lang: string): Observable {
- return this.http.get(`${mainLink}habit/assign/${habitAssignId}/allUserAndCustomList?lang=${lang}`);
- }
-
- getUserShoppingLists(lang: string): Observable {
- return this.http.get(`${mainLink}habit/assign/allUserAndCustomShoppingListsInprogress?lang=${lang}`);
- }
-
- updateStandardShopItemStatus(item: ShoppingList, lang: string): Observable {
- const body = {};
- return this.http.patch(`${mainLink}user/shopping-list-items/${item.id}/status/${item.status}?lang=${lang}`, body);
- }
-
- updateCustomShopItemStatus(userId: number, item: ShoppingList): Observable {
- const body = {};
- return this.http.patch(
- `${mainLink}custom/shopping-list-items/${userId}/custom-shopping-list-items?itemId=${item.id}&status=${item.status}`,
- body
- );
- }
-
- updateHabitShopList(habitShopList: HabitUpdateShopList) {
- const assignId = habitShopList.habitAssignId;
- const body = {
- customShoppingListItemDto: habitShopList.customShopList,
- userShoppingListItemDto: habitShopList.standardShopList
- };
- return this.http.put(`${mainLink}habit/assign/${assignId}/allUserAndCustomList?lang=${habitShopList.lang}`, body);
- }
-}
diff --git a/src/app/main/component/user/components/habit/add-new-habit/habit-edit-shopping-list/habit-edit-shopping-list.component.html b/src/app/main/component/user/components/habit/add-new-habit/habit-edit-to-do-list/habit-edit-to-do-list.component.html
similarity index 85%
rename from src/app/main/component/user/components/habit/add-new-habit/habit-edit-shopping-list/habit-edit-shopping-list.component.html
rename to src/app/main/component/user/components/habit/add-new-habit/habit-edit-to-do-list/habit-edit-to-do-list.component.html
index cd39734542..62ae3bef0b 100644
--- a/src/app/main/component/user/components/habit/add-new-habit/habit-edit-shopping-list/habit-edit-shopping-list.component.html
+++ b/src/app/main/component/user/components/habit/add-new-habit/habit-edit-to-do-list/habit-edit-to-do-list.component.html
@@ -1,10 +1,10 @@
-
+
{{ 'user.habit.to-do.to-do-list' | translate }}
-
-
- -
+
+
+ -