@autobusal/common 0.0.41 → 1.0.0
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.
- package/ApiDetails/ApiDetails.tsx +1 -1
- package/ApiDetails/Content.tsx +9 -5
- package/ApiDetails/Devpos.tsx +26 -26
- package/ApiDetails/services.ts +4 -3
- package/Autocomplete/Autocomplete.tsx +3 -3
- package/Avatar.tsx +2 -2
- package/{BackTo.tsx → Back/BackTo.tsx} +3 -26
- package/Back/BackWithTitle.tsx +30 -0
- package/Button/Button.tsx +4 -2
- package/Calendar/Calendar.tsx +2 -2
- package/{BrowseCompanyItem/BrowseCompanyItem.tsx → CompanyItem/CompanyItem.tsx} +2 -2
- package/CookieNotification/CookieNotification.tsx +2 -2
- package/File/File.tsx +4 -4
- package/IpLogs/IpLogs.tsx +3 -3
- package/IpLogs/View.tsx +5 -5
- package/IpLogs/services.ts +2 -2
- package/Loading/Loading.tsx +19 -29
- package/Loading/Paragraph.tsx +62 -0
- package/Loading/styles.ts +29 -5
- package/Meta.tsx +1 -1
- package/Modal/Modal.tsx +2 -3
- package/Pagination/Pagination.tsx +1 -1
- package/Passengers/Passengers.tsx +6 -5
- package/Passengers/Persons.tsx +7 -7
- package/Passengers/{utilities/getText.ts → utilities.ts} +3 -5
- package/Password/Password.tsx +2 -2
- package/Password/styles.ts +1 -1
- package/Policy/services.ts +1 -3
- package/Report/Send.tsx +5 -8
- package/Report/services.ts +3 -2
- package/Report/types.ts +3 -0
- package/RouteItem/styles.ts +0 -1
- package/Seats/ChooseSeat.tsx +2 -2
- package/Seats/Preview.tsx +1 -1
- package/Table/Header/Header.tsx +1 -1
- package/Table/Header/Sort.tsx +2 -2
- package/Table/Paginate.tsx +2 -2
- package/Table/Row.tsx +5 -3
- package/Table/Rows/Loading.tsx +1 -1
- package/Table/Rows/Rows.tsx +5 -4
- package/Table/Rows/styles.ts +6 -0
- package/Table/Table.tsx +5 -3
- package/Table/browseUrl.ts +2 -2
- package/Viewer/Actions.tsx +4 -4
- package/Viewer/Data.tsx +15 -14
- package/Viewer/Item.tsx +2 -2
- package/Viewer/Items/CheckboxList.tsx +1 -1
- package/Viewer/Items/DatePicker.tsx +2 -2
- package/Viewer/Items/Dropdown.tsx +5 -9
- package/Viewer/Items/TextareaHtml.tsx +3 -3
- package/Viewer/Items/styles.ts +1 -1
- package/Viewer/Viewer.tsx +4 -4
- package/Viewer/types.ts +1 -1
- package/index.ts +15 -9
- package/package.json +1 -1
- /package/{BrowseCompanyItem → CompanyItem}/styles.ts +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
2
|
import { TFunction } from 'i18next';
|
|
3
3
|
import { IoKeySharp } from 'react-icons/io5';
|
|
4
|
-
import { Button, Modal } from '
|
|
4
|
+
import { Button, Modal } from '../index';
|
|
5
5
|
import Content from './Content';
|
|
6
6
|
|
|
7
7
|
interface Props {
|
package/ApiDetails/Content.tsx
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { TFunction } from 'i18next';
|
|
2
|
-
import { Paragraph } from '
|
|
2
|
+
import { Paragraph } from '../index';
|
|
3
|
+
import { success } from '@autobusal/utilities';
|
|
3
4
|
import DevPos from './Devpos';
|
|
5
|
+
import { DevPosForm } from './types';
|
|
4
6
|
import { GetSettings, PostSettings } from './services';
|
|
5
7
|
|
|
6
8
|
interface Props {
|
|
@@ -10,11 +12,11 @@ interface Props {
|
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
const Content = ({ id, type, t }: Props): JSX.Element => {
|
|
13
|
-
const { data,
|
|
15
|
+
const { data, isLoading } = GetSettings(id, type);
|
|
14
16
|
|
|
15
17
|
const { mutate: SaveSettings, isPending } = PostSettings(id, type);
|
|
16
18
|
|
|
17
|
-
if (
|
|
19
|
+
if (isLoading) {
|
|
18
20
|
return <Paragraph count={ 3 } />;
|
|
19
21
|
}
|
|
20
22
|
|
|
@@ -24,8 +26,10 @@ const Content = ({ id, type, t }: Props): JSX.Element => {
|
|
|
24
26
|
);
|
|
25
27
|
}
|
|
26
28
|
|
|
27
|
-
const onSave = (data:
|
|
28
|
-
SaveSettings(data
|
|
29
|
+
const onSave = (data: DevPosForm) => {
|
|
30
|
+
SaveSettings(data, {
|
|
31
|
+
onSuccess: () => success(t('api_details.messages.saved'))
|
|
32
|
+
});
|
|
29
33
|
};
|
|
30
34
|
|
|
31
35
|
switch (type) {
|
package/ApiDetails/Devpos.tsx
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { TFunction } from 'i18next';
|
|
2
2
|
import { useForm } from 'react-hook-form';
|
|
3
|
-
import { Button } from '
|
|
4
|
-
import {
|
|
5
|
-
import { ApiDetailsData } from '@
|
|
3
|
+
import { Button } from '../index';
|
|
4
|
+
import { Validate, Display } from '@autobusal/utilities';
|
|
5
|
+
import { ApiDetailsData } from '@autobusal/providers/types/users';
|
|
6
6
|
import { DevPosForm } from './types';
|
|
7
7
|
|
|
8
8
|
interface Props {
|
|
9
9
|
data?: ApiDetailsData
|
|
10
10
|
loading: boolean
|
|
11
11
|
t: TFunction<'common'>
|
|
12
|
-
onSave: (data:
|
|
12
|
+
onSave: (data: DevPosForm) => void
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
const DevPos = ({ data, loading, t, onSave }: Props): JSX.Element => {
|
|
@@ -32,17 +32,17 @@ const DevPos = ({ data, loading, t, onSave }: Props): JSX.Element => {
|
|
|
32
32
|
<div className="row">
|
|
33
33
|
{ t('api_details.devpos.business_code', { ns: 'common' }) }
|
|
34
34
|
|
|
35
|
-
<input type="text" defaultValue={ data?.business_code } { ...register('business_code',
|
|
35
|
+
<input type="text" defaultValue={ data?.business_code } { ...register('business_code', Validate('required|min_length:2', t)) } onKeyDown={ onKeyDown } />
|
|
36
36
|
|
|
37
|
-
{
|
|
37
|
+
{ Display(errors.business_code) }
|
|
38
38
|
</div>
|
|
39
39
|
|
|
40
40
|
<div className="row">
|
|
41
41
|
{ t('api_details.devpos.operator_code', { ns: 'common' }) }
|
|
42
42
|
|
|
43
|
-
<input type="text" defaultValue={ data?.operator_code } { ...register('operator_code',
|
|
43
|
+
<input type="text" defaultValue={ data?.operator_code } { ...register('operator_code', Validate('required|min_length:2', t)) } onKeyDown={ onKeyDown } />
|
|
44
44
|
|
|
45
|
-
{
|
|
45
|
+
{ Display(errors.operator_code) }
|
|
46
46
|
</div>
|
|
47
47
|
</div>
|
|
48
48
|
|
|
@@ -50,17 +50,17 @@ const DevPos = ({ data, loading, t, onSave }: Props): JSX.Element => {
|
|
|
50
50
|
<div className="row">
|
|
51
51
|
{ t('api_details.devpos.nuis', { ns: 'common' }) }
|
|
52
52
|
|
|
53
|
-
<input type="text" defaultValue={ data?.nuis } { ...register('nuis',
|
|
53
|
+
<input type="text" defaultValue={ data?.nuis } { ...register('nuis', Validate('required|min_length:2', t)) } onKeyDown={ onKeyDown } />
|
|
54
54
|
|
|
55
|
-
{
|
|
55
|
+
{ Display(errors.nuis) }
|
|
56
56
|
</div>
|
|
57
57
|
|
|
58
58
|
<div className="row">
|
|
59
59
|
{ t('api_details.devpos.fiscalization_number', { ns: 'common' }) }
|
|
60
60
|
|
|
61
|
-
<input type="text" defaultValue={ data?.fiscalization_number } { ...register('fiscalization_number',
|
|
61
|
+
<input type="text" defaultValue={ data?.fiscalization_number } { ...register('fiscalization_number', Validate('required|min_length:2', t)) } onKeyDown={ onKeyDown } />
|
|
62
62
|
|
|
63
|
-
{
|
|
63
|
+
{ Display(errors.fiscalization_number) }
|
|
64
64
|
</div>
|
|
65
65
|
</div>
|
|
66
66
|
|
|
@@ -68,43 +68,43 @@ const DevPos = ({ data, loading, t, onSave }: Props): JSX.Element => {
|
|
|
68
68
|
<div className="row">
|
|
69
69
|
{ t('api_details.devpos.username', { ns: 'common' }) }
|
|
70
70
|
|
|
71
|
-
<input type="text" defaultValue={ data?.username } { ...register('username',
|
|
71
|
+
<input type="text" defaultValue={ data?.username } { ...register('username', Validate('required|min_length:2', t)) } onKeyDown={ onKeyDown } />
|
|
72
72
|
|
|
73
|
-
{
|
|
73
|
+
{ Display(errors.username) }
|
|
74
74
|
</div>
|
|
75
75
|
|
|
76
76
|
<div className="row">
|
|
77
77
|
{ t('api_details.devpos.password', { ns: 'common' }) }
|
|
78
78
|
|
|
79
|
-
<input type="text" defaultValue={ data?.password } { ...register('password',
|
|
79
|
+
<input type="text" defaultValue={ data?.password } { ...register('password', Validate('required|min_length:2', t)) } onKeyDown={ onKeyDown } />
|
|
80
80
|
|
|
81
|
-
{
|
|
81
|
+
{ Display(errors.password) }
|
|
82
82
|
</div>
|
|
83
83
|
</div>
|
|
84
84
|
|
|
85
85
|
<div className="row">
|
|
86
86
|
{ t('api_details.devpos.bank_name', { ns: 'common' }) }
|
|
87
87
|
|
|
88
|
-
<input type="text" defaultValue={ data?.bank_name } { ...register('bank_name',
|
|
88
|
+
<input type="text" defaultValue={ data?.bank_name } { ...register('bank_name', Validate('required|min_length:2', t)) } onKeyDown={ onKeyDown } />
|
|
89
89
|
|
|
90
|
-
{
|
|
90
|
+
{ Display(errors.bank_name) }
|
|
91
91
|
</div>
|
|
92
92
|
|
|
93
93
|
<div className="column">
|
|
94
94
|
<div className="row">
|
|
95
95
|
{ t('api_details.devpos.bank_swift', { ns: 'common' }) }
|
|
96
96
|
|
|
97
|
-
<input type="text" defaultValue={ data?.bank_swift } { ...register('bank_swift',
|
|
97
|
+
<input type="text" defaultValue={ data?.bank_swift } { ...register('bank_swift', Validate('required|min_length:2', t)) } onKeyDown={ onKeyDown } />
|
|
98
98
|
|
|
99
|
-
{
|
|
99
|
+
{ Display(errors.bank_swift) }
|
|
100
100
|
</div>
|
|
101
101
|
|
|
102
102
|
<div className="row">
|
|
103
103
|
{ t('api_details.devpos.bank_account', { ns: 'common' }) }
|
|
104
104
|
|
|
105
|
-
<input type="text" defaultValue={ data?.bank_account } { ...register('bank_account',
|
|
105
|
+
<input type="text" defaultValue={ data?.bank_account } { ...register('bank_account', Validate('required|min_length:2', t)) } onKeyDown={ onKeyDown } />
|
|
106
106
|
|
|
107
|
-
{
|
|
107
|
+
{ Display(errors.bank_account) }
|
|
108
108
|
</div>
|
|
109
109
|
</div>
|
|
110
110
|
|
|
@@ -112,17 +112,17 @@ const DevPos = ({ data, loading, t, onSave }: Props): JSX.Element => {
|
|
|
112
112
|
<div className="row">
|
|
113
113
|
{ t('api_details.devpos.bank_address', { ns: 'common' }) }
|
|
114
114
|
|
|
115
|
-
<input type="text" defaultValue={ data?.bank_address } { ...register('bank_address',
|
|
115
|
+
<input type="text" defaultValue={ data?.bank_address } { ...register('bank_address', Validate('required|min_length:2', t)) } onKeyDown={ onKeyDown } />
|
|
116
116
|
|
|
117
|
-
{
|
|
117
|
+
{ Display(errors.bank_address) }
|
|
118
118
|
</div>
|
|
119
119
|
|
|
120
120
|
<div className="row">
|
|
121
121
|
{ t('api_details.devpos.bank_city', { ns: 'common' }) }
|
|
122
122
|
|
|
123
|
-
<input type="text" defaultValue={ data?.bank_city } { ...register('bank_city',
|
|
123
|
+
<input type="text" defaultValue={ data?.bank_city } { ...register('bank_city', Validate('required|min_length:2', t)) } onKeyDown={ onKeyDown } />
|
|
124
124
|
|
|
125
|
-
{
|
|
125
|
+
{ Display(errors.bank_city) }
|
|
126
126
|
</div>
|
|
127
127
|
</div>
|
|
128
128
|
|
package/ApiDetails/services.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useQuery, UseQueryResult, useMutation, UseMutationResult } from '@tanstack/react-query';
|
|
2
2
|
import { apiClient } from '@autobusal/providers';
|
|
3
|
-
import { ApiDetailsData } from '@
|
|
3
|
+
import { ApiDetailsData } from '@autobusal/providers/types/users';
|
|
4
|
+
import { DevPosForm } from './types';
|
|
4
5
|
|
|
5
6
|
export const GetSettings = (id: number, type: string): UseQueryResult<ApiDetailsData | string> => (
|
|
6
7
|
useQuery({
|
|
@@ -20,10 +21,10 @@ export const GetSettings = (id: number, type: string): UseQueryResult<ApiDetails
|
|
|
20
21
|
})
|
|
21
22
|
);
|
|
22
23
|
|
|
23
|
-
export const PostSettings = (id: number, type: string): UseMutationResult<void> => (
|
|
24
|
+
export const PostSettings = (id: number, type: string): UseMutationResult<void, Error, DevPosForm, unknown> => (
|
|
24
25
|
useMutation({
|
|
25
26
|
mutationKey: ['apidetails-update-settings'],
|
|
26
|
-
mutationFn: async (data:
|
|
27
|
+
mutationFn: async (data: DevPosForm) => (
|
|
27
28
|
await apiClient
|
|
28
29
|
.post('/api/api_details/admin/update', {
|
|
29
30
|
...data,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useState, useRef, ChangeEvent, KeyboardEvent } from 'react';
|
|
2
|
-
import { UseFormRegister, UseFormSetValue } from 'react-hook-form';
|
|
3
2
|
import { TFunction } from 'i18next';
|
|
3
|
+
import { UseFormRegister, UseFormSetValue } from 'react-hook-form';
|
|
4
4
|
import { useOutside } from '@autobusal/hooks';
|
|
5
|
-
import {
|
|
5
|
+
import { Validate } from '@autobusal/utilities';
|
|
6
6
|
import Suggestions from './Suggestions';
|
|
7
7
|
import { Container } from './styles';
|
|
8
8
|
import { AutocompleteData } from './types';
|
|
@@ -97,7 +97,7 @@ const Autocomplete = ({ name, defaultValue, data, validation, t, refs, onUpdate
|
|
|
97
97
|
|
|
98
98
|
{ (show && q.length > 1 && options.length > 0) && <Suggestions options={ options } selected={ selected } onClick={ onSelected } /> }
|
|
99
99
|
|
|
100
|
-
<input type="hidden" defaultValue={ value } { ...refs(name,
|
|
100
|
+
<input type="hidden" defaultValue={ value } { ...refs(name, Validate(validation, t)) } />
|
|
101
101
|
</Container>
|
|
102
102
|
);
|
|
103
103
|
}
|
package/Avatar.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
|
-
import { OperatorData } from '@
|
|
3
|
-
import { AgentData } from '@
|
|
2
|
+
import { OperatorData } from '@autobusal/providers/types/operators';
|
|
3
|
+
import { AgentData } from '@autobusal/providers/types/agents';
|
|
4
4
|
|
|
5
5
|
interface Props {
|
|
6
6
|
display?: OperatorData | AgentData
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TFunction } from 'i18next';
|
|
2
|
-
import { Link } from 'react-router-dom';
|
|
3
2
|
import styled from 'styled-components';
|
|
3
|
+
import { Link } from 'react-router-dom';
|
|
4
4
|
import { BiChevronLeftCircle } from 'react-icons/bi';
|
|
5
5
|
|
|
6
6
|
interface Props {
|
|
@@ -26,34 +26,11 @@ const LinkStyled = styled(Link)`
|
|
|
26
26
|
}
|
|
27
27
|
`;
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
const BackTo = ({ to, t }: Props): JSX.Element => (
|
|
30
30
|
<LinkStyled to={ to }>
|
|
31
31
|
<BiChevronLeftCircle />
|
|
32
32
|
{ t('back', { ns: 'common' }) }
|
|
33
33
|
</LinkStyled>
|
|
34
34
|
);
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
title: string
|
|
38
|
-
to: string
|
|
39
|
-
t: TFunction<'common'>
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const ContainerTitle = styled.div`
|
|
43
|
-
display: flex;
|
|
44
|
-
gap: 15px;
|
|
45
|
-
align-items: center;
|
|
46
|
-
margin-bottom: 20px;
|
|
47
|
-
|
|
48
|
-
& > h1 {
|
|
49
|
-
margin-bottom: 0;
|
|
50
|
-
}
|
|
51
|
-
`;
|
|
52
|
-
|
|
53
|
-
export const BackWithTitle = ({ title, to, t }: TitleProps): JSX.Element => (
|
|
54
|
-
<ContainerTitle>
|
|
55
|
-
<BackTo to={ to } t={ t } />
|
|
56
|
-
|
|
57
|
-
<h1>{ title }</h1>
|
|
58
|
-
</ContainerTitle>
|
|
59
|
-
);
|
|
36
|
+
export default BackTo;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { TFunction } from 'i18next';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import BackTo from './BackTo';
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
title: string
|
|
7
|
+
to: string
|
|
8
|
+
t: TFunction<'common'>
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const Container = styled.div`
|
|
12
|
+
display: flex;
|
|
13
|
+
gap: 15px;
|
|
14
|
+
align-items: center;
|
|
15
|
+
margin-bottom: 20px;
|
|
16
|
+
|
|
17
|
+
& > h1 {
|
|
18
|
+
margin-bottom: 0;
|
|
19
|
+
}
|
|
20
|
+
`;
|
|
21
|
+
|
|
22
|
+
const BackWithTitle = ({ title, to, t }: Props): JSX.Element => (
|
|
23
|
+
<Container>
|
|
24
|
+
<BackTo to={ to } t={ t } />
|
|
25
|
+
|
|
26
|
+
<h1>{ title }</h1>
|
|
27
|
+
</Container>
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
export default BackWithTitle;
|
package/Button/Button.tsx
CHANGED
|
@@ -13,7 +13,7 @@ interface Props {
|
|
|
13
13
|
onClick?: any
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
const Button = ({ type, size, loading, active, subtype, text, noMargin, maxWidth, onClick }: Props) => (
|
|
17
17
|
<ButtonStyled
|
|
18
18
|
$size={ size }
|
|
19
19
|
type={ loading ? 'button' : type }
|
|
@@ -25,4 +25,6 @@ export const Button = ({ type, size, loading, active, subtype, text, noMargin, m
|
|
|
25
25
|
>
|
|
26
26
|
{ loading ? <RiLoader2Fill /> : text }
|
|
27
27
|
</ButtonStyled>
|
|
28
|
-
);
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
export default Button;
|
package/Calendar/Calendar.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import { useState, useRef } from 'react';
|
|
|
2
2
|
import { UseFormRegister, UseFormSetValue } from 'react-hook-form';
|
|
3
3
|
import { TFunction } from 'i18next';
|
|
4
4
|
import { useOutside } from '@autobusal/hooks';
|
|
5
|
-
import {
|
|
5
|
+
import { Validate, prepareDate } from '@autobusal/utilities';
|
|
6
6
|
import Picker from './Picker';
|
|
7
7
|
import { Container } from './styles';
|
|
8
8
|
|
|
@@ -48,7 +48,7 @@ const Calendar = ({ type, name, defaultValue, t, validation, refs, onUpdate }: P
|
|
|
48
48
|
/>
|
|
49
49
|
) }
|
|
50
50
|
|
|
51
|
-
<input type="hidden" defaultValue={ prepared } { ...refs(name,
|
|
51
|
+
<input type="hidden" defaultValue={ prepared } { ...refs(name, Validate(validation ?? '', t)) } />
|
|
52
52
|
</Container>
|
|
53
53
|
);
|
|
54
54
|
}
|
|
@@ -7,7 +7,7 @@ interface Props {
|
|
|
7
7
|
type: 'agent' | 'operator'
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
const
|
|
10
|
+
const CompanyItem = ({ item, type }: Props): JSX.Element => {
|
|
11
11
|
const isColumn = item.column === 1;
|
|
12
12
|
const isBanner = item.banner === 1;
|
|
13
13
|
|
|
@@ -36,4 +36,4 @@ const BrowseCompanyItem = ({ item, type }: Props): JSX.Element => {
|
|
|
36
36
|
);
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
-
export default
|
|
39
|
+
export default CompanyItem;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
2
|
import { TFunction } from 'i18next';
|
|
3
|
-
import
|
|
3
|
+
import Button from '../Button/Button';
|
|
4
4
|
import { Container, Info } from './styles';
|
|
5
5
|
|
|
6
6
|
interface Props {
|
|
@@ -18,7 +18,7 @@ const CookieNotification = ({ t }: Props): (JSX.Element | null) => {
|
|
|
18
18
|
const CookieDate = new Date();
|
|
19
19
|
CookieDate.setFullYear(CookieDate.getFullYear() + 1);
|
|
20
20
|
|
|
21
|
-
document.cookie = '
|
|
21
|
+
document.cookie = 'OBTCookieNotification=viewed; expires=' + CookieDate.toUTCString() + '; path=/; SameSite=None; Secure';
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
if (! show) {
|
package/File/File.tsx
CHANGED
|
@@ -2,9 +2,9 @@ import { TFunction } from 'i18next';
|
|
|
2
2
|
import { useState, useRef } from 'react';
|
|
3
3
|
import { UseFormRegister } from 'react-hook-form';
|
|
4
4
|
import { HiOutlineCloudUpload, HiCheck } from 'react-icons/hi';
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
5
|
+
import Modal from '../Modal/Modal';
|
|
6
|
+
import { Validate } from '@autobusal/utilities';
|
|
7
|
+
import Button from '../Button/Button';
|
|
8
8
|
import { Container, ImgView, ImgPreview } from './styles';
|
|
9
9
|
|
|
10
10
|
interface Props {
|
|
@@ -22,7 +22,7 @@ const File = ({ name, value, validation, multiple, t, refs }: Props): JSX.Elemen
|
|
|
22
22
|
|
|
23
23
|
const inputRef = useRef<HTMLInputElement | null>(null);
|
|
24
24
|
|
|
25
|
-
const rules =
|
|
25
|
+
const rules = Validate(String(validation), t);
|
|
26
26
|
|
|
27
27
|
const onChange = (): void => {
|
|
28
28
|
setUploaded(true);
|
package/IpLogs/IpLogs.tsx
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { TFunction } from 'i18next';
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import { AiOutlineLogin } from 'react-icons/ai';
|
|
4
|
-
import { Button } from '
|
|
4
|
+
import { Button } from '../index';
|
|
5
5
|
import View from './View';
|
|
6
6
|
import { NotAvailable } from './styles';
|
|
7
7
|
|
|
8
8
|
interface Props {
|
|
9
9
|
id: number
|
|
10
10
|
page: number
|
|
11
|
-
type: 'admins' | 'financers' | 'operators' | 'visitors'
|
|
11
|
+
type: 'admins' | 'agents' | 'financers' | 'operators' | 'visitors'
|
|
12
12
|
t: TFunction<'common'>
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
const IpLogs = ({ id, page, type, t }: Props): (JSX.Element | string) => {
|
|
16
16
|
const [ show, setShow ] = useState<boolean>(false);
|
|
17
17
|
|
|
18
|
-
if (id
|
|
18
|
+
if (id === 0) {
|
|
19
19
|
return (
|
|
20
20
|
<NotAvailable>
|
|
21
21
|
{ t('ip_logs.not_available', { ns: 'common' }) }
|
package/IpLogs/View.tsx
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { TFunction } from 'i18next';
|
|
2
|
-
import Table from '
|
|
3
|
-
import Row from '@modules/Common/Table/Row';
|
|
2
|
+
import { Table, Row } from '../index';
|
|
4
3
|
import { Container } from './styles';
|
|
5
4
|
import { GetLogs } from './services';
|
|
6
5
|
|
|
7
6
|
interface Props {
|
|
8
7
|
id: number
|
|
9
8
|
page: number
|
|
10
|
-
type: 'admins' | 'financers'
|
|
9
|
+
type: 'admins' | 'agents' | 'financers' | 'operators' | 'visitors'
|
|
11
10
|
t: TFunction<'common'>
|
|
12
11
|
}
|
|
13
12
|
|
|
14
13
|
const View = ({ id, page, type, t }: Props): JSX.Element => {
|
|
15
|
-
const { data, isFetching } = GetLogs(id, type, page);
|
|
14
|
+
const { data, isLoading, isFetching } = GetLogs(id, type, page);
|
|
16
15
|
|
|
17
16
|
const rows = data?.data.map(item => (
|
|
18
17
|
<Row
|
|
@@ -38,7 +37,8 @@ const View = ({ id, page, type, t }: Props): JSX.Element => {
|
|
|
38
37
|
}] }
|
|
39
38
|
rows={ rows }
|
|
40
39
|
pages={ data }
|
|
41
|
-
loading={
|
|
40
|
+
loading={ isLoading }
|
|
41
|
+
fetching={ isFetching }
|
|
42
42
|
t={ t }
|
|
43
43
|
/>
|
|
44
44
|
</Container>
|
package/IpLogs/services.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useQuery, UseQueryResult } from '@tanstack/react-query';
|
|
2
2
|
import { apiClient } from '@autobusal/providers';
|
|
3
|
-
import { LogData } from '@
|
|
4
|
-
import { PaginationData } from '@autobusal/
|
|
3
|
+
import { LogData } from '@autobusal/providers/types/users';
|
|
4
|
+
import { PaginationData } from '@autobusal/providers/types/pagination';
|
|
5
5
|
|
|
6
6
|
export const GetLogs = (id: number, type: string, page: number): UseQueryResult<PaginationData<LogData>> => (
|
|
7
7
|
useQuery({
|
package/Loading/Loading.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SpinnerRoundFilled, SpinnerCircularFixed } from 'spinners-react';
|
|
2
|
-
import { useSystemTheme } from '@autobusal/
|
|
3
|
-
import
|
|
4
|
-
import { ContainerGeneral, ContainerInline,
|
|
2
|
+
import { useSystemTheme } from '@autobusal/hooks';
|
|
3
|
+
import Paragraph from './Paragraph';
|
|
4
|
+
import { ContainerGeneral, ContainerInline, ContainerBoxMiddle, ContainerFull } from './styles';
|
|
5
5
|
|
|
6
6
|
export const General = (): JSX.Element => {
|
|
7
7
|
const theme = useSystemTheme();
|
|
@@ -46,39 +46,29 @@ export const Inline = ({ text }: InlineProps): JSX.Element => {
|
|
|
46
46
|
);
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
-
interface ParagraphProps {
|
|
50
|
-
count?: number
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export const Paragraph = ({ count = 3 }: ParagraphProps): JSX.Element => {
|
|
54
|
-
const items: JSX.Element[] = [];
|
|
55
|
-
|
|
56
|
-
const theme = useSystemTheme();
|
|
57
|
-
|
|
58
|
-
for (let i = 1; i <= count; i++) {
|
|
59
|
-
items.push(
|
|
60
|
-
<ItemParagraph $color={ theme === 'light' ? '#EBEBEB' : '#202020' } $width={ getRandomNumber(60, 100) } />
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return (
|
|
65
|
-
<ContainerParagraph>
|
|
66
|
-
{ items }
|
|
67
|
-
</ContainerParagraph>
|
|
68
|
-
);
|
|
69
|
-
};
|
|
70
|
-
|
|
71
49
|
interface BoxProps {
|
|
72
|
-
title?: string
|
|
73
50
|
count?: number
|
|
74
51
|
}
|
|
75
52
|
|
|
76
|
-
export const Box = ({
|
|
53
|
+
export const Box = ({ count = 3 }: BoxProps): JSX.Element => (
|
|
77
54
|
<>
|
|
78
|
-
<
|
|
55
|
+
<Paragraph isTitle />
|
|
79
56
|
|
|
80
57
|
<div className="box">
|
|
81
|
-
|
|
58
|
+
<Paragraph count={ count } />
|
|
82
59
|
</div>
|
|
83
60
|
</>
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
export const BoxMiddle = ({ count = 3 }: BoxProps): JSX.Element => (
|
|
64
|
+
<ContainerBoxMiddle className="box">
|
|
65
|
+
<Paragraph isTitle />
|
|
66
|
+
<Paragraph count={ count } />
|
|
67
|
+
</ContainerBoxMiddle>
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
export const GeneralFull = (): JSX.Element => (
|
|
71
|
+
<ContainerFull>
|
|
72
|
+
<General />
|
|
73
|
+
</ContainerFull>
|
|
84
74
|
);
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { useSystemTheme } from '@autobusal/hooks';
|
|
2
|
+
import { getRandomNumber } from '@autobusal/utilities';
|
|
3
|
+
import { ContainerParagraphs, ContainerParagraph, ItemParagraph } from './styles';
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
count?: number
|
|
7
|
+
isTitle?: boolean
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const Paragraph = ({ count = 3, isTitle }: Props): JSX.Element => {
|
|
11
|
+
const theme = useSystemTheme();
|
|
12
|
+
|
|
13
|
+
const color = theme === 'light' ? '#EBEBEB' : '#202020';
|
|
14
|
+
|
|
15
|
+
if (isTitle) {
|
|
16
|
+
return (
|
|
17
|
+
<h1>
|
|
18
|
+
<ItemParagraph
|
|
19
|
+
$color={ color }
|
|
20
|
+
$width={ 50 }
|
|
21
|
+
$height={ 27 }
|
|
22
|
+
/>
|
|
23
|
+
</h1>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const paragraphs = getParagraphs(count, color);
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<ContainerParagraphs>
|
|
31
|
+
{ paragraphs }
|
|
32
|
+
</ContainerParagraphs>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const getParagraphs = (count: number, color: string): JSX.Element[] => {
|
|
37
|
+
const paragraphs: JSX.Element[] = [];
|
|
38
|
+
|
|
39
|
+
for (let i = 1; i <= count; i++) {
|
|
40
|
+
const items: JSX.Element[] = [];
|
|
41
|
+
|
|
42
|
+
for (let j = 1; j <= 3; j++) {
|
|
43
|
+
items.push(
|
|
44
|
+
<ItemParagraph
|
|
45
|
+
key={ 100 * i + j }
|
|
46
|
+
$color={ color }
|
|
47
|
+
$width={ getRandomNumber(60, 100) }
|
|
48
|
+
/>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
paragraphs.push(
|
|
53
|
+
<ContainerParagraph key={ i }>
|
|
54
|
+
{ items }
|
|
55
|
+
</ContainerParagraph>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return paragraphs;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export default Paragraph;
|
package/Loading/styles.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
|
+
import { Middle } from '@layouts/Full/styles';
|
|
2
3
|
|
|
3
4
|
export const ContainerGeneral = styled.div`
|
|
4
5
|
width: 100%;
|
|
@@ -17,15 +18,38 @@ export const ContainerInline = styled.div`
|
|
|
17
18
|
color: ${ props => props.theme.font.faded };
|
|
18
19
|
`;
|
|
19
20
|
|
|
20
|
-
export const
|
|
21
|
+
export const ContainerParagraphs = styled.div`
|
|
21
22
|
display: flex;
|
|
22
|
-
gap:
|
|
23
|
+
gap: 20px;
|
|
24
|
+
flex-direction: column;
|
|
23
25
|
padding: 15px 0;
|
|
24
26
|
`;
|
|
25
27
|
|
|
26
|
-
export const
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
export const ContainerParagraph = styled.div`
|
|
29
|
+
display: flex;
|
|
30
|
+
gap: 9px;
|
|
31
|
+
flex-direction: column;
|
|
32
|
+
`;
|
|
33
|
+
|
|
34
|
+
export const ItemParagraph = styled.div<{
|
|
35
|
+
$color: string
|
|
36
|
+
$width: number
|
|
37
|
+
$height?: number
|
|
38
|
+
}>`
|
|
39
|
+
width: ${ props => props.$width }%;
|
|
40
|
+
height: ${ props => props.$height ? props.$height : 11 }px;
|
|
29
41
|
background: ${ props => props.$color };
|
|
30
42
|
border-radius: 5px;
|
|
43
|
+
`;
|
|
44
|
+
|
|
45
|
+
export const ContainerBoxMiddle = styled(Middle)`
|
|
46
|
+
& > h1 {
|
|
47
|
+
margin-bottom: 15px;
|
|
48
|
+
}
|
|
49
|
+
`;
|
|
50
|
+
|
|
51
|
+
export const ContainerFull = styled.div`
|
|
52
|
+
flex: 1;
|
|
53
|
+
display: flex;
|
|
54
|
+
align-items: center;
|
|
31
55
|
`;
|
package/Meta.tsx
CHANGED