@autobusal/common 0.0.41 → 1.0.1

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.
Files changed (56) hide show
  1. package/ApiDetails/ApiDetails.tsx +1 -1
  2. package/ApiDetails/Content.tsx +9 -5
  3. package/ApiDetails/Devpos.tsx +26 -26
  4. package/ApiDetails/services.ts +4 -3
  5. package/Autocomplete/Autocomplete.tsx +3 -3
  6. package/Avatar.tsx +2 -2
  7. package/{BackTo.tsx → Back/BackTo.tsx} +3 -26
  8. package/Back/BackWithTitle.tsx +30 -0
  9. package/Button/Button.tsx +4 -2
  10. package/Calendar/Calendar.tsx +2 -2
  11. package/{BrowseCompanyItem/BrowseCompanyItem.tsx → CompanyItem/CompanyItem.tsx} +2 -2
  12. package/CookieNotification/CookieNotification.tsx +2 -2
  13. package/File/File.tsx +4 -4
  14. package/IpLogs/IpLogs.tsx +3 -3
  15. package/IpLogs/View.tsx +5 -5
  16. package/IpLogs/services.ts +2 -2
  17. package/Loading/Loading.tsx +19 -29
  18. package/Loading/Paragraph.tsx +62 -0
  19. package/Loading/styles.ts +35 -5
  20. package/Meta.tsx +1 -1
  21. package/Modal/Modal.tsx +2 -3
  22. package/Pagination/Pagination.tsx +1 -1
  23. package/Passengers/Passengers.tsx +6 -5
  24. package/Passengers/Persons.tsx +7 -7
  25. package/Passengers/{utilities/getText.ts → utilities.ts} +3 -5
  26. package/Password/Password.tsx +2 -2
  27. package/Password/styles.ts +1 -1
  28. package/Policy/services.ts +1 -3
  29. package/Report/Send.tsx +5 -8
  30. package/Report/services.ts +3 -2
  31. package/Report/types.ts +3 -0
  32. package/RouteItem/styles.ts +0 -1
  33. package/Seats/ChooseSeat.tsx +2 -2
  34. package/Seats/Preview.tsx +1 -1
  35. package/Table/Header/Header.tsx +1 -1
  36. package/Table/Header/Sort.tsx +2 -2
  37. package/Table/Paginate.tsx +2 -2
  38. package/Table/Row.tsx +5 -3
  39. package/Table/Rows/Loading.tsx +1 -1
  40. package/Table/Rows/Rows.tsx +5 -4
  41. package/Table/Rows/styles.ts +6 -0
  42. package/Table/Table.tsx +5 -3
  43. package/Table/browseUrl.ts +2 -2
  44. package/Viewer/Actions.tsx +4 -4
  45. package/Viewer/Data.tsx +15 -14
  46. package/Viewer/Item.tsx +2 -2
  47. package/Viewer/Items/CheckboxList.tsx +1 -1
  48. package/Viewer/Items/DatePicker.tsx +2 -2
  49. package/Viewer/Items/Dropdown.tsx +5 -9
  50. package/Viewer/Items/TextareaHtml.tsx +3 -3
  51. package/Viewer/Items/styles.ts +1 -1
  52. package/Viewer/Viewer.tsx +4 -4
  53. package/Viewer/types.ts +1 -1
  54. package/index.ts +15 -9
  55. package/package.json +1 -1
  56. /package/{BrowseCompanyItem → CompanyItem}/styles.ts +0 -0
package/Meta.tsx CHANGED
@@ -4,7 +4,7 @@ interface Props {
4
4
  title: string
5
5
  keywords?: string
6
6
  description?: string
7
- children: JSX.Element | JSX.Element[] | string | null | false | boolean
7
+ children: any
8
8
  }
9
9
 
10
10
  const Meta = ({ title, keywords, description, children }: Props): JSX.Element => (
package/Modal/Modal.tsx CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AiOutlineClose } from 'react-icons/ai';
2
2
  import { useOverflow } from '@autobusal/hooks';
