@autobusal/operator-routes 1.0.7 → 1.0.9

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.
@@ -4,7 +4,7 @@ import { BsPlusCircleFill } from 'react-icons/bs';
4
4
  import { Meta, BackWithTitle, Button, Table, Row } from '@autobusal/common';
5
5
  import { usePage } from '@autobusal/hooks';
6
6
  import { success } from '@autobusal/utilities';
7
- import { GetAlternates, PostAdd, DeleteAlternate } from '../../../modules/OperatorRoutes/Alternates/services';
7
+ import { useGetAlternates, usePostAdd, useDeleteAlternate } from './services';
8
8
 
9
9
  interface Props {
10
10
  url: string
@@ -24,11 +24,11 @@ const Browse = ({ url, backUrl, t }: Props): JSX.Element => {
24
24
 
25
25
  usePage('routes');
26
26
 
27
- const { data, isLoading, isFetching, refetch } = GetAlternates(id);
27
+ const { data, isLoading, isFetching, refetch } = useGetAlternates(id);
28
28
 
29
- const { mutate: Add, isPending } = PostAdd(id);
29
+ const { mutate: Add, isPending } = usePostAdd(id);
30
30
 
31
- const { mutate: Delete } = DeleteAlternate(id);
31
+ const { mutate: Delete } = useDeleteAlternate(id);
32
32
 
33
33
  if (id === 0) {
34
34
  return <Navigate to={ backUrl } />;
@@ -3,7 +3,7 @@ import { apiClient } from '@autobusal/providers';
3
3
  import { RouteData, AlternateData } from '@autobusal/providers/types/routes';
4
4
  import { ScheduleForm } from '../Prices/types';
5
5
 
6
- export const GetAlternates = (id: number): UseQueryResult<RouteData> => (
6
+ export const useGetAlternates = (id: number): UseQueryResult<RouteData> => (
7
7
  useQuery({
8
8
  queryKey: ['operator-alternates', { id }],
9
9
  queryFn: async () => (
@@ -18,7 +18,7 @@ export const GetAlternates = (id: number): UseQueryResult<RouteData> => (
18
18
  })
19
19
  );
20
20
 
21
- export const PostAdd = (id: number): UseMutationResult<AlternateData> => (
21
+ export const usePostAdd = (id: number): UseMutationResult<AlternateData> => (
22
22
  useMutation({
23
23
  mutationKey: ['operator-alternates-add', { id }],
24
24
  mutationFn: async () => (
@@ -31,7 +31,7 @@ export const PostAdd = (id: number): UseMutationResult<AlternateData> => (
31
31
  })
32
32
  );
33
33
 
34
- export const PostSchedule = (id: number, name: string): UseMutationResult<void, Error, ScheduleForm, unknown> => (
34
+ export const usePostSchedule = (id: number, name: string): UseMutationResult<void, Error, ScheduleForm, unknown> => (
35
35
  useMutation({
36
36
  mutationKey: ['operator-alternates-schedule', { id, name }],
37
37
  mutationFn: async (data: ScheduleForm) => (
@@ -48,7 +48,7 @@ export const PostSchedule = (id: number, name: string): UseMutationResult<void,
48
48
  })
49
49
  );
50
50
 
51
- export const DeleteAlternate = (id: number): UseMutationResult<void, Error, number, unknown> => (
51
+ export const useDeleteAlternate = (id: number): UseMutationResult<void, Error, number, unknown> => (
52
52
  useMutation({
53
53
  mutationKey: ['operator-alternates-delete'],
54
54
  mutationFn: async (name: number) => (
package/Browse.tsx CHANGED
@@ -4,7 +4,7 @@ import { Meta, Table, Row } from '@autobusal/common';
4
4
  import { usePage } from '@autobusal/hooks';
5
5
  import { getParams } from '@autobusal/utilities';
6
6
  import { Bags, Dates } from './Information';
7
- import { GetRoutes } from './services';
7
+ import { useGetRoutes } from './services';
8
8
 
9
9
  interface Props {
10
10
  url: string
@@ -16,7 +16,7 @@ const Browse = ({ url, t }: Props): JSX.Element => {
16
16
 
17
17
  usePage('routes');
18
18
 
19
- const { data, isLoading, isFetching } = GetRoutes(getParams(searchParams, ['page', 'sort', 'order', 'q']));
19
+ const { data, isLoading, isFetching } = useGetRoutes(getParams(searchParams, ['page', 'sort', 'order', 'q']));
20
20
 
21
21
  const rows = data?.data.map(item => (
22
22
  <Row
@@ -7,7 +7,7 @@ import Loading from './Loading';
7
7
  import { getStops } from '../utilities';
8
8
  import { Container, Title, ContainerAdd, Choose, Notice } from './styles';
9
9
  import { AddForm } from '../types';
10
- import { GetStops, AddLocation } from '../services';
10
+ import { useGetStops, useAddLocation } from '../services';
11
11
 
12
12
  interface Props {
13
13
  routeId: number
@@ -18,9 +18,9 @@ interface Props {
18
18
  const Add = ({ routeId, t, onReload }: Props): JSX.Element => {
19
19
  const { register, handleSubmit, formState: { errors } } = useForm<AddForm>();
20
20
 
21
- const { data, isLoading } = GetStops(routeId);
21
+ const { data, isLoading } = useGetStops(routeId);
22
22
 
23
- const { mutate: Save, isPending } = AddLocation(routeId);
23
+ const { mutate: Save, isPending } = useAddLocation(routeId);
24
24
 
25
25
  if (isLoading) {
26
26
  return <Loading t={ t } />;
@@ -6,7 +6,7 @@ import { getTomorrow } from '../utilities';
6
6
  import { Data } from './styles';
7
7
  import { LocationForm } from '../types';
8
8
  import { LocationData } from '@autobusal/providers/types/locations';
9
- import { PostMove, DeleteLocation, PostUpdate } from '../services';
9
+ import { usePostMove, useDeleteLocation, usePostUpdate } from '../services';
10
10
 
11
11
  interface Props {
12
12
  routeId: number
@@ -18,11 +18,11 @@ interface Props {
18
18
  const Item = ({ routeId, item, t, onReload }: Props): JSX.Element => {
19
19
  const { register, handleSubmit, formState: { errors } } = useForm<LocationForm>();
20
20
 
21
- const { mutate: Save, isPending: isPendingUpdate } = PostUpdate(routeId, item.id);
21
+ const { mutate: Save, isPending: isPendingUpdate } = usePostUpdate(routeId, item.id);
22
22
 
23
- const { mutate: Move, isPending: isPendingMove } = PostMove(routeId, item.id);
23
+ const { mutate: Move, isPending: isPendingMove } = usePostMove(routeId, item.id);
24
24
 
25
- const { mutate: Delete, isPending: isPendingDelete } = DeleteLocation(routeId, item.id);
25
+ const { mutate: Delete, isPending: isPendingDelete } = useDeleteLocation(routeId, item.id);
26
26
 
27
27
  const onSubmit = (data: LocationForm): void => {
28
28
  Save(data);
@@ -4,7 +4,7 @@ import { Meta, BackWithTitle, Report } from '@autobusal/common';
4
4
  import { usePage } from '@autobusal/hooks';
5
5
  import Add from './Add/Add';
6
6
  import Browse from './Browse/Browse';
7
- import { GetLocations } from './services';
7
+ import { useGetLocations } from './services';
8
8
 
9
9
  interface Props {
10
10
  url: string
@@ -20,7 +20,7 @@ const Manage = ({ url, t }: Props): JSX.Element => {
20
20
 
21
21
  usePage('routes');
22
22
 
23
- const { data, refetch } = GetLocations(id);
23
+ const { data, refetch } = useGetLocations(id);
24
24
 
25
25
  const onReload = (): void => {
26
26
  refetch();
@@ -4,7 +4,7 @@ import { RouteData } from '@autobusal/providers/types/routes';
4
4
  import { CountryData } from '@autobusal/providers/types/locations';
5
5
  import { AddForm, LocationForm } from './types';
6
6
 
7
- export const GetLocations = (id: number): UseSuspenseQueryResult<RouteData> => (
7
+ export const useGetLocations = (id: number): UseSuspenseQueryResult<RouteData> => (
8
8
  useSuspenseQuery({
9
9
  queryKey: ['operator-locations', { id }],
10
10
  queryFn: async () => (
@@ -19,7 +19,7 @@ export const GetLocations = (id: number): UseSuspenseQueryResult<RouteData> => (
19
19
  })
20
20
  );
21
21
 
22
- export const GetStops = (routeId: number): UseQueryResult<CountryData[]> => (
22
+ export const useGetStops = (routeId: number): UseQueryResult<CountryData[]> => (
23
23
  useQuery({
24
24
  queryKey: ['operator-stops', { routeId }],
25
25
  queryFn: async () => (
@@ -36,7 +36,7 @@ export const GetStops = (routeId: number): UseQueryResult<CountryData[]> => (
36
36
  })
37
37
  );
38
38
 
39
- export const AddLocation = (id: number): UseMutationResult<void, Error, AddForm, unknown> => (
39
+ export const useAddLocation = (id: number): UseMutationResult<void, Error, AddForm, unknown> => (
40
40
  useMutation({
41
41
  mutationKey: ['operator-locations-add', { id }],
42
42
  mutationFn: async (data: AddForm) => {
@@ -52,7 +52,7 @@ export const AddLocation = (id: number): UseMutationResult<void, Error, AddForm,
52
52
  })
53
53
  );
54
54
 
55
- export const PostMove = (id: number, location_id: number): UseMutationResult<void, Error, number, unknown> => (
55
+ export const usePostMove = (id: number, location_id: number): UseMutationResult<void, Error, number, unknown> => (
56
56
  useMutation({
57
57
  mutationKey: ['operator-locations-move', { id, location_id }],
58
58
  mutationFn: async (order: number) => (
@@ -69,7 +69,7 @@ export const PostMove = (id: number, location_id: number): UseMutationResult<voi
69
69
  })
70
70
  );
71
71
 
72
- export const DeleteLocation = (id: number, location_id: number): UseMutationResult<void> => (
72
+ export const useDeleteLocation = (id: number, location_id: number): UseMutationResult<void> => (
73
73
  useMutation({
74
74
  mutationKey: ['operator-locations-delete', { id, location_id }],
75
75
  mutationFn: async () => (
@@ -87,7 +87,7 @@ export const DeleteLocation = (id: number, location_id: number): UseMutationResu
87
87
  })
88
88
  );
89
89
 
90
- export const PostUpdate = (id: number, location_id: number): UseMutationResult<void, Error, LocationForm, unknown> => (
90
+ export const usePostUpdate = (id: number, location_id: number): UseMutationResult<void, Error, LocationForm, unknown> => (
91
91
  useMutation({
92
92
  mutationKey: ['operator-locations-update', { id, location_id }],
93
93
  mutationFn: async (data: LocationForm) => (
package/Manage.tsx CHANGED
@@ -12,7 +12,7 @@ import Options from './Options';
12
12
  import Seating from './Seating';
13
13
  import { getType, getLanguagesExtended, getTemplates, getBusType, getSeatingType, getTransiting } from './utilities';
14
14
  import { RouteData } from '@autobusal/providers/types/routes';
15
- import { GetRoute, PostRoute, DeleteRoute } from './services';
15
+ import { useGetRoute, usePostRoute, useDeleteRoute } from './services';
16
16
 
17
17
  interface Props {
18
18
  url: string
@@ -30,11 +30,11 @@ const Manage = ({ url, t }: Props): JSX.Element => {
30
30
 
31
31
  const navigate = useNavigate();
32
32
 
33
- const { data } = GetRoute(id);
33
+ const { data } = useGetRoute(id);
34
34
 
35
- const { mutate: Update, isPending: isPendingSave } = PostRoute(id, seating);
35
+ const { mutate: Update, isPending: isPendingSave } = usePostRoute(id, seating);
36
36
 
37
- const { mutate: Delete, isPending: isPendingDelete } = DeleteRoute();
37
+ const { mutate: Delete, isPending: isPendingDelete } = useDeleteRoute();
38
38
 
39
39
  const buses = useBuses();
40
40
 
package/Options.tsx CHANGED
@@ -4,7 +4,7 @@ import styled from 'styled-components';
4
4
  import { AiOutlineCopy, AiOutlineReload } from 'react-icons/ai';
5
5
  import { Button } from '@autobusal/common';
6
6
  import { success } from '@autobusal/utilities';
7
- import { PostCopy } from './services';
7
+ import { usePostCopy } from './services';
8
8
 
9
9
  interface Props {
10
10
  id: number
@@ -14,9 +14,9 @@ interface Props {
14
14
  const Options = ({ id, t }: Props): JSX.Element => {
15
15
  const navigate = useNavigate();
16
16
 
17
- const { mutate: Copy, isPending: isPendingCopy } = PostCopy(id);
17
+ const { mutate: Copy, isPending: isPendingCopy } = usePostCopy(id);
18
18
 
19
- const { mutate: Reverse, isPending: isPendingReverse } = PostCopy(id, true);
19
+ const { mutate: Reverse, isPending: isPendingReverse } = usePostCopy(id, true);
20
20
 
21
21
  const onCopy = (): void => {
22
22
  if (!window.confirm(t('operator_routes.manage.options.confirm', { ns: 'common' }))) {
@@ -6,7 +6,7 @@ import { Validate, Display, success } from '@autobusal/utilities';
6
6
  import { Prices, Actions } from './styles';
7
7
  import { PriceData } from '@autobusal/providers/types/routes';
8
8
  import { PriceForm } from '../types';
9
- import { PostPrice } from '../services';
9
+ import { usePostPrice } from '../services';
10
10
 
11
11
  interface Props {
12
12
  id: number
@@ -19,7 +19,7 @@ interface Props {
19
19
  const Item = ({ id, type, item, name, t }: Props): JSX.Element => {
20
20
  const { register, handleSubmit, formState: { errors } } = useForm<PriceForm>();
21
21
 
22
- const { mutate: Save, isPending } = PostPrice(id, item.id, type, name);
22
+ const { mutate: Save, isPending } = usePostPrice(id, item.id, type, name);
23
23
 
24
24
  const onSubmit = (data: PriceForm): void => {
25
25
  Save(data, {
package/Prices/Manage.tsx CHANGED
@@ -5,7 +5,7 @@ import { usePage } from '@autobusal/hooks';
5
5
  import Options from './Options/Options';
6
6
  import Schedule from './Schedule/Schedule';
7
7
  import Browse from './Browse/Browse';
8
- import { GetPrices } from './services';
8
+ import { useGetPrices } from './services';
9
9
 
10
10
  interface Props {
11
11
  type: 'normal' | 'alternate'
@@ -23,7 +23,7 @@ const Manage = ({ type, url, t }: Props): JSX.Element => {
23
23
 
24
24
  usePage('routes');
25
25
 
26
- const { data, refetch } = GetPrices(id, type, name);
26
+ const { data, refetch } = useGetPrices(id, type, name);
27
27
 
28
28
  const onReload = () => {
29
29
  refetch();
@@ -5,7 +5,7 @@ import { Inline } from '@autobusal/common';
5
5
  import { useOutside } from '@autobusal/hooks';
6
6
  import { success } from '@autobusal/utilities';
7
7
  import { Container, ButtonMore, Submenu, ButtonOption, Loading } from './styles';
8
- import { PostCopy } from '../services';
8
+ import { usePostCopy } from '../services';
9
9
 
10
10
  interface Props {
11
11
  id: number
@@ -20,7 +20,7 @@ const Options = ({ id, type, name, t, onReload }: Props): JSX.Element => {
20
20
 
21
21
  const ref = useRef(null);
22
22
 
23
- const { mutate: Copy, isPending } = PostCopy(id, type, name);
23
+ const { mutate: Copy, isPending } = usePostCopy(id, type, name);
24
24
 
25
25
  useOutside(ref, () => setShow(false));
26
26
 
@@ -5,7 +5,7 @@ import { Calendar, Button } from '@autobusal/common';
5
5
  import { Display, success } from '@autobusal/utilities';
6
6
  import { Container, Dates } from './styles';
7
7
  import { AlternateData } from '@autobusal/providers/types/routes';
8
- import { PostSchedule } from '../../Alternates/services';
8
+ import { usePostSchedule } from '../../Alternates/services';
9
9
  import { ScheduleForm } from '../types';
10
10
 
11
11
  interface Props {
@@ -21,7 +21,7 @@ const Schedule = ({ id, data, name, t }: Props): JSX.Element => {
21
21
  // we get the 1st value, as they're identical
22
22
  const details = data !== undefined ? data[0] : undefined;
23
23
 
24
- const { mutate: Save, isPending } = PostSchedule(id, name);
24
+ const { mutate: Save, isPending } = usePostSchedule(id, name);
25
25
 
26
26
  const onSubmit = (data: ScheduleForm): void => {
27
27
  Save(data, {
@@ -3,7 +3,7 @@ import { apiClient } from '@autobusal/providers';
3
3
  import { RouteData } from '@autobusal/providers/types/routes';
4
4
  import { PriceForm } from './types';
5
5
 
6
- export const GetPrices = (id: number, type: string, name: string): UseSuspenseQueryResult<RouteData> => (
6
+ export const useGetPrices = (id: number, type: string, name: string): UseSuspenseQueryResult<RouteData> => (
7
7
  useSuspenseQuery({
8
8
  queryKey: [`operator-prices-${ type }`, { id, type, name }],
9
9
  queryFn: async () => (
@@ -22,7 +22,7 @@ export const GetPrices = (id: number, type: string, name: string): UseSuspenseQu
22
22
  })
23
23
  );
24
24
 
25
- export const PostPrice = (id: number, price_id: number, type: ('normal' | 'alternate'), name: string): UseMutationResult<void, Error, PriceForm, unknown> => (
25
+ export const usePostPrice = (id: number, price_id: number, type: ('normal' | 'alternate'), name: string): UseMutationResult<void, Error, PriceForm, unknown> => (
26
26
  useMutation({
27
27
  mutationKey: ['operator-prices-save', { id, price_id, type, name }],
28
28
  mutationFn: async (data: PriceForm) => (
@@ -41,7 +41,7 @@ export const PostPrice = (id: number, price_id: number, type: ('normal' | 'alter
41
41
  })
42
42
  );
43
43
 
44
- export const PostCopy = (id: number, type: ('normal' | 'alternate'), name: string): UseMutationResult<void> => (
44
+ export const usePostCopy = (id: number, type: ('normal' | 'alternate'), name: string): UseMutationResult<void> => (
45
45
  useMutation({
46
46
  mutationKey: ['operator-prices-copy', { id, type, name }],
47
47
  mutationFn: async () => (
@@ -5,7 +5,7 @@ import { usePage } from '@autobusal/hooks';
5
5
  import { success } from '@autobusal/utilities';
6
6
  import { getSchedules } from './utilities';
7
7
  import { AvailableData } from '@autobusal/providers/types/routes';
8
- import { GetSchedule, PostSchedule } from './services';
8
+ import { useGetSchedule, usePostSchedule } from './services';
9
9
 
10
10
  interface Props {
11
11
  url: string
@@ -23,9 +23,9 @@ const Manage = ({ url, t }: Props): JSX.Element => {
23
23
 
24
24
  const navigate = useNavigate();
25
25
 
26
- const { data } = GetSchedule(id);
26
+ const { data } = useGetSchedule(id);
27
27
 
28
- const { mutate: Update, isPending } = PostSchedule(id);
28
+ const { mutate: Update, isPending } = usePostSchedule(id);
29
29
 
30
30
  if (id === 0) {
31
31
  return <Navigate to={ url } />;
@@ -2,7 +2,7 @@ import { UseMutationResult, UseSuspenseQueryResult, useMutation, useSuspenseQuer
2
2
  import { apiClient } from '@autobusal/providers';
3
3
  import { RouteData, AvailableData } from '@autobusal/providers/types/routes';
4
4
 
5
- export const GetSchedule = (id: number): UseSuspenseQueryResult<RouteData> => (
5
+ export const useGetSchedule = (id: number): UseSuspenseQueryResult<RouteData> => (
6
6
  useSuspenseQuery({
7
7
  queryKey: ['operator-schedule-manage', { id }],
8
8
  queryFn: async () => {
@@ -21,7 +21,7 @@ export const GetSchedule = (id: number): UseSuspenseQueryResult<RouteData> => (
21
21
  })
22
22
  );
23
23
 
24
- export const PostSchedule = (id: number): UseMutationResult<void, Error, AvailableData, unknown> => (
24
+ export const usePostSchedule = (id: number): UseMutationResult<void, Error, AvailableData, unknown> => (
25
25
  useMutation({
26
26
  mutationKey: ['operator-schedule-save', { id }],
27
27
  mutationFn: async (data: AvailableData) => (
package/Template.tsx CHANGED
@@ -3,7 +3,7 @@ import { TFunction } from 'i18next';
3
3
  import styled from 'styled-components';
4
4
  import { RiEyeFill } from 'react-icons/ri';
5
5
  import { Button, Modal } from '@autobusal/common';
6
- import { GetSettings } from '@autobusal/providers/services';
6
+ import { useGetSettings } from '@autobusal/providers/services';
7
7
 
8
8
  interface Props {
9
9
  type?: string
@@ -13,7 +13,7 @@ interface Props {
13
13
  const Template = ({ type, t }: Props): JSX.Element => {
14
14
  const [ show, setShow ] = useState<boolean>(false);
15
15
 
16
- const { data } = GetSettings();
16
+ const { data } = useGetSettings();
17
17
 
18
18
  if (!type) {
19
19
  return (
@@ -6,7 +6,7 @@ import { success } from '@autobusal/utilities';
6
6
  import Countries from './Countries';
7
7
  import { filterCountries } from './utilities';
8
8
  import { TransitingData } from '@autobusal/providers/types/routes';
9
- import { GetTransiting, PostTransiting, DeleteTransiting } from './services';
9
+ import { useGetTransiting, usePostTransiting, useDeleteTransiting } from './services';
10
10
 
11
11
  interface Props {
12
12
  url: string
@@ -24,11 +24,11 @@ const Manage = ({ url, t }: Props): JSX.Element => {
24
24
 
25
25
  const { data: CountriesData, isLoading } = useCountries('available');
26
26
 
27
- const { data, refetch } = GetTransiting(id);
27
+ const { data, refetch } = useGetTransiting(id);
28
28
 
29
- const { mutate: Update, isPending: isPendingSave } = PostTransiting(id);
29
+ const { mutate: Update, isPending: isPendingSave } = usePostTransiting(id);
30
30
 
31
- const { mutate: Delete, isPending: isPendingDelete } = DeleteTransiting(id);
31
+ const { mutate: Delete, isPending: isPendingDelete } = useDeleteTransiting(id);
32
32
 
33
33
  if (id === 0) {
34
34
  return <Navigate to={ url } />;
@@ -2,7 +2,7 @@ import { UseMutationResult, UseSuspenseQueryResult, useMutation, useSuspenseQuer
2
2
  import { apiClient } from '@autobusal/providers';
3
3
  import { RouteData, TransitingData } from '@autobusal/providers/types/routes';
4
4
 
5
- export const GetTransiting = (id: number): UseSuspenseQueryResult<RouteData> => (
5
+ export const useGetTransiting = (id: number): UseSuspenseQueryResult<RouteData> => (
6
6
  useSuspenseQuery({
7
7
  queryKey: ['operator-transiting', { id }],
8
8
  queryFn: async () => (
@@ -17,7 +17,7 @@ export const GetTransiting = (id: number): UseSuspenseQueryResult<RouteData> =>
17
17
  })
18
18
  );
19
19
 
20
- export const PostTransiting = (id: number): UseMutationResult<void, Error, TransitingData, unknown> => (
20
+ export const usePostTransiting = (id: number): UseMutationResult<void, Error, TransitingData, unknown> => (
21
21
  useMutation({
22
22
  mutationKey: ['operator-transiting-save', { id }],
23
23
  mutationFn: async (data: TransitingData) => (
@@ -33,7 +33,7 @@ export const PostTransiting = (id: number): UseMutationResult<void, Error, Trans
33
33
  })
34
34
  );
35
35
 
36
- export const DeleteTransiting = (id: number): UseMutationResult<void, Error, number, unknown> => (
36
+ export const useDeleteTransiting = (id: number): UseMutationResult<void, Error, number, unknown> => (
37
37
  useMutation({
38
38
  mutationKey: ['operator-transiting-delete'],
39
39
  mutationFn: async (countryId: number) => (
@@ -2,7 +2,7 @@ import { TFunction } from 'i18next';
2
2
  import { useParams, Navigate } from 'react-router-dom';
3
3
  import { Meta, BackWithTitle, Table, Row } from '@autobusal/common';
4
4
  import { usePage } from '@autobusal/hooks';
5
- import { GetUnavailableDates, DeleteUnavailable } from './services';
5
+ import { useGetUnavailableDates, useDeleteUnavailable } from './services';
6
6
 
7
7
  interface Props {
8
8
  url: string
@@ -18,9 +18,9 @@ const Browse = ({ url, t }: Props): JSX.Element => {
18
18
 
19
19
  usePage('routes');
20
20
 
21
- const { data, isLoading, isFetching, refetch } = GetUnavailableDates(id);
21
+ const { data, isLoading, isFetching, refetch } = useGetUnavailableDates(id);
22
22
 
23
- const { mutate: Delete } = DeleteUnavailable(id);
23
+ const { mutate: Delete } = useDeleteUnavailable(id);
24
24
 
25
25
  if (id === 0) {
26
26
  return <Navigate to={ url } />;
@@ -4,7 +4,7 @@ import { Meta, BackWithTitle, Viewer } from '@autobusal/common';
4
4
  import { usePage } from '@autobusal/hooks';
5
5
  import { success } from '@autobusal/utilities';
6
6
  import { UnavailableData } from '@autobusal/providers/types/routes';
7
- import { GetUnavailable, PostUnavailable, DeleteUnavailable } from './services';
7
+ import { useGetUnavailable, usePostUnavailable, useDeleteUnavailable } from './services';
8
8
 
9
9
  interface Props {
10
10
  url: string
@@ -23,11 +23,11 @@ const Manage = ({ url, t }: Props): JSX.Element => {
23
23
 
24
24
  const navigate = useNavigate();
25
25
 
26
- const { data } = GetUnavailable(routeId, id);
26
+ const { data } = useGetUnavailable(routeId, id);
27
27
 
28
- const { mutate: Update, isPending: isPendingSave } = PostUnavailable(routeId, id);
28
+ const { mutate: Update, isPending: isPendingSave } = usePostUnavailable(routeId, id);
29
29
 
30
- const { mutate: Delete, isPending: isPendingDelete } = DeleteUnavailable(routeId);
30
+ const { mutate: Delete, isPending: isPendingDelete } = useDeleteUnavailable(routeId);
31
31
 
32
32
  if (routeId === 0) {
33
33
  return <Navigate to={ url } />;
@@ -3,7 +3,7 @@ import { apiClient } from '@autobusal/providers';
3
3
  import { RouteData } from '@autobusal/providers/types/routes';
4
4
  import { UnavailableData } from '@autobusal/providers/types/routes';
5
5
 
6
- export const GetUnavailableDates = (id: number): UseQueryResult<RouteData> => (
6
+ export const useGetUnavailableDates = (id: number): UseQueryResult<RouteData> => (
7
7
  useQuery({
8
8
  queryKey: ['operators-unavailable', { id }],
9
9
  queryFn: async () => (
@@ -18,7 +18,7 @@ export const GetUnavailableDates = (id: number): UseQueryResult<RouteData> => (
18
18
  })
19
19
  );
20
20
 
21
- export const GetUnavailable = (routeId: number, id: number): UseSuspenseQueryResult<RouteData> => (
21
+ export const useGetUnavailable = (routeId: number, id: number): UseSuspenseQueryResult<RouteData> => (
22
22
  useSuspenseQuery({
23
23
  queryKey: ['operator-unavailable-manage', { routeId, id }],
24
24
  queryFn: async () => (
@@ -36,7 +36,7 @@ export const GetUnavailable = (routeId: number, id: number): UseSuspenseQueryRes
36
36
  })
37
37
  );
38
38
 
39
- export const PostUnavailable = (routeId: number, id: number): UseMutationResult<void, Error, UnavailableData, unknown> => (
39
+ export const usePostUnavailable = (routeId: number, id: number): UseMutationResult<void, Error, UnavailableData, unknown> => (
40
40
  useMutation({
41
41
  mutationKey: ['unavailable-operator-save', { routeId, id }],
42
42
  mutationFn: async (data: UnavailableData) => (
@@ -53,7 +53,7 @@ export const PostUnavailable = (routeId: number, id: number): UseMutationResult<
53
53
  })
54
54
  );
55
55
 
56
- export const DeleteUnavailable = (routeId: number): UseMutationResult<void, Error, number, unknown> => (
56
+ export const useDeleteUnavailable = (routeId: number): UseMutationResult<void, Error, number, unknown> => (
57
57
  useMutation({
58
58
  mutationKey: ['unavailable-operator-delete', { routeId }],
59
59
  mutationFn: async (id: number) => (
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autobusal/operator-routes",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "type": "module",
5
5
  "main": "index.ts"
6
6
  }
package/services.ts CHANGED
@@ -4,7 +4,7 @@ import { PaginationData } from '@autobusal/providers/types/pagination';
4
4
  import { RouteData } from '@autobusal/providers/types/routes';
5
5
  import { TableParamsData } from '@autobusal/providers/types/other';
6
6
 
7
- export const GetRoutes = (params: TableParamsData): UseQueryResult<PaginationData<RouteData>> => (
7
+ export const useGetRoutes = (params: TableParamsData): UseQueryResult<PaginationData<RouteData>> => (
8
8
  useQuery({
9
9
  queryKey: ['operator-routes', params],
10
10
  queryFn: async () => (
@@ -17,7 +17,7 @@ export const GetRoutes = (params: TableParamsData): UseQueryResult<PaginationDat
17
17
  })
18
18
  );
19
19
 
20
- export const GetRoute = (id: number): UseSuspenseQueryResult<RouteData> => (
20
+ export const useGetRoute = (id: number): UseSuspenseQueryResult<RouteData> => (
21
21
  useSuspenseQuery({
22
22
  queryKey: ['operator-routes-manage', { id }],
23
23
  queryFn: async () => {
@@ -36,7 +36,7 @@ export const GetRoute = (id: number): UseSuspenseQueryResult<RouteData> => (
36
36
  })
37
37
  );
38
38
 
39
- export const PostRoute = (id: number, seating: string): UseMutationResult<void, Error, RouteData, unknown> => (
39
+ export const usePostRoute = (id: number, seating: string): UseMutationResult<void, Error, RouteData, unknown> => (
40
40
  useMutation({
41
41
  mutationKey: ['operator-routes-save', { id, seating }],
42
42
  mutationFn: async (data: RouteData) => (
@@ -55,7 +55,7 @@ export const PostRoute = (id: number, seating: string): UseMutationResult<void,
55
55
  })
56
56
  );
57
57
 
58
- export const DeleteRoute = (): UseMutationResult<void, Error, number, unknown> => (
58
+ export const useDeleteRoute = (): UseMutationResult<void, Error, number, unknown> => (
59
59
  useMutation({
60
60
  mutationKey: ['operator-routes-delete'],
61
61
  mutationFn: async (id: number) => (
@@ -70,7 +70,7 @@ export const DeleteRoute = (): UseMutationResult<void, Error, number, unknown> =
70
70
  })
71
71
  );
72
72
 
73
- export const PostCopy = (id: number, reverse?: boolean): UseMutationResult<RouteData> => (
73
+ export const usePostCopy = (id: number, reverse?: boolean): UseMutationResult<RouteData> => (
74
74
  useMutation({
75
75
  mutationKey: [`operator-routes-copy${ reverse && '-reverse' }`, { id }],
76
76
  mutationFn: async () => (