fix: corrige tipos e testes
Some checks are pending
Docker Build and Push / build (push) Waiting to run

- Refatora interfaces do banco de dados com BaseEntity

- Corrige conflitos de tipos em email, status e cover

- Padroniza tipos de campos em todas as interfaces

- Corrige erro no teste do WordHighlighter

- Atualiza CHANGELOG.md
This commit is contained in:
Lucas Santana 2025-01-11 07:55:58 -03:00
parent 9b023e7ef9
commit 1ea1b3e841
3 changed files with 93 additions and 152 deletions

View File

@ -5,6 +5,19 @@ Todas as mudanças notáveis neste projeto serão documentadas neste arquivo.
O formato é baseado em [Keep a Changelog](https://keepachangelog.com/pt-BR/1.0.0/),
e este projeto adere ao [Semantic Versioning](https://semver.org/lang/pt-BR/).
## [1.1.1] - 2024-01-17
### Técnico
- Refatoração das interfaces do banco de dados:
- Criada interface base `BaseEntity` para reduzir duplicação
- Corrigidos conflitos de tipos em `email`, `status` e `cover`
- Padronizados os tipos de campos em todas as interfaces
- Corrigidas as interfaces `ClassWithStudents` e `ClassWithStudentsAndStories`
- Melhorada a organização do código com herança de interfaces
- Corrigido erro no teste do `WordHighlighter`:
- Adicionada importação do `beforeEach` do Vitest
- Mantida a estrutura dos testes existentes
## [1.1.0] - 2024-01-17
### Adicionado

View File

@ -1,6 +1,6 @@
import { render, screen, fireEvent } from '@testing-library/react'
import { WordHighlighter } from './WordHighlighter'
import { describe, it, expect, vi } from 'vitest'
import { describe, it, expect, vi, beforeEach } from 'vitest'
import '@testing-library/jest-dom/vitest'
describe('WordHighlighter', () => {

View File

@ -1,37 +1,41 @@
export interface School {
// Interfaces Base
export interface BaseEntity {
id: string;
name: string;
address?: string;
phone?: string;
email?: string;
created_at: string;
updated_at: string;
}
export interface Teacher {
id: string;
export interface School extends BaseEntity {
name: string;
email: string;
phone?: string;
address?: string;
city?: string;
state?: string;
zip_code?: string;
director_name?: string;
}
export interface Teacher extends BaseEntity {
school_id: string;
name: string;
email: string;
phone?: string;
subject?: string;
created_at: string;
updated_at: string;
}
export interface Class {
id: string;
export interface Class extends BaseEntity {
school_id: string;
name: string;
grade: string;
year: number;
period?: string;
created_at: string;
updated_at: string;
students?: {
count: number;
};
}
export interface Student {
id: string;
export interface Student extends BaseEntity {
class_id: string;
school_id: string;
name: string;
@ -40,11 +44,8 @@ export interface Student {
guardian_name?: string;
guardian_phone?: string;
guardian_email?: string;
created_at: string;
updated_at: string;
status?: string;
avatar_url?: string;
// Relacionamentos
status: 'active' | 'inactive';
class?: {
id: string;
name: string;
@ -54,13 +55,60 @@ export interface Student {
id: string;
name: string;
};
interests?: Interest[];
}
export interface TeacherClass {
id: string;
export interface TeacherClass extends BaseEntity {
teacher_id: string;
class_id: string;
created_at: string;
}
export interface StoryPage {
text: string;
image?: string;
audio?: string;
}
export interface Story extends BaseEntity {
student_id: string;
class_id: string;
school_id: string;
title: string;
theme: string;
content: {
pages: StoryPage[];
currentPage?: number;
lastModified?: string;
};
status: 'draft' | 'published' | 'archived';
cover: {
id: string;
image_url: string;
};
students?: {
name: string;
};
}
export interface StoryRecording extends BaseEntity {
fluency_score: number;
pronunciation_score: number;
accuracy_score: number;
comprehension_score: number;
words_per_minute: number;
pause_count: number;
error_count: number;
self_corrections: number;
strengths: string[];
improvements: string[];
suggestions: string;
processed_at: string | null;
}
export interface Interest extends BaseEntity {
student_id: string;
category: string;
items: string[];
}
// Tipos para relacionamentos
@ -77,7 +125,15 @@ export interface TeacherWithClassesAndStories extends Teacher {
}
export interface ClassWithStudents extends Class {
students: Student[];
students: Student[] & { count: number };
}
export interface StudentWithStories extends Student {
stories: Story[];
}
export interface ClassWithStudentsAndStories extends Class {
students: StudentWithStories[] & { count: number };
}
// Interface base para School com relações
@ -85,144 +141,16 @@ interface BaseSchoolWithRelations extends School {
teachers: Teacher[];
}
// Interface específica para School com Classes e Students
export interface SchoolWithClasses extends BaseSchoolWithRelations {
classes: ClassWithStudents[];
}
// Interface específica para School com Classes, Students e Stories
export interface SchoolWithClassesAndStories extends BaseSchoolWithRelations {
classes: ClassWithStudentsAndStories[];
}
// Removendo a interface duplicada e usando as novas interfaces específicas
export type SchoolWithRelations = SchoolWithClasses | SchoolWithClassesAndStories;
export interface StoryPage {
text: string;
image?: string;
audio?: string;
}
export interface Story {
cover: any;
id: string;
student_id: string;
class_id: string;
school_id: string;
title: string;
theme: string;
content: {
pages: StoryPage[];
currentPage?: number;
lastModified?: string;
};
status: 'draft' | 'published' | 'archived';
created_at: string;
updated_at: string;
}
// Atualizando a interface Student para incluir histórias
export interface StudentWithStories extends Student {
stories: Story[];
}
// Atualizando ClassWithStudents para incluir histórias dos alunos
export interface ClassWithStudentsAndStories extends Class {
students: StudentWithStories[];
}
export interface StoryRecording {
id: string;
fluency_score: number;
pronunciation_score: number;
accuracy_score: number;
comprehension_score: number;
words_per_minute: number;
pause_count: number;
error_count: number;
self_corrections: number;
strengths: string[];
improvements: string[];
suggestions: string;
created_at: string;
processed_at: string | null;
}
export interface Interest {
id: string;
student_id: string;
category: string;
items: string[];
created_at: string;
updated_at: string;
}
export interface Student {
id: string;
name: string;
email: string;
avatar_url?: string;
class_id: string;
school_id: string;
status: 'active' | 'inactive';
created_at: string;
updated_at: string;
interests?: Interest[];
class?: {
id: string;
name: string;
grade: string;
};
school?: {
id: string;
name: string;
};
}
export interface Story {
id: string;
title: string;
content: string;
student_id: string;
status: 'draft' | 'published';
created_at: string;
updated_at: string;
cover?: {
id: string;
image_url: string;
};
students?: {
name: string;
};
}
export interface Class {
id: string;
name: string;
grade: string;
school_id: string;
created_at: string;
updated_at: string;
students?: {
count: number;
};
}
export interface School {
id: string;
name: string;
email: string;
phone?: string;
address?: string;
city?: string;
state?: string;
zip_code?: string;
director_name?: string;
created_at: string;
updated_at: string;
}
export interface SchoolSettings {
name: string;
email: string;