@autobusal/operator-routes 1.10.0 → 1.10.2
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/CHANGELOG.md +4 -0
- package/Manage.tsx +20 -1
- package/Prices/Browse/Browse.tsx +48 -15
- package/Prices/Browse/Group.tsx +207 -0
- package/Prices/Browse/styles.ts +236 -8
- package/Prices/Manage.tsx +1 -1
- package/Prices/services.ts +41 -2
- package/Prices/types.ts +23 -0
- package/Prices/utilities.ts +73 -0
- package/Pricing/Manage.tsx +279 -0
- package/Pricing/services.ts +76 -0
- package/Pricing/styles.ts +166 -0
- package/index.ts +2 -0
- package/package.json +1 -1
- package/types.ts +40 -1
- package/Prices/Browse/Item.tsx +0 -106
package/Prices/Browse/Item.tsx
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { TFunction } from 'i18next';
|
|
2
|
-
import { useForm } from 'react-hook-form';
|
|
3
|
-
import { BiEditAlt } from 'react-icons/bi';
|
|
4
|
-
import { Button } from '@autobusal/common';
|
|
5
|
-
import { Validate, Display, success } from '@autobusal/utilities';
|
|
6
|
-
import { Prices, Actions } from './styles';
|
|
7
|
-
import { PriceData } from '@autobusal/providers/types/routes';
|
|
8
|
-
import { PriceForm } from '../types';
|
|
9
|
-
import { usePostPrice } from '../services';
|
|
10
|
-
|
|
11
|
-
interface Props {
|
|
12
|
-
id: number
|
|
13
|
-
type: 'normal' | 'alternate'
|
|
14
|
-
item: PriceData
|
|
15
|
-
name: string
|
|
16
|
-
t: TFunction<'normal'>
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const Item = ({ id, type, item, name, t }: Props): JSX.Element => {
|
|
20
|
-
const { register, handleSubmit, formState: { errors } } = useForm<PriceForm>();
|
|
21
|
-
|
|
22
|
-
const { mutate: Save, isPending } = usePostPrice(id, item.id, type, name);
|
|
23
|
-
|
|
24
|
-
const onSubmit = (data: PriceForm): void => {
|
|
25
|
-
Save(data, {
|
|
26
|
-
onSuccess: () => success(t('prices_manage.messages.saved', { ns: 'common' }))
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<div className="box">
|
|
32
|
-
<h4>
|
|
33
|
-
{ item.from.city.name } ({ item.from.city.country?.name }) › { item.to.city.name } ({ item.to.city.country?.name })
|
|
34
|
-
</h4>
|
|
35
|
-
|
|
36
|
-
<form onSubmit={ handleSubmit(onSubmit) }>
|
|
37
|
-
<Prices>
|
|
38
|
-
<div className="row">
|
|
39
|
-
{ t('prices_manage.prices.adult', { ns: 'common' }) }
|
|
40
|
-
|
|
41
|
-
<input type="number" defaultValue={ item.adult } { ...register('adult', Validate('required', t)) } />
|
|
42
|
-
|
|
43
|
-
{ Display(errors.adult) }
|
|
44
|
-
</div>
|
|
45
|
-
|
|
46
|
-
<div className="row">
|
|
47
|
-
{ t('prices_manage.prices.child', { ns: 'common' }) }
|
|
48
|
-
|
|
49
|
-
<input type="number" defaultValue={ item.child } { ...register('child', Validate('required', t)) } />
|
|
50
|
-
|
|
51
|
-
{ Display(errors.child) }
|
|
52
|
-
</div>
|
|
53
|
-
|
|
54
|
-
<div className="row">
|
|
55
|
-
{ t('prices_manage.prices.baby', { ns: 'common' }) }
|
|
56
|
-
|
|
57
|
-
<input type="number" defaultValue={ item.baby } { ...register('baby', Validate('required', t)) } />
|
|
58
|
-
|
|
59
|
-
{ Display(errors.baby) }
|
|
60
|
-
</div>
|
|
61
|
-
</Prices>
|
|
62
|
-
|
|
63
|
-
<Prices>
|
|
64
|
-
<div className="row">
|
|
65
|
-
{ t('prices_manage.prices.adult_return', { ns: 'common' }) }
|
|
66
|
-
|
|
67
|
-
<input type="number" defaultValue={ item.adult_return } { ...register('adult_return', Validate('required', t)) } />
|
|
68
|
-
|
|
69
|
-
{ Display(errors.adult_return) }
|
|
70
|
-
</div>
|
|
71
|
-
|
|
72
|
-
<div className="row">
|
|
73
|
-
{ t('prices_manage.prices.child_return', { ns: 'common' }) }
|
|
74
|
-
|
|
75
|
-
<input type="number" defaultValue={ item.child_return } { ...register('child_return', Validate('required', t)) } />
|
|
76
|
-
|
|
77
|
-
{ Display(errors.child_return) }
|
|
78
|
-
</div>
|
|
79
|
-
|
|
80
|
-
<div className="row">
|
|
81
|
-
{ t('prices_manage.prices.baby_return', { ns: 'common' }) }
|
|
82
|
-
|
|
83
|
-
<input type="number" defaultValue={ item.baby_return } { ...register('baby_return', Validate('required', t)) } />
|
|
84
|
-
|
|
85
|
-
{ Display(errors.baby_return) }
|
|
86
|
-
</div>
|
|
87
|
-
</Prices>
|
|
88
|
-
|
|
89
|
-
<Actions>
|
|
90
|
-
<Button
|
|
91
|
-
type="submit"
|
|
92
|
-
loading={ isPending }
|
|
93
|
-
text={
|
|
94
|
-
<>
|
|
95
|
-
<BiEditAlt />
|
|
96
|
-
{ t('table.actions.update', { ns: 'common' }) }
|
|
97
|
-
</>
|
|
98
|
-
}
|
|
99
|
-
/>
|
|
100
|
-
</Actions>
|
|
101
|
-
</form>
|
|
102
|
-
</div>
|
|
103
|
-
);
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
export default Item;
|