3
- import { Paragraph } from '../Loading/Loading';
3
+ import Paragraph from '../Loading/Paragraph';
4
4
  import { Background, Container, Title, ButtonClose } from './styles';
5
5
 
6
6
  interface Props {
@@ -28,8 +28,7 @@ const Modal = ({ loading, width, title, content, onClose }: Props): JSX.Element
28
28
  </ButtonClose>
29
29
  </Title>
30
30
 
31
- {/* { loading ? <Paragraph /> : content } */}
32
- <Paragraph />
31
+ { loading ? <Paragraph /> : content }
33
32
  </Container>
34
33
  </>
35
34
  );
@@ -1,6 +1,6 @@
1
1
  import { TFunction } from 'i18next';
2
2
  import { Container, Left, Right, PageText, PageLink } from './styles';
3
- import { PaginationData } from '@modules/Providers/types/pagination';
3
+ import { PaginationData } from '@autobusal/providers/types/pagination';
4
4
 
5
5
  interface Props {
6
6
  pages: PaginationData<unknown>
@@ -2,8 +2,8 @@ import { useState, useEffect, useRef } from 'react';
2
2
  import { TFunction } from 'i18next';
3
3
  import { UseFormRegister, UseFormSetValue } from 'react-hook-form';
4
4
  import { useOutside } from '@autobusal/hooks';
5
- import getText from './utilities/getText';
6
5
  import Persons from './Persons';
6
+ import { getText } from './utilities';
7
7
  import { Container } from './styles';
8
8
 
9
9
  interface Props {
@@ -28,8 +28,9 @@ const Passengers = ({ defaultAdults, defaultChildren, defaultBabies, t, refs, on
28
28
 
29
29
  useEffect(() => {
30
30
  const text = getText(adults, children, babies, t);
31
+
31
32
  setDisplay(text);
32
- }, [adults, children, babies]);
33
+ }, [adults, children, babies, t]);
33
34
 
34
35
  useOutside(ref, () => setShow(false));
35
36
 
@@ -57,9 +58,9 @@ const Passengers = ({ defaultAdults, defaultChildren, defaultBabies, t, refs, on
57
58
 
58
59
  { show &&
59
60
  <Persons
60
- adults={ adults }
61
- children={ children }
62
- babies={ babies }
61
+ adultsNo={ adults }
62
+ childrenNo={ children }
63
+ babiesNo={ babies }
63
64
  t={ t }
64
65
  onChange={ onChange }
65
66
  /> }
@@ -3,20 +3,20 @@ import Person from './Person';
3
3
  import { Passengers } from './styles';
4
4
 
5
5
  interface Props {
6
- adults: number
7
- children: number
8
- babies: number
6
+ adultsNo: number
7
+ childrenNo: number
8
+ babiesNo: number
9
9
  t: TFunction<'common'>
10
10
  onChange: (name: ('adults' | 'children' | 'babies'), amount: number) => void
11
11
  }
12
12
 
13
- const Persons = ({ adults, children, babies, t, onChange }: Props): JSX.Element => (
13
+ const Persons = ({ adultsNo, childrenNo, babiesNo, t, onChange }: Props): JSX.Element => (
14
14
  <Passengers>
15
15
  <Person
16
16
  name="adults"
17
17
  title={ t('data.persons.adult.plural', { ns: 'common' }) }
18
18
  description={ t('data.persons.adult.description', { ns: 'common' }) }
19
- amount={ adults }
19
+ amount={ adultsNo }
20
20
  onChange={ onChange }
21
21
  />
22
22
 
@@ -24,7 +24,7 @@ const Persons = ({ adults, children, babies, t, onChange }: Props): JSX.Element
24
24
  name="children"
25
25
  title={ t('data.persons.child.plural', { ns: 'common' }) }
26
26
  description={ t('data.persons.child.description', { ns: 'common' }) }
27
- amount={ children }
27
+ amount={ childrenNo }
28
28
  onChange={ onChange }
29
29
  />
30
30
 
@@ -32,7 +32,7 @@ const Persons = ({ adults, children, babies, t, onChange }: Props): JSX.Element
32
32
  name="babies"
33
33
  title={ t('data.persons.baby.plural', { ns: 'common' }) }
34
34
  description={ t('data.persons.baby.description', { ns: 'common' }) }
35
- amount={ babies }
35
+ amount={ babiesNo }
36
36
  onChange={ onChange }
37
37
  />
38
38
  </Passengers>
@@ -1,7 +1,7 @@
1
1
  import { TFunction } from 'i18next';
2
2
 
3
- const getText = (adults: number, children: number, babies: number, t: TFunction<'common'>): string => {
4
- let final = [];
3
+ export const getText = (adults: number, children: number, babies: number, t: TFunction<'common'>): string => {
4
+ const final = [];
5
5
 
6
6
  if (adults > 0) {
7
7
  final.push(`${ t('data.persons.adult.plural', { ns: 'common' }) }: ${ adults }`);
@@ -16,6 +16,4 @@ const getText = (adults: number, children: number, babies: number, t: TFunction<
16
16
  }
17
17
 
18
18
  return final.join(', ');
19
- };
20
-
21
- export default getText;
19
+ };
@@ -2,7 +2,7 @@ import { useState } from 'react';
2
2
  import { TFunction } from 'i18next';
3
3
  import { UseFormRegister } from 'react-hook-form';
4
4
  import { AiFillEye, AiFillEyeInvisible } from 'react-icons/ai';
5
- import { validate } from '@autobusal/utilities';
5
+ import { Validate } from '@autobusal/utilities';
6
6
  import { Container } from './styles';
7
7
 
8
8
  interface Props {
@@ -22,7 +22,7 @@ const Password = ({ name, tabIndex, validation, t, refs }: Props): JSX.Element =
22
22
 
23
23
  return (
24
24
  <Container>
25
- <input type={ show ? 'text' : 'password' } tabIndex={ tabIndex } { ...refs(name, validate(validation ?? '', t)) } />
25
+ <input type={ show ? 'text' : 'password' } tabIndex={ tabIndex } { ...refs(name, Validate(validation ?? '', t)) } />
26
26
 
27
27
  { show
28
28
  ? <AiFillEye onClick={ toggle } />
@@ -1,4 +1,4 @@
1
- import styled from "styled-components";
1
+ import styled from 'styled-components';
2
2
 
3
3
  export const Container = styled.div`
4
4
  position: relative;
@@ -8,9 +8,7 @@ export const GetPolicy = (id: number): UseQueryResult<PolicyData> => (
8
8
  queryFn: async () => (
9
9
  await apiClient
10
10
  .get('/api/routes/policy', {
11
- params: {
12
- id
13
- }
11
+ params: { id }
14
12
  })
15
13
  .then(response => (
16
14
  response.data
package/Report/Send.tsx CHANGED
@@ -1,9 +1,10 @@
1
1
  import { TFunction } from 'i18next';
2
2
  import { useForm } from 'react-hook-form';
3
- import { Button } from '@autobusal/common';
4
3
  import { RiCheckFill } from 'react-icons/ri';
5
- import { validate, display } from '@autobusal/utilities/form';
4
+ import { Button } from '../index';
5
+ import { Validate, Display } from '@autobusal/utilities';
6
6
  import { Success } from './styles';
7
+ import { ReportForm } from './types';
7
8
  import { PostReport } from './services';
8
9
 
9
10
  interface Props {
@@ -11,10 +12,6 @@ interface Props {
11
12
  t: TFunction<'common'>
12
13
  }
13
14
 
14
- interface ReportForm {
15
- about: string
16
- }
17
-
18
15
  const Send = ({ type, t }: Props): JSX.Element => {
19
16
  const { register, handleSubmit, formState: { errors } } = useForm<ReportForm>();
20
17
 
@@ -38,9 +35,9 @@ const Send = ({ type, t }: Props): JSX.Element => {
38
35
  <div className="row">
39
36
  { t('report.explain', { ns: 'common' }) }
40
37
 
41
- <textarea { ...register('about', validate('required|min_length:3', t)) } />
38
+ <textarea { ...register('about', Validate('required|min_length:3', t)) } />
42
39
 
43
- { display(errors.about) }
40
+ { Display(errors.about) }
44
41
  </div>
45
42
 
46
43
  <Button
@@ -1,10 +1,11 @@
1
1
  import { UseMutationResult, useMutation } from '@tanstack/react-query';
2
2
  import { apiClient } from '@autobusal/providers';
3
+ import { ReportForm } from './types';
3
4
 
4
- export const PostReport = (type: string): UseMutationResult<void> => (
5
+ export const PostReport = (type: string): UseMutationResult<void, Error, ReportForm, unknown> => (
5
6
  useMutation({
6
7
  mutationKey: ['operator-locations-move', { type }],
7
- mutationFn: async (data: any) => (
8
+ mutationFn: async (data: ReportForm) => (
8
9
  await apiClient
9
10
  .post('/api/reporting/send', {
10
11
  ...data,
@@ -0,0 +1,3 @@
1
+ export interface ReportForm {
2
+ about: string
3
+ }
@@ -1,6 +1,5 @@
1
1
  import styled, { css } from 'styled-components';
2
2
  import { Link } from 'react-router-dom';
3
- // import { Box } from '@layouts/styles';
4
3
 
5
4
  export const Container = styled.div`
6
5
  padding: 10px;
@@ -3,7 +3,7 @@ import { UseFormRegister } from 'react-hook-form';
3
3
  import { TFunction } from 'i18next';
4
4
  import { FaCheck } from 'react-icons/fa';
5
5
  import { MdEventSeat } from 'react-icons/md';
6
- import { validate } from '@autobusal/utilities';
6
+ import { Validate } from '@autobusal/utilities';
7
7
  import Unavailable from './Unavailable';
8
8
  import Preview from './Preview';
9
9
  import { ButtonSeat } from './styles';
@@ -61,7 +61,7 @@ const ChooseSeat = ({ name, type, defaultValue, bus, picked, validation, t, refs
61
61
  />
62
62
  ) }
63
63
 
64
- <input type="hidden" defaultValue={ selected } { ...refs(name, validate(validation, t)) } />
64
+ <input type="hidden" defaultValue={ selected } { ...refs(name, Validate(validation, t)) } />
65
65
  </div>
66
66
  );
67
67
  };
package/Seats/Preview.tsx CHANGED
@@ -1,6 +1,6 @@
1
1
  import { TFunction } from 'i18next';
2
2
  import { MdEventSeat } from 'react-icons/md';
3
- import { Modal } from '@autobusal/common';
3
+ import { Modal } from '../index';
4
4
  import { Seats, SeatsInner, ButtonOccupy } from './styles';
5
5
  import { BusData } from '@autobusal/providers/types/buses';
6
6
 
@@ -1,8 +1,8 @@
1
1
  import { TFunction } from 'i18next';
2
2
  import Sort from './Sort';
3
+ import { getUrl } from '../browseUrl';
3
4
  import { Container, Td, Column, Text } from './styles';
4
5
  import { ColumnData, SortingData } from '../types';
5
- import { getUrl } from '../browseUrl';
6
6
 
7
7
  interface Props {
8
8
  url: string
@@ -1,7 +1,7 @@
1
+ import { BiSortDown, BiSortUp } from 'react-icons/bi';
2
+ import { parseUrl } from '../browseUrl';
1
3
  import { LinkHeader } from './styles';
2
4
  import { ColumnData, SortingData } from '../types';
3
- import { parseUrl } from '../browseUrl';
4
- import { BiSortDown, BiSortUp } from 'react-icons/bi';
5
5
 
6
6
  interface Props {
7
7
  item: ColumnData
@@ -1,10 +1,10 @@
1
1
  import { TFunction } from 'i18next';
2
2
  import Pagination from '../Pagination/Pagination';
3
3
  import { ContainerPaginate } from './styles';
4
- import { PaginationData } from '@modules/Providers/types/pagination';
4
+ import { PaginationData } from '@autobusal/providers/types/pagination';
5
5
 
6
6
  interface Props {
7
- data?: PaginationData<any>
7
+ data?: PaginationData<unknown>
8
8
  colLength: number
9
9
  t: TFunction<'common'>
10
10
  }
package/Table/Row.tsx CHANGED
@@ -1,13 +1,15 @@
1
1
  import { Td } from './styles';
2
2
 
3
3
  interface Props {
4
- id: number
4
+ id?: number
5
5
  data: any[]
6
- withoutView?: boolean
7
6
  }
8
7
 
9
- // @todo: de scos id-ul din toate row-urile
10
8
  const Row = ({ id, data }: Props): JSX.Element[] => {
9
+ if (id === undefined) {
10
+ return [];
11
+ }
12
+
11
13
  const columns = data.map((item, index) => (
12
14
  <Td key={ index }>
13
15
  { item }
@@ -1,5 +1,5 @@
1
1
  import { TFunction } from 'i18next';
2
- import { Inline } from '@autobusal/common';
2
+ import { Inline } from '../../Loading/Loading';
3
3
  import { ContainerLoading } from './styles';
4
4
 
5
5
  interface Props {
@@ -3,13 +3,14 @@ import { NavigateFunction } from 'react-router-dom';
3
3
  import Loading from './Loading';
4
4
  import NotFound from './NotFound';
5
5
  import Actions from '../Actions/Actions';
6
- import { Tr } from './styles';
6
+ import { Tbody, Tr } from './styles';
7
7
 
8
8
  interface Props {
9
9
  url: string
10
10
  urlWith?: string
11
11
  data?: JSX.Element[]
12
12
  loading: boolean
13
+ fetching: boolean
13
14
  colLength: number
14
15
  t: TFunction<'common'>
15
16
  actions?: string[]
@@ -17,7 +18,7 @@ interface Props {
17
18
  navigate: NavigateFunction
18
19
  }
19
20
 
20
- const Rows = ({ url, urlWith, data, loading, colLength, t, actions, handlers, navigate }: Props): JSX.Element => {
21
+ const Rows = ({ url, urlWith, data, loading, fetching, colLength, t, actions, handlers, navigate }: Props): JSX.Element => {
21
22
  if (loading) {
22
23
  return <Loading length={ colLength } t={ t } />;
23
24
  }
@@ -53,9 +54,9 @@ const Rows = ({ url, urlWith, data, loading, colLength, t, actions, handlers, na
53
54
  ));
54
55
 
55
56
  return (
56
- <tbody>
57
+ <Tbody $fetching={ fetching }>
57
58
  { columns }
58
- </tbody>
59
+ </Tbody>
59
60
  );
60
61
  };
61
62
 
@@ -13,6 +13,12 @@ export const ContainerNotFound = styled(ContainerLoading)`
13
13
  color: ${ props => props.theme.font.faded };
14
14
  `;
15
15
 
16
+ export const Tbody = styled.tbody<{ $fetching: boolean }>`
17
+ ${ props => props.$fetching && css`
18
+ opacity: .5;
19
+ ` }
20
+ `;
21
+
16
22
  export const Tr = styled.tr<{ $viewable?: boolean }>`
17
23
  ${ props => props.$viewable && css`
18
24
  cursor: pointer;
package/Table/Table.tsx CHANGED
@@ -1,12 +1,12 @@
1
1
  import { TFunction } from 'i18next';
2
+ import { useNavigate } from 'react-router-dom';
2
3
  import Top from './Top/Top';
3
4
  import Header from './Header/Header';
4
5
  import Rows from './Rows/Rows';
5
6
  import Paginate from './Paginate';
6
7
  import { Container, Content, Inner, ContainerTable } from './styles';
8
+ import { PaginationData } from '@autobusal/providers/types/pagination';
7
9
  import { ColumnData, SortingData } from './types';
8
- import { useNavigate } from 'react-router-dom';
9
- import { PaginationData } from '@modules/Providers/types/pagination';
10
10
 
11
11
  interface Props {
12
12
  url: string
@@ -17,13 +17,14 @@ interface Props {
17
17
  sorting?: SortingData
18
18
  search?: string | null
19
19
  loading: boolean
20
+ fetching: boolean
20
21
  t: TFunction<'common'>
21
22
  actions?: string[]
22
23
  extra?: JSX.Element
23
24
  handlers?: any
24
25
  }
25
26
 
26
- const Table = ({ url, urlWith, columns, rows, pages, sorting, search, loading, t, actions, extra, handlers }: Props): JSX.Element => {
27
+ const Table = ({ url, urlWith, columns, rows, pages, sorting, search, loading, fetching, t, actions, extra, handlers }: Props): JSX.Element => {
27
28
  const navigate = useNavigate();
28
29
 
29
30
  const colLength = columns.length + 1;
@@ -56,6 +57,7 @@ const Table = ({ url, urlWith, columns, rows, pages, sorting, search, loading, t
56
57
  urlWith={ urlWith }
57
58
  data={ rows }
58
59
  loading={ loading }
60
+ fetching={ fetching }
59
61
  colLength={ colLength }
60
62
  t={ t }
61
63
  actions={ actions }
@@ -1,4 +1,4 @@
1
- import queryString from 'query-string';
1
+ import queryString, { ParsedQuery } from 'query-string';
2
2
 
3
3
  export const parseUrl = (replace: any): string => {
4
4
  const query = queryString.parse(location.search);
@@ -16,6 +16,6 @@ export const parseUrl = (replace: any): string => {
16
16
  return `?${ url }`
17
17
  };
18
18
 
19
- export const getUrl = (): any => (
19
+ export const getUrl = (): ParsedQuery<string> => (
20
20
  queryString.parse(location.search)
21
21
  );
@@ -2,19 +2,19 @@ import { TFunction } from 'i18next';
2
2
  import { BiEditAlt, BiTrash, BiSend } from 'react-icons/bi';
3
3
  import { RiSave2Line, RiCheckFill, RiSearchLine } from 'react-icons/ri';
4
4
  import { BsPlusCircleFill } from 'react-icons/bs';
5
+ import Button from '../Button/Button';
5
6
  import { ContainerActions } from './styles';
6
7
  import { ActionData } from './types';
7
- import { Button } from '@autobusal/common';
8
8
 
9
9
  interface Props {
10
10
  id: number
11
11
  available: string[]
12
- loading?: boolean
12
+ pending?: boolean
13
13
  t: TFunction<'common'>
14
14
  onDelete?: () => void
15
15
  }
16
16
 
17
- const Actions = ({ id, available, loading, t, onDelete }: Props): JSX.Element => {
17
+ const Actions = ({ id, available, pending, t, onDelete }: Props): JSX.Element => {
18
18
  const options: ActionData[] = [];
19
19
 
20
20
  const onAskDelete = (): void => {
@@ -90,7 +90,7 @@ const Actions = ({ id, available, loading, t, onDelete }: Props): JSX.Element =>
90
90
  text={
91
91
  <>{ item.icon } { item.label }</>
92
92
  }
93
- loading={ loading }
93
+ loading={ pending }
94
94
  noMargin
95
95
  onClick={ item.handler }
96
96
  />
package/Viewer/Data.tsx CHANGED
@@ -1,16 +1,16 @@
1
1
  import { TFunction } from 'i18next';
2
2
  import { UseFormRegister, UseFormSetValue } from 'react-hook-form';
3
+ import { Validate } from '@autobusal/utilities';
4
+ import Password from '../Password/Password';
5
+ import Calendar from '../Calendar/Calendar';
6
+ import File from '../File/File';
3
7
  import CheckboxList from './Items/CheckboxList';
4
8
  import Linked from './Items/Linked';
5
9
  import TextareaHtml from './Items/TextareaHtml';
6
- import Password from '../Password/Password';
7
10
  import Dropdown from './Items/Dropdown';
8
11
  import DatePicker from './Items/DatePicker';
9
- import { ViewData } from './types';
10
- import Calendar from '../Calendar/Calendar';
11
- import File from '../File/File';
12
- import { validate } from '@autobusal/utilities';
13
12
  import { Display } from './styles';
13
+ import { ViewData } from './types';
14
14
 
15
15
  interface Props {
16
16
  id: number
@@ -27,7 +27,7 @@ const Data = ({ id, item, refs, t, onUpdate }: Props): (JSX.Element | null) => {
27
27
 
28
28
  switch (item.type) {
29
29
  case 'checkbox':
30
- return <input type="checkbox" value={ 1 } defaultChecked={ Number(item.value) == 1 } { ...refs(item.name, validate(String(item.rules), t)) } />;
30
+ return <input type="checkbox" value={ 1 } defaultChecked={ Number(item.value) == 1 } { ...refs(item.name, Validate(String(item.rules), t)) } />;
31
31
 
32
32
  case 'checkbox-list':
33
33
  case 'checkbox-list-all':
@@ -50,8 +50,8 @@ const Data = ({ id, item, refs, t, onUpdate }: Props): (JSX.Element | null) => {
50
50
 
51
51
  case 'date':
52
52
  case 'dob':
53
- case 'picker':
54
- const value = item.value !== null && item.value !== undefined ? String(item.value) : undefined;
53
+ case 'picker': {
54
+ const value = (item.value !== null && item.value !== undefined) ? String(item.value) : undefined;
55
55
 
56
56
  return (
57
57
  <Calendar
@@ -64,19 +64,20 @@ const Data = ({ id, item, refs, t, onUpdate }: Props): (JSX.Element | null) => {
64
64
  onUpdate={ onUpdate }
65
65
  />
66
66
  );
67
+ }
67
68
 
68
69
  case 'date-picker':
69
70
  return <DatePicker item={ item } t={ t } refs={ refs } onUpdate={ onUpdate } />;
70
71
 
71
72
  case 'email':
72
- return <input type="email" defaultValue={ item.value ? String(item.value) : undefined } { ...refs(item.name, validate(String(item.rules), t)) } />;
73
+ return <input type="email" defaultValue={ item.value !== undefined ? String(item.value) : undefined } { ...refs(item.name, Validate(String(item.rules), t)) } />;
73
74
 
74
75
  case 'file':
75
76
  case 'files':
76
77
  return (
77
78
  <File
78
79
  name={ item.name }
79
- value={ item.value ? String(item.value) : undefined }
80
+ value={ item.value !== undefined ? String(item.value) : undefined }
80
81
  validation={ item.rules }
81
82
  multiple={ item.type === 'files' }
82
83
  t={ t }
@@ -85,13 +86,13 @@ const Data = ({ id, item, refs, t, onUpdate }: Props): (JSX.Element | null) => {
85
86
  );
86
87
 
87
88
  case 'float':
88
- return <input type="number" defaultValue={ item.value ? Number(item.value) : undefined } { ...refs(item.name, validate(String(item.rules), t)) } step="0.01" />;
89
+ return <input type="number" defaultValue={ item.value !== undefined ? Number(item.value) : undefined } { ...refs(item.name, Validate(String(item.rules), t)) } step="0.01" />;
89
90
 
90
91
  case 'link':
91
92
  return <Linked id={ id } value={ item.value } url={ item.url } />;
92
93
 
93
94
  case 'number':
94
- return <input type="number" defaultValue={ item.value ? Number(item?.value) : undefined } { ...refs(item.name, validate(String(item.rules), t)) } />
95
+ return <input type="number" defaultValue={ item.value !== undefined ? Number(item?.value) : undefined } { ...refs(item.name, Validate(String(item.rules), t)) } />
95
96
 
96
97
  case 'password':
97
98
  return <Password name={ item.name } validation={ item.rules } t={ t } refs={ refs } />;
@@ -100,10 +101,10 @@ const Data = ({ id, item, refs, t, onUpdate }: Props): (JSX.Element | null) => {
100
101
  return <Dropdown item={ item } refs={ refs } t={ t } />;
101
102
 
102
103
  case 'text':
103
- return <input type="text" defaultValue={ item.value ? String(item.value) : undefined } { ...refs(item.name, validate(String(item.rules), t)) } />;
104
+ return <input type="text" defaultValue={ item.value !== undefined ? String(item.value) : undefined } { ...refs(item.name, Validate(String(item.rules), t)) } />;
104
105
 
105
106
  case 'textarea':
106
- return <textarea defaultValue={ item.value ? String(item.value) : undefined } { ...refs(item.name, validate(String(item.rules), t)) }></textarea>;
107
+ return <textarea defaultValue={ item.value !== undefined ? String(item.value) : undefined } { ...refs(item.name, Validate(String(item.rules), t)) }></textarea>;
107
108
 
108
109
  case 'textarea-html':
109
110
  return (
package/Viewer/Item.tsx CHANGED
@@ -1,5 +1,5 @@
1
1
  import { FieldErrors, UseFormRegister, UseFormSetValue } from 'react-hook-form';
2
- import { display } from '@autobusal/utilities';
2
+ import { Display } from '@autobusal/utilities';
3
3
  import Data from './Data';
4
4
  import { Notice } from './styles';
5
5
  import { ViewData } from './types';
@@ -26,7 +26,7 @@ const Item = ({ id, data, refs, t, errors, onUpdate }: Props): JSX.Element => (
26
26
  onUpdate={ onUpdate }
27
27
  />
28
28
 
29
- { data.name && display(errors[data.name]) }
29
+ { data.name && Display(errors[data.name]) }
30
30
 
31
31
  { data.notice && <Notice>* { data.notice }</Notice> }
32
32
  </div>
@@ -2,7 +2,7 @@ import { useState } from 'react';
2
2
  import { TFunction } from 'i18next';
3
3
  import { UseFormRegister } from 'react-hook-form';
4
4
  import { ContainerCheckboxList, ListLabel } from './styles';
5
- import { DropdownData } from '@modules/Providers/types/other';
5
+ import { DropdownData } from '@autobusal/providers/types/other';
6
6
 
7
7
  interface Props {
8
8
  name: string
@@ -1,12 +1,12 @@
1
1
  import { useState } from 'react';
2
2
  import { TFunction } from 'i18next';
3
3
  import { UseFormRegister, UseFormSetValue } from 'react-hook-form';
4
- import { Button } from '@autobusal/common';
5
4
  import { FaCalendar } from 'react-icons/fa';
5
+ import { RiCloseCircleFill } from 'react-icons/ri';
6
+ import Button from '../../Button/Button';
6
7
  import Calendar from '../../Calendar/Calendar';
7
8
  import { Picker, ContainerPicker, PickerClose } from './styles';
8
9
  import { ViewData } from '../types';
9
- import { RiCloseCircleFill } from 'react-icons/ri';
10
10
 
11
11
  interface Props {
12
12
  item: ViewData
@@ -1,6 +1,6 @@
1
1
  import { TFunction } from 'i18next';
2
2
  import { UseFormRegister } from 'react-hook-form';
3
- import { validate } from '@autobusal/utilities';
3
+ import { Validate } from '@autobusal/utilities';
4
4
  import { ViewData } from '../types';
5
5
 
6
6
  interface Props {
@@ -18,19 +18,15 @@ const Dropdown = ({ item, refs, t }: Props): (JSX.Element | null) => {
18
18
  return null;
19
19
  }
20
20
 
21
- const rules = validate(String(item.rules), t);
21
+ const rules = Validate(String(item.rules), t);
22
22
 
23
23
  // we listen for the change
24
- if (item.onChange !== undefined) {
25
- rules.onChange = (event: React.EventHandler<any>) => item.onChange(event.target.value);
24
+ if (item.onChange !== undefined && item.onChange !== null) {
25
+ rules.onChange = (event: any) => item.onChange!(event.target.value);
26
26
  }
27
27
 
28
28
  const values = item.values?.map((item, index) => (
29
- <option
30
- key={ index }
31
- value={ item.id }
32
- // disabled={ item.disabled === true }
33
- >
29
+ <option key={ index } value={ item.id }>
34
30
  { item.name }
35
31
  </option>
36
32
  ));