code7-leia 0.1.13 → 0.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,12 +6,16 @@ import { useLocation } from 'react-router-dom';
6
6
 
7
7
  import type { FileData } from '../../interface/FileData'
8
8
 
9
+ import { getLanguage } from '../../utils/getLanguage'
10
+
9
11
  import * as S from './styles';
12
+ import Table from './components/Table';
10
13
 
11
14
  export const FileArea = () => {
12
15
  const [files, setFiles] = useState<FileData[]>([]);
13
16
  const { pathname } = useLocation();
14
17
  const id = pathname.split('/')[4]
18
+ const t = getLanguage('pt-br')
15
19
 
16
20
  useEffect(() => {
17
21
  setFiles([
@@ -35,29 +39,47 @@ export const FileArea = () => {
35
39
  }, [])
36
40
 
37
41
  useEffect(() => {
38
- console.log('files, id: ', files, id)
42
+ console.log('files, id, t: ', files, id, t)
39
43
  }, [files])
40
44
 
45
+ const presset = (tags: string): string => tags.split(',').map(tag => `<p class='tag'>${tag}</p>`).join('');
46
+
41
47
  const renderFiles = () => {
42
48
  if (files.length === 0) {
43
49
  return null;
44
50
  }
45
51
 
46
52
  return (
47
- <ul>
48
- {files.map(({ name, tags }, index) => (
49
- <li key={index}>
50
- <div>{name}</div>
51
- <div>{tags}</div>
52
- </li>
53
- ))}
54
- </ul>
53
+ <Table>
54
+ <thead>
55
+ <tr>
56
+ <th className="th_file_name">
57
+ {t.fileArea.fileName}
58
+ </th>
59
+ <th className="th_pressets">
60
+ {t.fileArea.presset}
61
+ </th>
62
+ <th className="th_actions">
63
+ {t.fileArea.actions}
64
+ </th>
65
+ </tr>
66
+ </thead>
67
+
68
+ <tbody>
69
+ {files.map((object) => (
70
+ <tr>
71
+ <td>{object.name}</td>
72
+ <td>{presset(object.tags)}</td>
73
+ <td>{t.buttons.delete}</td>
74
+ </tr>
75
+ ))}
76
+ </tbody>
77
+ </Table>
55
78
  );
56
79
  }
57
80
 
58
81
  return (
59
82
  <S.Container>
60
- <div>File Area</div>
61
83
  {renderFiles()}
62
84
  </S.Container>
63
85
  );
@@ -0,0 +1,42 @@
1
+ type FileArea = {
2
+ description: string;
3
+ fileName: string;
4
+ presset: string;
5
+ actions: string;
6
+ search: string;
7
+ fileUpload: string;
8
+ emptyState: {
9
+ title: string;
10
+ description: string;
11
+ };
12
+ modal: {
13
+ descriptionUpload: string;
14
+ chooseFile: string;
15
+ };
16
+ };
17
+
18
+ type Buttons = {
19
+ cancel: string;
20
+ send: string;
21
+ delete: string;
22
+ test: string;
23
+ };
24
+
25
+ type TestArea = {
26
+ description: string;
27
+ typeSentence: string;
28
+ selectPersona: string;
29
+ selectPresset: string;
30
+ emptyState: {
31
+ title: string;
32
+ description: string;
33
+ };
34
+ };
35
+
36
+ export type Language = {
37
+ files: string;
38
+ test: string;
39
+ fileArea: FileArea;
40
+ buttons: Buttons;
41
+ testArea: TestArea;
42
+ };
@@ -0,0 +1,12 @@
1
+ export interface TableProps {
2
+ children: React.ReactNode;
3
+ className?: string;
4
+ size?: 'small' | 'medium' | 'large';
5
+ isLoading?: boolean;
6
+ }
7
+
8
+ export interface SpinnerProps {
9
+ color?: string;
10
+ size?: 'sm' | 'md' | 'lg';
11
+ className?: string;
12
+ }
@@ -1,23 +1,128 @@
1
- type Language = {
2
- files: string;
3
- test: string;
1
+
2
+ import { Language } from '../interface/Language'
3
+
4
+ const defaultLanguage: Language = {
5
+ files: 'Files',
6
+ test: 'Test',
7
+ fileArea: {
8
+ description: 'bla bla bla bla bla',
9
+ fileName: 'File name',
10
+ presset: 'Presset',
11
+ actions: 'Actions',
12
+ search: 'Search',
13
+ fileUpload: 'File upload',
14
+ emptyState: {
15
+ title: 'No data',
16
+ description: 'bla bla bla bla bla',
17
+ },
18
+ modal: {
19
+ descriptionUpload: 'Drag and drop files here or',
20
+ chooseFile: 'Choose a file',
21
+ },
22
+ },
23
+ buttons: {
24
+ cancel: 'Cancel',
25
+ send: 'Send',
26
+ delete: 'Delete',
27
+ test: 'Test',
28
+ },
29
+ testArea: {
30
+ description: 'bla bla bla bla bla',
31
+ typeSentence: 'Type a sentence',
32
+ selectPersona: 'Select a Persona',
33
+ selectPresset: 'Select a presset',
34
+ emptyState: {
35
+ title: 'No data for analysis',
36
+ description: 'Do a search, click the "Test" button.',
37
+ },
38
+ },
4
39
  };
5
40
 
6
41
  export const getLanguage = (language: keyof Record<'en' | 'pt-br' | 'es', Language>): Language => {
7
- const languages: Record<'en' | 'pt-br' | 'es', Language> = {
8
- en: {
9
- files: 'Files',
10
- test: 'Test',
11
- },
42
+ const languages = {
43
+ en: defaultLanguage,
12
44
  'pt-br': {
13
45
  files: 'Arquivos',
14
46
  test: 'Teste',
47
+ fileArea: {
48
+ ...defaultLanguage.fileArea,
49
+ fileName: 'Nome do arquivo',
50
+ presset: 'Presset',
51
+ actions: 'Ações',
52
+ search: 'Pesquisar',
53
+ fileUpload: 'Upload de arquivo',
54
+ emptyState: {
55
+ ...defaultLanguage.fileArea.emptyState,
56
+ title: 'Sem dados',
57
+ },
58
+ modal: {
59
+ ...defaultLanguage.fileArea.modal,
60
+ descriptionUpload: 'Arraste e solte os arquivos aqui ou',
61
+ chooseFile: 'Escolha um arquivo',
62
+ },
63
+ },
64
+ buttons: {
65
+ ...defaultLanguage.buttons,
66
+ cancel: 'Cancelar',
67
+ send: 'Enviar',
68
+ delete: 'Excluir',
69
+ test: 'Testar',
70
+ },
71
+ testArea: {
72
+ ...defaultLanguage.testArea,
73
+ description: 'bla bla bla bla bla',
74
+ typeSentence: 'Digite uma frase',
75
+ selectPersona: 'Selecione uma Persona',
76
+ selectPresset: 'Selecione uma predefinição',
77
+ emptyState: {
78
+ ...defaultLanguage.testArea.emptyState,
79
+ title: 'Sem dados para análise',
80
+ description: 'Faça uma pesquisa, clique no botão "Teste".',
81
+ },
82
+ },
15
83
  },
16
84
  es: {
85
+ ...defaultLanguage,
17
86
  files: 'Archivos',
18
87
  test: 'Prueba',
19
- }
88
+ fileArea: {
89
+ ...defaultLanguage.fileArea,
90
+ fileName: 'Nombre del archivo',
91
+ presset: 'Presset',
92
+ actions: 'Acciones',
93
+ search: 'Buscar',
94
+ fileUpload: 'Carga de archivos',
95
+ emptyState: {
96
+ ...defaultLanguage.fileArea.emptyState,
97
+ title: 'Sin datos',
98
+ },
99
+ modal: {
100
+ ...defaultLanguage.fileArea.modal,
101
+ descriptionUpload: 'Arrastre y suelte los archivos aquí o',
102
+ chooseFile: 'Elegir un archivo',
103
+ },
104
+ },
105
+ buttons: {
106
+ ...defaultLanguage.buttons,
107
+ cancel: 'Cancelar',
108
+ send: 'Enviar',
109
+ delete: 'Eliminar',
110
+ test: 'Probar',
111
+ },
112
+ testArea: {
113
+ ...defaultLanguage.testArea,
114
+ description: 'bla bla bla bla bla',
115
+ typeSentence: 'Escribe una oración',
116
+ selectPersona: 'Seleccionar una Persona',
117
+ selectPresset: 'Seleccionar una configuración preestablecida',
118
+ emptyState: {
119
+ ...defaultLanguage.testArea.emptyState,
120
+ title: 'Sin datos para el análisis',
121
+ description: 'Realiza una búsqueda, haz clic en el botón "Prueba".',
122
+ },
123
+ },
124
+ },
20
125
  };
21
126
 
22
- return languages[language] || languages['pt-br'];
127
+ return languages[language] || defaultLanguage;
23
128
  };