tycho-components 0.0.9-SNAPSHOT-2 → 0.0.10-SNAPSHOT

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,4 +6,15 @@ type Props = {
6
6
  onConfirm: () => void;
7
7
  };
8
8
  export default function AppModalRemove({ title, subtitle, onClose, onConfirm, }: Props): import("react/jsx-runtime").JSX.Element;
9
+ export declare const modalRemoveStyle: {
10
+ position: string;
11
+ top: string;
12
+ left: string;
13
+ transform: string;
14
+ width: string;
15
+ maxWidth: string;
16
+ borderRadius: string;
17
+ boxShadow: number;
18
+ bgcolor: string;
19
+ };
9
20
  export {};
@@ -5,9 +5,9 @@ import { Button, Icon } from 'tycho-storybook';
5
5
  import './style.scss';
6
6
  export default function AppModalRemove({ title, subtitle, onClose, onConfirm, }) {
7
7
  const { t } = useTranslation('common');
8
- return (_jsx(Modal, { open: true, children: _jsxs(Box, { className: "modal-container modal-remove", sx: style, children: [_jsxs("div", { className: "body", children: [_jsx(Icon, { name: "warning", size: "large", filled: true }), _jsxs("div", { className: "texts", children: [_jsx("span", { className: "title", children: title }), _jsx("span", { className: "subtitle", children: subtitle })] })] }), _jsxs("div", { className: "footer", children: [_jsx(Button, { onClick: onClose, text: t('button.cancel'), mode: "tonal" }), _jsx(Button, { onClick: onConfirm, text: t('button.confirm') })] })] }) }));
8
+ return (_jsx(Modal, { open: true, children: _jsxs(Box, { className: "modal-container modal-remove", sx: modalRemoveStyle, children: [_jsx("div", { className: "body", children: _jsxs("div", { className: "line", children: [_jsx(Icon, { name: "warning", size: "large", filled: true }), _jsxs("div", { className: "texts", children: [_jsx("span", { className: "title", children: title }), _jsx("span", { className: "subtitle", children: subtitle })] })] }) }), _jsxs("div", { className: "footer", children: [_jsx(Button, { onClick: onClose, text: t('button.cancel'), mode: "tonal" }), _jsx(Button, { onClick: onConfirm, text: t('button.confirm') })] })] }) }));
9
9
  }
