diff --git a/angular.json b/angular.json index 3394018..0c355b1 100644 --- a/angular.json +++ b/angular.json @@ -42,7 +42,7 @@ "budgets": [ { "type": "initial", - "maximumWarning": "500kB", + "maximumWarning": "1MB", "maximumError": "1MB" }, { diff --git a/db.json b/db.json index fc82235..ce77698 100644 --- a/db.json +++ b/db.json @@ -1,28 +1,22 @@ { "tasks": [ { - "id": "a2e6", - "title": "Teste", + "id": "39b1", + "title": "Testando", "categoryId": "1", - "isCompleted": false + "isCompleted": true }, { - "id": "9992", - "title": "Testeasdas", - "categoryId": "1", - "isCompleted": false + "id": "ab73", + "title": "testando", + "categoryId": "2", + "isCompleted": true }, { - "id": "c544", - "title": "treinar", - "categoryId": "1", - "isCompleted": false - }, - { - "id": "ecc9", - "title": "treinar 2", - "categoryId": "1", - "isCompleted": false + "id": "eee1", + "title": "Hackeando tudo", + "categoryId": "3", + "isCompleted": true } ], "categories": [ @@ -34,7 +28,7 @@ { "id": "2", "name": "Estudo", - "color": "orange" + "color": "yellow" }, { "id": "3", diff --git a/public/no_data.svg b/public/no_data.svg new file mode 100644 index 0000000..d10300c --- /dev/null +++ b/public/no_data.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/public/trash.svg b/public/trash.svg new file mode 100644 index 0000000..0be09ac --- /dev/null +++ b/public/trash.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 7f32813..5142978 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,6 +1,7 @@ import { Component } from '@angular/core'; -import { ThemeToggleComponent } from './shared/components/theme-toggle/theme-toggle.component'; -import { MainComponent } from "./layout/main/main.component"; +import { MainComponent } from '@layout/main/main.component'; +import { ThemeToggleComponent } from '@shared/components/theme-toggle/theme-toggle.component'; + const COMPONENTS = [ThemeToggleComponent, MainComponent]; diff --git a/src/app/features/category/components/colors-list/colors-list.component.ts b/src/app/features/category/components/colors-list/colors-list.component.ts index 2808e4e..9ed75aa 100644 --- a/src/app/features/category/components/colors-list/colors-list.component.ts +++ b/src/app/features/category/components/colors-list/colors-list.component.ts @@ -1,8 +1,8 @@ -import { categoryBackgroundColors } from './../../constants/category-colors'; -import { Category } from './../../model/category.model'; import { ChangeDetectionStrategy, Component, inject, Signal } from '@angular/core'; import { MatDivider } from '@angular/material/divider'; -import { CategoryService } from '../../services/category.service'; +import { categoryBackgroundColors } from '@features/category/constants/category-colors'; +import { Category } from '@features/category/model/category.model'; +import { CategoryService } from '@features/category/services/category.service'; const MODULES = [MatDivider]; diff --git a/src/app/features/category/components/main-list/main-list.component.ts b/src/app/features/category/components/main-list/main-list.component.ts index 5e71b61..24f51cf 100644 --- a/src/app/features/category/components/main-list/main-list.component.ts +++ b/src/app/features/category/components/main-list/main-list.component.ts @@ -1,7 +1,8 @@ import { CommonModule } from '@angular/common'; import { ChangeDetectionStrategy, Component, inject, Signal } from '@angular/core'; -import { Category } from '../../model/category.model'; -import { CategoryService } from '../../services/category.service'; +import { Category } from '@category/model/category.model'; +import { CategoryService } from '@category/services/category.service'; + @Component({ selector: 'app-main-list', diff --git a/src/app/features/category/constants/category-colors.ts b/src/app/features/category/constants/category-colors.ts index 18d3039..d8b325e 100644 --- a/src/app/features/category/constants/category-colors.ts +++ b/src/app/features/category/constants/category-colors.ts @@ -1,6 +1,6 @@ export const categoryBackgroundColors: Record = { green: 'bg-green-600', - orange: 'bg-yellow-600', + yellow: 'bg-yellow-600', red: 'bg-red-600', blue: 'bg-blue-600', purple: 'bg-purple-600', @@ -13,3 +13,13 @@ export const categoryBackgroundIdColors: Record = { '4': 'bg-blue-600', '5': 'bg-purple-600', }; + + +export const categoryTextColors: Record = { + green: 'text-green-600', + yellow: 'text-yellow-600', + red: 'text-red-600', + blue: 'text-blue-600', + purple: 'text-purple-600', +}; + diff --git a/src/app/features/task/components/inclusion-form/include-task-form/include-task-form.component.spec.ts b/src/app/features/task/components/inclusion-form/include-task-form/include-task-form.component.spec.ts index 984b5b5..889a0e2 100644 --- a/src/app/features/task/components/inclusion-form/include-task-form/include-task-form.component.spec.ts +++ b/src/app/features/task/components/inclusion-form/include-task-form/include-task-form.component.spec.ts @@ -1,22 +1,17 @@ -import { SnackBarService } from './../../../../../shared/services/snack-bar.service'; -import { TaskService } from './../../../service/task.service'; -import { CategoryService } from './../../../../category/services/category.service'; -import { - ComponentFixture, - fakeAsync, - TestBed, - tick, -} from '@angular/core/testing'; -import { NO_ERRORS_SCHEMA } from '@angular/core'; -import { IncludeTaskFormComponent } from './include-task-form.component'; - +import { SnackBarService } from '@shared/services/snack-bar.service'; +import { TaskService } from '@features/task/service/task.service'; +import { CategoryService } from '@features/category/services/category.service'; +import { Task } from '@features/task/model/task.model'; +import { task } from '@mocks/task'; import { Observable, of } from 'rxjs'; -import { Task } from '../../../model/task.model'; -import { task } from '../../../../../__mocks__/task'; +import { By } from '@angular/platform-browser'; import { provideHttpClient } from '@angular/common/http'; import { provideHttpClientTesting } from '@angular/common/http/testing'; import { provideAnimations } from '@angular/platform-browser/animations'; -import { By } from '@angular/platform-browser'; +import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; +import { IncludeTaskFormComponent } from './include-task-form.component'; + + describe('IncludeTaskFormComponent', () => { let component: IncludeTaskFormComponent; diff --git a/src/app/features/task/components/inclusion-form/include-task-form/include-task-form.component.ts b/src/app/features/task/components/inclusion-form/include-task-form/include-task-form.component.ts index 6fb39a3..243d5ad 100644 --- a/src/app/features/task/components/inclusion-form/include-task-form/include-task-form.component.ts +++ b/src/app/features/task/components/inclusion-form/include-task-form/include-task-form.component.ts @@ -1,27 +1,17 @@ -import { FormGroup } from '@angular/forms'; -import { CategoryService } from './../../../../category/services/category.service'; -import { - ChangeDetectionStrategy, - Component, - computed, - DestroyRef, - inject, - OnInit, -} from '@angular/core'; - +import { ChangeDetectionStrategy, Component, computed, DestroyRef, inject } from '@angular/core'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { MatFormFieldModule } from '@angular/material/form-field'; import { MatIconModule } from '@angular/material/icon'; import { MatInputModule } from '@angular/material/input'; import { MatSelectChange, MatSelectModule } from '@angular/material/select'; -import { createTaskForm } from '../../../constants/create-task-form'; -import { Task } from '../../../model/task.model'; -import { TaskService } from '../../../service/task.service'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { delay, finalize } from 'rxjs/operators'; - import { NgClass } from '@angular/common'; -import { SnackBarService } from '../../../../../shared/services/snack-bar.service'; +import { CategoryService } from '@category/services/category.service'; +import { SnackBarService } from '@shared/services/snack-bar.service'; +import { createTaskForm } from '@features/task/constants/create-task-form'; +import { Task } from '@features/task/model/task.model'; +import { TaskService } from '@features/task/service/task.service'; const MODULES = [ @@ -33,11 +23,8 @@ const MODULES = [ ReactiveFormsModule, ]; -// const COMPONENTS: never[] = []; - const COMMONS = [NgClass]; - @Component({ selector: 'app-include-task-form', standalone: true, @@ -64,8 +51,7 @@ const COMMONS = [NgClass]; Categorias + >Categorias - +
diff --git a/src/app/features/task/components/no-tasks/no-tasks.component.ts b/src/app/features/task/components/no-tasks/no-tasks.component.ts new file mode 100644 index 0000000..3efa8b7 --- /dev/null +++ b/src/app/features/task/components/no-tasks/no-tasks.component.ts @@ -0,0 +1,18 @@ +import { Component, Input } from '@angular/core'; + +@Component({ + selector: 'app-no-task', + standalone: true, + template: ` +
+ + {{ message }} +
+ `, + styles: ``, +}) +export class NoTasksComponent { + @Input() public alt!: string; + @Input() public imageUrl!: string; + @Input() public message!: string; +} diff --git a/src/app/features/task/components/task-list/task-list.component.ts b/src/app/features/task/components/task-list/task-list.component.ts new file mode 100644 index 0000000..0d76c6c --- /dev/null +++ b/src/app/features/task/components/task-list/task-list.component.ts @@ -0,0 +1,77 @@ +import { Component, inject } from '@angular/core'; +import { TaskService } from '@features/task/service/task.service'; +import { AsyncPipe } from '@angular/common'; +import { NoTasksComponent } from '../no-tasks/no-tasks.component'; +import { Task } from '@features/task/model/task.model'; +import { CategoryService } from '@features/category/services/category.service'; +import { categoryTextColors } from '@features/category/constants/category-colors'; + +@Component({ + selector: 'app-task-list', + imports: [AsyncPipe, NoTasksComponent], + template: ` +
+ @if(tasks$ | async) { @if(numberOfTasks() > 0) { @for(task of tasks(); + track task.id) { +
+ + + + + @if(task.isCompleted) { + + }@else{ + + } + + + +
+ } } @else { + + } } +
+ `, + styles: ``, +}) +export class TaskListComponent { + private tasksService = inject(TaskService); + private categoryService = inject(CategoryService); + public tasks$ = this.tasksService.getTasks(); + public tasks = this.tasksService.tasks; + public category = this.categoryService.categories; + + public toggleTaskStatus(task: Task): void { + this.tasksService + .updateIsCompletedStatus(task.id, !task.isCompleted) + .subscribe(); + } + + // função para buscar cor com base na categoria da task + public getColorByTask(task: Task): string { + const cat = this.category().find( + (cat) => cat.id === task.categoryId + )?.color; + return cat || ''; + } + + public numberOfTasks = this.tasksService.numberOfTasks; + + public colorVariants = categoryTextColors; + public updateTask = this.tasksService.updateTaskInTheTasksList; + + public deleteTask(taskId: string): void { + this.tasksService.deleteTask(taskId).subscribe(); + } +} diff --git a/src/app/features/task/constants/create-task-form.ts b/src/app/features/task/constants/create-task-form.ts index 0ef621b..6e1ba87 100644 --- a/src/app/features/task/constants/create-task-form.ts +++ b/src/app/features/task/constants/create-task-form.ts @@ -1,4 +1,3 @@ -import { Task } from './../model/task.model'; import { inject } from "@angular/core"; import { FormControl, FormGroup, NonNullableFormBuilder, Validators } from "@angular/forms"; diff --git a/src/app/features/task/service/task.service.spec.ts b/src/app/features/task/service/task.service.spec.ts index 80c7be4..960ff75 100644 --- a/src/app/features/task/service/task.service.spec.ts +++ b/src/app/features/task/service/task.service.spec.ts @@ -1,9 +1,9 @@ -import { task, TASK_INTERNAL_SERVER_ERROR_RESPONSE, TASK_UNPROCESSIBLE_ENTITY_RESPONSE, tasks } from './../../../__mocks__/task'; import { TestBed, waitForAsync } from '@angular/core/testing'; import { HttpErrorResponse, provideHttpClient } from '@angular/common/http'; import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing'; import { TaskService } from './task.service'; import { Task } from '../model/task.model'; +import { task, TASK_INTERNAL_SERVER_ERROR_RESPONSE, TASK_UNPROCESSIBLE_ENTITY_RESPONSE, tasks } from '@mocks/task'; describe('TaskService', () => { let taskService: TaskService; diff --git a/src/app/features/task/service/task.service.ts b/src/app/features/task/service/task.service.ts index 8e07a31..2eac5f3 100644 --- a/src/app/features/task/service/task.service.ts +++ b/src/app/features/task/service/task.service.ts @@ -1,9 +1,9 @@ -import { Task } from './../model/task.model'; + import { HttpClient } from '@angular/common/http'; import { Injectable, computed, inject, signal } from '@angular/core'; -import { environment } from '../../../../env/environment.prod'; import { Observable, tap } from 'rxjs'; -import { setThrowInvalidWriteToSignalError } from '@angular/core/primitives/signals'; +import { environment } from '@env/environment.prod'; +import { Task } from '../model/task.model'; @Injectable({ providedIn: 'root', diff --git a/src/app/features/task/view/task/task.component.ts b/src/app/features/task/view/task/task.component.ts index 055279b..e705eed 100644 --- a/src/app/features/task/view/task/task.component.ts +++ b/src/app/features/task/view/task/task.component.ts @@ -1,13 +1,14 @@ import { ChangeDetectionStrategy, Component } from '@angular/core'; import { InclusionFormComponent } from '../../components/inclusion-form/inclusion-form.component'; +import { TaskListComponent } from "../../components/task-list/task-list.component"; -const COMPONENTS = [InclusionFormComponent]; +const COMPONENTS = [InclusionFormComponent, TaskListComponent]; @Component({ selector: 'app-task', standalone: true, - imports: [...COMPONENTS], + imports: [...COMPONENTS ], template: `
Meu quadro de tarefas @@ -16,6 +17,7 @@ const COMPONENTS = [InclusionFormComponent]; +
`, styles: ``, changeDetection: ChangeDetectionStrategy.OnPush, diff --git a/src/app/layout/main/main.component.ts b/src/app/layout/main/main.component.ts index 72515d2..aeb5fc2 100644 --- a/src/app/layout/main/main.component.ts +++ b/src/app/layout/main/main.component.ts @@ -1,7 +1,7 @@ import { ChangeDetectionStrategy, Component } from '@angular/core'; -import { CategoryComponent } from '../../features/category/view/category/category.component'; import { MatDivider } from '@angular/material/divider'; -import { TaskComponent } from '../../features/task/view/task/task.component'; +import { CategoryComponent } from '@features/category/view/category/category.component'; +import { TaskComponent } from '@features/task/view/task/task.component'; const COMPONENTS = [CategoryComponent, TaskComponent]; const MODULES = [MatDivider]; @@ -11,15 +11,15 @@ const MODULES = [MatDivider]; standalone: true, imports: [...COMPONENTS,...MODULES], template: ` -
+
- + - +
`, styles: ``, diff --git a/src/app/shared/components/theme-toggle/theme-toggle.component.ts b/src/app/shared/components/theme-toggle/theme-toggle.component.ts index 4494d23..31eb496 100644 --- a/src/app/shared/components/theme-toggle/theme-toggle.component.ts +++ b/src/app/shared/components/theme-toggle/theme-toggle.component.ts @@ -1,5 +1,6 @@ import { Component, inject } from '@angular/core'; -import { ThemeService } from '../../services/theme.service'; +import { ThemeService } from '@shared/services/theme.service'; + @Component({ selector: 'app-theme-toggle', diff --git a/tsconfig.json b/tsconfig.json index 4882a03..9f9ffec 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,6 +7,18 @@ "node", "jest" ], + "baseUrl": "./", + "paths": { + "@features/*": ["src/app/features/*"], + "@category/*": ["src/app/features/category/*"], + "@task/*": ["src/app/features/task/*"], + "@mocks/*": ["src/app/__mocks__/*"], + "@shared/*": ["src/app/shared/*"], + "@layout/*": ["src/app/layout/*"], + "@initializers/*": ["src/app/initializers/*"], + "@services/*": ["src/app/services/*"], + "@env/*": ["src/env/*"] + }, "outDir": "./dist/out-tsc", "strict": true, "noImplicitOverride": true,