Skip to content

Hamed R. - #3

Open
HamedRazizadeh-hub wants to merge 1 commit into
HackYourAssignment:mainfrom
HamedRazizadeh-hub:main
Open

HamedRazizadeh-hub wants to merge 1 commit into
HackYourAssignment:mainfrom
HamedRazizadeh-hub:main

Conversation

@HamedRazizadeh-hub

Copy link
Copy Markdown

No description provided.

Comment thread task-1/src/types.ts
Comment on lines +1 to +20
export interface Task {
id: string;
title: string;
description: string;
completed: boolean;
}

export type FilterStatus = "all" | "pending" | "completed";

export interface TaskHandlers {
onAdd(title: string, description: string): void;

onToggle(id: string): void;

onDelete(id: string): void;

onEdit(id: string, title: string, description: string): void;

onFilter(status: FilterStatus): void;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very good and an professional approach on creating types files to isolate your definitions! 👏

Comment thread task-1/src/types.ts
completed: boolean;
}

export type FilterStatus = "all" | "pending" | "completed";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a union type makes things more clear and not so generic as string. Good one!

Comment on lines +24 to +28
const form = root.querySelector<HTMLFormElement>(".todo-form")!;
const titleInput = root.querySelector<HTMLInputElement>("#title-input")!;
const descInput = root.querySelector<HTMLInputElement>("#desc-input")!;
const taskListEl = root.querySelector<HTMLUListElement>(".task-list")!;
this.filterBar = root.querySelector<HTMLDivElement>(".filter-bar")!;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good use on the DOM elements here!

Comment thread task-1/src/main.ts
Comment on lines +7 to +9
if (!root) {
throw new Error("Root element not found");
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a really good one! This secure that the application will need to have the proper #app element

Comment on lines +4 to +5
tasks: Task[] = [];
store: TaskStore;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you are using class here, I would recommend to use private here to not expose this property outside. Read more here in this documentation and about encapsulation

Comment on lines +6 to +7
root: HTMLElement;
handlers: TaskHandlers;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing as commented before about encapsulation

const task = tasks.find((t) => t.id === id);
for (const li of this.root.querySelectorAll<HTMLElement>(".task-item")) {
const id = li.dataset.id!;
const task = tasks.find((t) => t.id === id)!;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be better to have a early return here if task is undefined?

@rafasilpereira rafasilpereira added Reviewed This assignment has been reivewed by a mentor and a feedback has been provided and removed Review in progress labels May 25, 2026
@rafasilpereira

Copy link
Copy Markdown

The build generates asset paths as /assets/index.js (absolute), which breaks when dist/index.html is opened and that doesn't root at the project folder. Adding a vite.config.ts with base: './' fixes this so the built app works anywhere:

import { defineConfig } from 'vite'
export default defineConfig({
  base: './',
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Reviewed This assignment has been reivewed by a mentor and a feedback has been provided

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants