refactor(challenge-1): augment challenge

Create city store
Camelcase some student and teacher interface's field to remove lint warnings
Move CardComponent's template to typescript file within decorator
This commit is contained in:
kabrunko-dev
2023-12-13 08:24:08 -03:00
parent 7e77b8a4a3
commit 89d9bf87fa
7 changed files with 61 additions and 38 deletions

View File

@@ -1,27 +0,0 @@
<div
class="border-2 border-black rounded-md p-4 w-fit flex flex-col gap-3"
[class]="customClass">
<img
*ngIf="type === CardType.TEACHER"
src="assets/img/teacher.png"
width="200px" />
<img
*ngIf="type === CardType.STUDENT"
src="assets/img/student.webp"
width="200px" />
<section>
<app-list-item
*ngFor="let item of list"
[name]="item.firstname"
[id]="item.id"
[type]="type">
</app-list-item>
</section>
<button
class="border border-blue-500 bg-blue-300 p-2 rounded-sm"
(click)="addNewItem()">
Add
</button>
</div>

View File

@@ -8,7 +8,34 @@ import { ListItemComponent } from '../list-item/list-item.component';
@Component({
selector: 'app-card',
templateUrl: './card.component.html',
template: `
<div
class="flex w-fit flex-col gap-3 rounded-md border-2 border-black p-4"
[class]="customClass">
<img
*ngIf="type === CardType.TEACHER"
src="assets/img/teacher.png"
width="200px" />
<img
*ngIf="type === CardType.STUDENT"
src="assets/img/student.webp"
width="200px" />
<section>
<app-list-item
*ngFor="let item of list"
[name]="item.firstName"
[id]="item.id"
[type]="type"></app-list-item>
</section>
<button
class="rounded-sm border border-blue-500 bg-blue-300 p-2"
(click)="addNewItem()">
Add
</button>
</div>
`,
standalone: true,
imports: [NgIf, NgFor, ListItemComponent],
})
@@ -21,7 +48,7 @@ export class CardComponent {
constructor(
private teacherStore: TeacherStore,
private studentStore: StudentStore
private studentStore: StudentStore,
) {}
addNewItem() {