10
- const style = {
10
+ export const modalRemoveStyle = {
11
11
  position: 'absolute',
12
12
  top: '40%',
13
13
  left: '50%',
@@ -40,24 +40,29 @@
40
40
  &.modal-remove {
41
41
  .body {
42
42
  display: flex;
43
- gap: 16px;
43
+ flex-direction: column;
44
44
 
45
- > .ds-icon {
46
- color: var(--icon-warning);
47
- }
48
-
49
- .texts {
45
+ > .line {
50
46
  display: flex;
51
- flex-direction: column;
47
+ gap: 16px;
52
48
 
53
- > .title {
54
- @include subtitle-medium-2;
55
- color: var(--text-primary);
49
+ > .ds-icon {
50
+ color: var(--icon-warning);
56
51
  }
57
52
 
58
- > .subtitle {
59
- @include body-medium-1;
60
- color: var(--text-secondary);
53
+ .texts {
54
+ display: flex;
55
+ flex-direction: column;
56
+
57
+ > .title {
58
+ @include subtitle-medium-2;
59
+ color: var(--text-primary);
60
+ }
61
+
62
+ > .subtitle {
63
+ @include body-medium-1;
64
+ color: var(--text-secondary);
65
+ }
61
66
  }
62
67
  }
63
68
  }
@@ -1,20 +1,26 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Box, Modal } from '@mui/material';
2
3
  import { useContext } from 'react';
3
4
  import { useTranslation } from 'react-i18next';
4
- import AppModalRemove from '../../AppModal/AppModalRemove';
5
+ import { Button, Icon, SelectField } from 'tycho-storybook';
6
+ import { modalRemoveStyle } from '../../AppModal/AppModalRemove';
5
7
  import CommonContext from '../../configs/CommonContext';
6
8
  import { useMessageUtils } from '../../configs/useMessageUtils';
7
9
  import ParticipantService from '../types/ParticipantService';
10
+ import { useForm } from 'react-hook-form';
8
11
  import './style.scss';
9
12
  export default function ParticipantRemove({ participant, participants, document, onClose, onChange, }) {
10
13
  const { t } = useTranslation('participants');
11
14
  const { state } = useContext(CommonContext);
12
- const { dispatchLoading, dispatchError } = useMessageUtils();
15
+ const { dispatchLoading } = useMessageUtils();
16
+ const createdForm = useForm({
17
+ mode: 'onChange',
18
+ });
13
19
  const handleRemove = () => {
14
20
  if (state.toastLoading || !participant)
15
21
  return;
16
22
  dispatchLoading(true);
17
- ParticipantService.remove(document, participant.code)
23
+ ParticipantService.remove(document, participant.code, createdForm.getValues().code)
18
24
  .then(() => {
19
25
  const list = participants?.filter((p) => p.code !== participant.code) || [];
20
26
  onChange(list);
@@ -23,5 +29,11 @@ export default function ParticipantRemove({ participant, participants, document,
23
29
  dispatchLoading(false);
24
30
  });
25
31
  };
26
- return (_jsx(AppModalRemove, { title: t('modal.remove.title'), subtitle: t('modal.remove.description'), onClose: onClose, onConfirm: handleRemove }));
32
+ let subtitle = t('modal.remove.description');
33
+ return (_jsx(Modal, { open: true, children: _jsxs(Box, { className: "modal-container modal-remove", sx: modalRemoveStyle, children: [_jsxs("div", { className: "body", children: [_jsxs("div", { className: "line", children: [_jsx(Icon, { name: "warning", size: "large", filled: true }), _jsxs("div", { className: "texts", children: [_jsx("span", { className: "title", children: t('modal.remove.title') }), _jsx("span", { className: "subtitle", children: subtitle })] })] }), participants.length !== 1 && (_jsxs("div", { className: "select-participant", children: [_jsxs("b", { children: [t('modal.remove.participant'), " ", participant.name, " (", participant.code, ")"] }), _jsx(SelectField, { label: t('modal.select.transfer'), attr: "code", createdForm: createdForm, options: participants
34
+ .filter((p) => p.code !== participant.code)
35
+ .map((p) => ({
36
+ value: p.code,
37
+ label: `${p.code} - ${p.name}`,
38
+ })), showEndAdornment: false })] }))] }), _jsxs("div", { className: "footer", children: [_jsx(Button, { onClick: onClose, text: t('common:button.cancel'), mode: "tonal" }), _jsx(Button, { onClick: handleRemove, text: t('common:button.confirm') })] })] }) }));
27
39
  }
@@ -1,32 +1,15 @@
1
- .participants-container {
2
- .header {
3
- display: flex;
4
- background-color: var(--color-secondary);
5
- padding: 8px 16px;
6
-
7
- .actions {
8
- margin-left: auto;
9
- margin-top: auto;
10
- margin-bottom: auto;
11
-
12
- .action {
13
- border: var(--border-default);
14
- padding: 0px 16px;
1
+ .modal-container {
2
+ &.modal-remove {
3
+ .body {
4
+ .select-participant {
5
+ border-top: 1px solid var(--border-subtle-1);
6
+ padding-top: 16px;
7
+ margin-top: 16px;
8
+
9
+ > .ds-select-text {
10
+ margin-top: 16px;
11
+ }
15
12
  }
16
13
  }
17
14
  }
18
-
19
- .body {
20
- height: 90vh;
21
- overflow-y: auto;
22
- padding: var(--spacing-small);
23
- }
24
-
25
- .footer {
26
- margin-top: 16px;
27
- padding-top: 16px;
28
- display: flex;
29
- justify-content: right;
30
- border-top: var(--border-default);
31
- }
32
15
  }
@@ -4,6 +4,7 @@ type Props = {
4
4
  document: string;
5
5
  onChange: (p: Participant[]) => void;
6
6
  participants: Participant[];
7
+ useChat?: boolean;
7
8
  };
8
- export default function Participants({ document, participants, onChange, }: Props): import("react/jsx-runtime").JSX.Element;
9
+ export default function Participants({ document, participants, onChange, useChat, }: Props): import("react/jsx-runtime").JSX.Element;
9
10
  export {};
@@ -1,20 +1,18 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { faPlus, faTrash } from '@fortawesome/free-solid-svg-icons';
3
3
  import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
4
- import { useContext, useEffect, useState } from 'react';
4
+ import { useEffect, useState } from 'react';
5
5
  import { Button, Form } from 'react-bootstrap';
6
6
  import { useTranslation } from 'react-i18next';
7
7
  import AppEditable from '../AppEditable';
8
- import CommonContext from '../configs/CommonContext';
8
+ import { useMessageUtils } from '../configs/useMessageUtils';
9
9
  import ParticipantCreate from './ParticipantCreate';
10
10
  import ParticipantRemove from './ParticipantRemove';
11
11
  import './style.scss';
12
- import { PARTICIPANT_FIELDS } from './types/Participant';
12
+ import { CHAT_FIELDS, PARTICIPANT_FIELDS, } from './types/Participant';
13
13
  import ParticipantService from './types/ParticipantService';
14
- import { useMessageUtils } from '../configs/useMessageUtils';
15
- export default function Participants({ document, participants, onChange, }) {
14
+ export default function Participants({ document, participants, onChange, useChat, }) {
16
15
  const { t } = useTranslation('participants');
17
- const { dispatch } = useContext(CommonContext);
18
16
  const { dispatchMessage } = useMessageUtils();
19
17
  const [participant, setParticipant] = useState();
20
18
  const [openRemove, setOpenRemove] = useState(false);
@@ -44,7 +42,7 @@ export default function Participants({ document, participants, onChange, }) {
44
42
  }, []);
45
43
  return (_jsxs("div", { className: "participants-container", children: [_jsxs("div", { className: "header", children: [_jsx("h3", { children: t('label.title') }), _jsx("div", { className: "actions", children: _jsxs("button", { type: "button", className: "action", onClick: () => setOpenCreate(true), children: [_jsx(FontAwesomeIcon, { icon: faPlus, title: t('button.label.add') }), _jsx("span", { className: "ms-2", children: t('button.label.add') })] }) })] }), _jsx("div", { className: "body", children: participant && (_jsxs(_Fragment, { children: [_jsx(Form.Select, { onChange: (e) => setParticipant(participants[Number(e.target.value)]), value: participant
46
44
  ? participants.findIndex((p) => p.code === participant.code)
47
- : 0, children: participants.map((el, idx) => (_jsx("option", { value: idx, children: `${el.code} - ${el.name}` }, idx))) }), _jsx(AppEditable, { translation: "participants", group: "participant", save: handleSave, item: { ...participant, uid: document }, fields: PARTICIPANT_FIELDS, className: "fields", reference: "code" }), _jsx("div", { className: "footer", children: _jsxs(Button, { variant: "danger", onClick: () => {
45
+ : 0, children: participants.map((el, idx) => (_jsx("option", { value: idx, children: `${el.code} - ${el.name}` }, idx))) }), _jsx(AppEditable, { translation: "participants", group: "participant", save: handleSave, item: { ...participant, uid: document }, fields: PARTICIPANT_FIELDS, className: "fields", reference: "code" }), useChat && (_jsx(AppEditable, { translation: "participants", group: "participant", save: handleSave, item: { ...participant, uid: document }, fields: CHAT_FIELDS, className: "fields", reference: "code" })), _jsx("div", { className: "footer", children: _jsxs(Button, { variant: "danger", onClick: () => {
48
46
  setParticipant(participant);
49
47
  setOpenRemove(true);
50
48
  }, children: [_jsx(FontAwesomeIcon, { icon: faTrash }), _jsx("span", { className: "ms-1", children: t('common:button.remove') })] }) })] })) }), participant && openRemove && (_jsx(ParticipantRemove, { document: document, onChange: (list) => {
@@ -24,4 +24,5 @@ export declare const EMPTY_PARTICIPANT: {
24
24
  name: string;
25
25
  };
26
26
  export declare const PARTICIPANT_FIELDS: FormField[];
27
+ export declare const CHAT_FIELDS: FormField[];
27
28
  export default Participant;
@@ -15,3 +15,13 @@ export const PARTICIPANT_FIELDS = [
15
15
  tooltip: 'field.color.tooltip',
16
16
  },
17
17
  ];
18
+ export const CHAT_FIELDS = [
19
+ { name: 'language', type: 'text', required: false },
20
+ { name: 'age', type: 'text', required: false },
21
+ { name: 'sex', type: 'text', required: false },
22
+ { name: 'group', type: 'text', required: false },
23
+ { name: 'ses', type: 'text', required: false },
24
+ { name: 'role', type: 'text', required: false },
25
+ { name: 'education', type: 'text', required: false },
26
+ { name: 'custom', type: 'text', required: false },
27
+ ];
@@ -2,7 +2,7 @@ import AppEditableField from '../../AppEditable/AppEditableField';
2
2
  import Participant, { ParticipantCreateRequest } from './Participant';
3
3
  declare function add(uid: string, request: ParticipantCreateRequest): Promise<import("axios").AxiosResponse<Participant, any>>;
4
4
  declare function update(field: AppEditableField): Promise<import("axios").AxiosResponse<any, any>>;
5
- declare function remove(document: string, code: string): Promise<import("axios").AxiosResponse<any, any>>;
5
+ declare function remove(document: string, code: string, transfer?: string): Promise<import("axios").AxiosResponse<any, any>>;
6
6
  declare const ParticipantService: {
7
7
  add: typeof add;
8
8
  update: typeof update;
@@ -5,8 +5,12 @@ function add(uid, request) {
5
5
  function update(field) {
6
6
  return api.patch(`${import.meta.env.VITE_APP_CATALOG_API}/participant/update`, field);
7
7
  }
8
- function remove(document, code) {
9
- return api.delete(`${import.meta.env.VITE_APP_CATALOG_API}/participant/${document}/${code}`);
8
+ function remove(document, code, transfer) {
9
+ const request = {
10
+ code,
11
+ transfer,
12
+ };
13
+ return api.delete(`${import.meta.env.VITE_APP_CATALOG_API}/participant/${document}`, { data: request });
10
14
  }
11
15
  const ParticipantService = { add, update, remove };
12
16
  export default ParticipantService;
@@ -22,12 +22,21 @@ export declare const commonResources: {
22
22
  'participant.field.color': string;
23
23
  'participant.field.separator': string;
24
24
  'participant.field.color.tooltip': string;
25
+ 'participant.field.language': string;
26
+ 'participant.field.age': string;
27
+ 'participant.field.sex': string;
28
+ 'participant.field.group': string;
29
+ 'participant.field.ses': string;
30
+ 'participant.field.role': string;
31
+ 'participant.field.education': string;
32
+ 'participant.field.custom': string;
25
33
  'modal.remove.title': string;
26
34
  'modal.remove.description': string;
27
35
  'modal.remove.participant': string;
28
36
  'modal.add.title': string;
29
37
  'modal.input.code': string;
30
38
  'modal.input.name': string;
39
+ 'modal.select.transfer': string;
31
40
  'participant.code.exists': string;
32
41
  };
33
42
  };
@@ -53,6 +62,14 @@ export declare const commonResources: {
53
62
  'participant.field.color': string;
54
63
  'participant.field.separator': string;
55
64
  'participant.field.color.tooltip': string;
65
+ 'participant.field.language': string;
66
+ 'participant.field.age': string;
67
+ 'participant.field.sex': string;
68
+ 'participant.field.group': string;
69
+ 'participant.field.ses': string;
70
+ 'participant.field.role': string;
71
+ 'participant.field.education': string;
72
+ 'participant.field.custom': string;
56
73
  'modal.remove.title': string;
57
74
  'modal.remove.description': string;
58
75
  'modal.remove.participant': string;
@@ -8,12 +8,21 @@ export declare const ParticipantsTexts: {
8
8
  'participant.field.color': string;
9
9
  'participant.field.separator': string;
10
10
  'participant.field.color.tooltip': string;
11
+ 'participant.field.language': string;
12
+ 'participant.field.age': string;
13
+ 'participant.field.sex': string;
14
+ 'participant.field.group': string;
15
+ 'participant.field.ses': string;
16
+ 'participant.field.role': string;
17
+ 'participant.field.education': string;
18
+ 'participant.field.custom': string;
11
19
  'modal.remove.title': string;
12
20
  'modal.remove.description': string;
13
21
  'modal.remove.participant': string;
14
22
  'modal.add.title': string;
15
23
  'modal.input.code': string;
16
24
  'modal.input.name': string;
25
+ 'modal.select.transfer': string;
17
26
  'participant.code.exists': string;
18
27
  };
19
28
  'pt-BR': {
@@ -25,6 +34,14 @@ export declare const ParticipantsTexts: {
25
34
  'participant.field.color': string;
26
35
  'participant.field.separator': string;
27
36
  'participant.field.color.tooltip': string;
37
+ 'participant.field.language': string;
38
+ 'participant.field.age': string;
39
+ 'participant.field.sex': string;
40
+ 'participant.field.group': string;
41
+ 'participant.field.ses': string;
42
+ 'participant.field.role': string;
43
+ 'participant.field.education': string;
44
+ 'participant.field.custom': string;
28
45
  'modal.remove.title': string;
29
46
  'modal.remove.description': string;
30
47
  'modal.remove.participant': string;
@@ -8,12 +8,21 @@ export const ParticipantsTexts = {
8
8
  'participant.field.color': 'Color',
9
9
  'participant.field.separator': 'Separator',
10
10
  'participant.field.color.tooltip': 'A color for transcription visual identifier',
11
+ 'participant.field.language': 'Language',
12
+ 'participant.field.age': 'Age',
13
+ 'participant.field.sex': 'Sex',
14
+ 'participant.field.group': 'Group',
15
+ 'participant.field.ses': 'SES',
16
+ 'participant.field.role': 'Role',
17
+ 'participant.field.education': 'Education',
18
+ 'participant.field.custom': 'Custom',
11
19
  'modal.remove.title': 'Remove participant',
12
20
  'modal.remove.description': 'Are you sure you want to delete this participant? This action is irreversible, but the sentences are not deleted.',
13
21
  'modal.remove.participant': 'You can choose a participant to transfer sentences related to ',
14
22
  'modal.add.title': 'Add new participant',
15
23
  'modal.input.code': 'ID',
16
24
  'modal.input.name': 'Name',
25
+ 'modal.select.transfer': 'Participant',
17
26
  'participant.code.exists': 'The participant code provided is already in use.',
18
27
  },
19
28
  'pt-BR': {
@@ -25,6 +34,14 @@ export const ParticipantsTexts = {
25
34
  'participant.field.color': 'Cor',
26
35
  'participant.field.separator': 'Separador',
27
36
  'participant.field.color.tooltip': 'Cor para identificação visual da sentença na transcrição',
37
+ 'participant.field.language': 'Língua',
38
+ 'participant.field.age': 'Idade',
39
+ 'participant.field.sex': 'Gênero',
40
+ 'participant.field.group': 'Grupo',
41
+ 'participant.field.ses': 'SES',
42
+ 'participant.field.role': 'Papel',
43
+ 'participant.field.education': 'Educação',
44
+ 'participant.field.custom': 'Outros',
28
45
  'modal.remove.title': 'Remover participante',
29
46
  'modal.remove.description': 'Você tem certeza que deseja remover este participante? Esta ação é irreversível, porém as sentenças não serão excluídas.',
30
47
  'modal.remove.participant': 'Você pode escolher um participante para transferir frases relacionadas a ',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tycho-components",
3
3
  "private": false,
4
- "version": "0.0.9-SNAPSHOT-2",
4
+ "version": "0.0.10-SNAPSHOT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {