@autobusal/common 1.0.5 → 1.0.7

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.
@@ -3,7 +3,7 @@ import { Paragraph } from '../index';
3
3
  import { success } from '@autobusal/utilities';
4
4
  import DevPos from './Devpos';
5
5
  import { DevPosForm } from './types';
6
- import { GetSettings, PostSettings } from './services';
6
+ import { useGetSettings, usePostSettings } from './services';
7
7
 
8
8
  interface Props {
9
9
  id: number
@@ -12,9 +12,9 @@ interface Props {
12
12
  }
13
13
 
14
14
  const Content = ({ id, type, t }: Props): JSX.Element => {
15
- const { data, isLoading } = GetSettings(id, type);
15
+ const { data, isLoading } = useGetSettings(id, type);
16
16
 
17
- const { mutate: SaveSettings, isPending } = PostSettings(id, type);
17
+ const { mutate: SaveSettings, isPending } = usePostSettings(id, type);
18
18
 
19
19
  if (isLoading) {
20
20
  return <Paragraph count={ 3 } />;
@@ -3,7 +3,7 @@ import { apiClient } from '@autobusal/providers';
3
3
  import { ApiDetailsData } from '@autobusal/providers/types/users';
4
4
  import { DevPosForm } from './types';
5
5
 
6
- export const GetSettings = (id: number, type: string): UseQueryResult<ApiDetailsData | string> => (
6
+ export const useGetSettings = (id: number, type: string): UseQueryResult<ApiDetailsData | string> => (
7
7
  useQuery({
8
8
  queryKey: ['apidetails-get-settings', { id, type }],
9
9
  queryFn: async () => (
@@ -21,7 +21,7 @@ export const GetSettings = (id: number, type: string): UseQueryResult<ApiDetails
21
21
  })
22
22
  );
23
23
 
24
- export const PostSettings = (id: number, type: string): UseMutationResult<void, Error, DevPosForm, unknown> => (
24
+ export const usePostSettings = (id: number, type: string): UseMutationResult<void, Error, DevPosForm, unknown> => (
25
25
  useMutation({
26
26
  mutationKey: ['apidetails-update-settings'],
27
27
  mutationFn: async (data: DevPosForm) => (
@@ -3,7 +3,7 @@ import { TFunction, i18n } from 'i18next';
3
3
  import { IoGlobeOutline } from 'react-icons/io5';
4
4
  import { useOutside } from '@autobusal/hooks';
5
5
  import { Container, Title, ContainerButtons, ButtonChange } from './styles';
6
- import { GetSettings } from '@autobusal/providers/services';
6
+ import { useGetSettings } from '@autobusal/providers/services';
7
7
 
8
8
  interface Props {
9
9
  type: 'top' | 'bottom'
@@ -15,7 +15,7 @@ interface Props {
15
15
  const ChangeLanguage = ({ type, t, i18n, onClose }: Props): JSX.Element => {
16
16
  const ref = useRef<HTMLDivElement>(null);
17
17
 
18
- const { data } = GetSettings();
18
+ const { data } = useGetSettings();
19
19
 
20
20
  useOutside(ref, onClose);
21
21
 
package/IpLogs/View.tsx CHANGED
@@ -1,7 +1,7 @@
1
1
  import { TFunction } from 'i18next';
2
2
  import { Table, Row } from '../index';
3
3
  import { Container } from './styles';
4
- import { GetLogs } from './services';
4
+ import { useGetLogs } from './services';
5
5
 
6
6
  interface Props {
7
7
  id: number
@@ -11,7 +11,7 @@ interface Props {
11
11
  }
12
12
 
13
13
  const View = ({ id, page, type, t }: Props): JSX.Element => {
14
- const { data, isLoading, isFetching } = GetLogs(id, type, page);
14
+ const { data, isLoading, isFetching } = useGetLogs(id, type, page);
15
15
 
16
16
  const rows = data?.data.map(item => (
17
17
  <Row
@@ -3,7 +3,7 @@ import { apiClient } from '@autobusal/providers';
3
3
  import { LogData } from '@autobusal/providers/types/users';
4
4
  import { PaginationData } from '@autobusal/providers/types/pagination';
5
5
 
6
- export const GetLogs = (id: number, type: string, page: number): UseQueryResult<PaginationData<LogData>> => (
6
+ export const useGetLogs = (id: number, type: string, page: number): UseQueryResult<PaginationData<LogData>> => (
7
7
  useQuery({
8
8
  queryKey: ['ip-logs', { id, type, page }],
9
9
  queryFn: async () => {
package/Policy/Policy.tsx CHANGED
@@ -1,6 +1,6 @@
1
1
  import { TFunction } from 'i18next';
2
2
  import Modal from '../Modal/Modal';
3
- import { GetPolicy } from './services';
3
+ import { useGetPolicy } from './services';
4
4
 
5
5
  interface Props {
6
6
  id: number
@@ -9,7 +9,7 @@ interface Props {
9
9
  }
10
10
 
11
11
  const Policy = ({ id, t, onClose }: Props): JSX.Element => {
12
- const { data, isFetching } = GetPolicy(id);
12
+ const { data, isFetching } = useGetPolicy(id);
13
13
 
14
14
  return (
15
15
  <Modal
@@ -2,7 +2,7 @@ import { useQuery, UseQueryResult } from '@tanstack/react-query';
2
2
  import { apiClient } from '@autobusal/providers';
3
3
  import { PolicyData } from '@autobusal/providers/types/routes';
4
4
 
5
- export const GetPolicy = (id: number): UseQueryResult<PolicyData> => (
5
+ export const useGetPolicy = (id: number): UseQueryResult<PolicyData> => (
6
6
  useQuery({
7
7
  queryKey: ['route-policy', { id }],
8
8
  queryFn: async () => (
package/Report/Send.tsx CHANGED
@@ -5,7 +5,7 @@ import { Button } from '../index';
5
5
  import { Validate, Display } from '@autobusal/utilities';
6
6
  import { Success } from './styles';
7
7
  import { ReportForm } from './types';
8
- import { PostReport } from './services';
8
+ import { usePostReport } from './services';
9
9
 
10
10
  interface Props {
11
11
  type: string
@@ -15,7 +15,7 @@ interface Props {
15
15
  const Send = ({ type, t }: Props): JSX.Element => {
16
16
  const { register, handleSubmit, formState: { errors } } = useForm<ReportForm>();
17
17
 
18
- const { mutate: Send, isPending, isSuccess } = PostReport(type);
18
+ const { mutate: Send, isPending, isSuccess } = usePostReport(type);
19
19
 
20
20
  const onSubmit = (data: ReportForm): void => {
21
21
  Send(data);
@@ -2,7 +2,7 @@ import { UseMutationResult, useMutation } from '@tanstack/react-query';
2
2
  import { apiClient } from '@autobusal/providers';
3
3
  import { ReportForm } from './types';
4
4
 
5
- export const PostReport = (type: string): UseMutationResult<void, Error, ReportForm, unknown> => (
5
+ export const usePostReport = (type: string): UseMutationResult<void, Error, ReportForm, unknown> => (
6
6
  useMutation({
7
7
  mutationKey: ['operator-locations-move', { type }],
8
8
  mutationFn: async (data: ReportForm) => (
package/Viewer/Data.tsx CHANGED
@@ -32,7 +32,7 @@ const Data = ({ id, item, refs, t, onUpdate }: Props): (JSX.Element | null) => {
32
32
 
33
33
  switch (item.type) {
34
34
  case 'checkbox':
35
- return <input type="checkbox" value={ 1 } defaultChecked={ Number(item.value) == 1 } { ...refs(item.name, Validate(String(item.rules), t)) } />;
35
+ return <input type="checkbox" value={ 1 } defaultChecked={ Number(item.value) === 1 } { ...refs(item.name, Validate(String(item.rules), t)) } />;
36
36
 
37
37
  case 'checkbox-list':
38
38
  case 'checkbox-list-all':
@@ -29,6 +29,7 @@ const TextareaHtml = ({ name, value, validation, t, refs, onUpdate }: Props): JS
29
29
  onEditorChange={ onChange }
30
30
  initialValue={ value ?? '' }
31
31
  tinymceScriptSrc="/tinymce/tinymce.min.js"
32
+ licenseKey="gpl"
32
33
  init={{
33
34
  height: 350,
34
35
  menubar: false,
@@ -0,0 +1,14 @@
1
+ import { TFunction } from 'i18next';
2
+ import { Inline } from '../Loading/Loading';
3
+
4
+ interface Props {
5
+ t: TFunction<'common'>
6
+ }
7
+
8
+ const Loading = ({ t }: Props): JSX.Element => (
9
+ <div className="box">
10
+ <Inline text={ t('table.loading_data', { ns: 'common' }) } />
11
+ </div>
12
+ );
13
+
14
+ export default Loading;
package/Viewer/Viewer.tsx CHANGED
@@ -1,5 +1,6 @@
1
1
  import { useForm } from 'react-hook-form';
2
2
  import { TFunction } from 'i18next';
3
+ import Loading from './Loading';
3
4
  import Item from './Item';
4
5
  import Actions from './Actions';
5
6
  import { Container } from './styles';
@@ -9,6 +10,7 @@ interface Props {
9
10
  id: number
10
11
  type?: 'simple'
11
12
  data: ViewData[]
13
+ fetching?: boolean
12
14
  pending?: boolean
13
15
  actions?: string[]
14
16
  t: TFunction<'common'>
@@ -16,8 +18,12 @@ interface Props {
16
18
  onDelete?: (data?: any) => void
17
19
  }
18
20
 
19
- const Viewer = ({ id, type, data, pending, actions, t, onSave, onDelete }: Props): JSX.Element => {
21
+ const Viewer = ({ id, type, data, fetching, pending, actions, t, onSave, onDelete }: Props): JSX.Element => {
20
22
  const { register, handleSubmit, formState: { errors }, setValue } = useForm<any>();
23
+
24
+ if (fetching) {
25
+ return <Loading t={ t } />;
26
+ }
21
27
 
22
28
  const items = data.map((item, index) => (
23
29
  <Item
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autobusal/common",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "type": "module",
5
5
  "main": "index.ts"
6
6
  }