Skip to content

Commit 069a7be

Browse files
committed
adding task counter
1 parent cf1c391 commit 069a7be

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

src/api/ProjectAPI.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ export async function createProject( formData : ProjectFormData ) {
1919

2020
export async function getProjects() {
2121
try {
22-
const { data } = await api('/projects')
22+
const { data } = await api('/projects')
2323
const response = dashboardProjectSchema.safeParse(data)
24+
console.log({response});
25+
2426
if(response.success) return response.data
2527
} catch (error) {
2628
if( isAxiosError(error) && error.response){

src/types/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,19 @@ export const projectSchema = z.object({
2222
_id: z.string(),
2323
projectName: z.string(),
2424
clientName: z.string(),
25-
description: z.string()
25+
description: z.string(),
26+
tasks: z.array( z.object() )
2627
})
2728

2829
export const dashboardProjectSchema = z.array(
2930
projectSchema.pick({
3031
_id: true,
3132
projectName: true,
3233
clientName: true,
33-
description: true
34+
description: true,
35+
tasks: true
3436
})
3537
)
3638

3739
export type Project = z.infer<typeof projectSchema>
38-
export type ProjectFormData = Pick<Project , 'clientName' | 'projectName' | 'description' >
40+
export type ProjectFormData = Pick<Project , 'clientName' | 'projectName' | 'description' | 'tasks' >

src/views/DashboardView.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default function DashboardView() {
1313
queryKey:['projects'],
1414
queryFn: getProjects
1515
})
16-
16+
1717
const queryClient = useQueryClient()
1818
const { mutate } = useMutation({
1919
mutationFn: deleteProject,
@@ -59,7 +59,10 @@ if(data) return (
5959
Cliente: {project.clientName}
6060
</p>
6161
<p className="text-sm text-gray-400">
62-
{project.description}
62+
Descripcion: {project.description}
63+
</p>
64+
<p className="text-sm text-gray-400">
65+
Tareas: {project.tasks.length}
6366
</p>
6467
</div>
6568
</div>

0 commit comments

Comments
 (0)