@autobusal/common 1.3.0 → 1.3.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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useRef } from 'react';
|
|
2
2
|
import { TFunction, i18n } from 'i18next';
|
|
3
|
-
import { IoGlobeOutline } from 'react-icons/io5';
|
|
4
3
|
import { useOutside } from '@autobusal/hooks';
|
|
4
|
+
import Flag from './Flag';
|
|
5
5
|
import { Container, Title, ContainerButtons, ButtonChange } from './styles';
|
|
6
6
|
import { useGetSettings } from '@autobusal/providers/services';
|
|
7
7
|
|
|
@@ -28,7 +28,7 @@ const ChangeLanguage = ({ type, t, i18n, onClose }: Props): JSX.Element => {
|
|
|
28
28
|
|
|
29
29
|
const items = available.map((item, index) => (
|
|
30
30
|
<ButtonChange key={ index } onClick={ () => onChange(item) }>
|
|
31
|
-
<
|
|
31
|
+
<Flag language={ item } size={ 22 } />
|
|
32
32
|
{ `${ t('languages.change', { ns: 'common' }) } ${ t(`languages.${ item }`, { ns: 'common' }) }` }
|
|
33
33
|
</ButtonChange>
|
|
34
34
|
));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ContainerFlag } from './styles';
|
|
2
|
+
|
|
3
|
+
interface Props {
|
|
4
|
+
language: string
|
|
5
|
+
size: number
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const Flag = ({ language, size }: Props): JSX.Element => (
|
|
9
|
+
<ContainerFlag $size={ size } src={ `${ import.meta.env.VITE_API_OBT }/languages/${ language }.svg` } />
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
export default Flag;
|
package/ChangeLanguage/styles.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import styled from 'styled-components';
|
|
1
|
+
import styled, { css } from 'styled-components';
|
|
2
2
|
|
|
3
3
|
export const Container = styled.div<{
|
|
4
4
|
$type: 'top' | 'bottom'
|
|
@@ -12,6 +12,11 @@ export const Container = styled.div<{
|
|
|
12
12
|
background-color: ${ props => props.theme.background.normal };
|
|
13
13
|
box-shadow: ${ props => props.theme.boxShadow };
|
|
14
14
|
border-radius: ${ props => props.theme.borderRadius };
|
|
15
|
+
|
|
16
|
+
${ props => props.$type === 'bottom' && css`
|
|
17
|
+
right: 10px;
|
|
18
|
+
bottom: 50px;
|
|
19
|
+
` }
|
|
15
20
|
`;
|
|
16
21
|
|
|
17
22
|
export const Title = styled.h5`
|
|
@@ -23,7 +28,13 @@ export const Title = styled.h5`
|
|
|
23
28
|
export const ContainerButtons = styled.div`
|
|
24
29
|
display: flex;
|
|
25
30
|
flex-direction: column;
|
|
26
|
-
gap:
|
|
31
|
+
gap: 6px;
|
|
32
|
+
`;
|
|
33
|
+
|
|
34
|
+
export const ContainerFlag = styled.img<{ $size: number }>`
|
|
35
|
+
display: block;
|
|
36
|
+
width: ${ props => props.$size }px;
|
|
37
|
+
border-radius: 4px;
|
|
27
38
|
`;
|
|
28
39
|
|
|
29
40
|
export const ButtonChange = styled.button`
|
|
@@ -33,13 +44,10 @@ export const ButtonChange = styled.button`
|
|
|
33
44
|
justify-content: center;
|
|
34
45
|
gap: 8px;
|
|
35
46
|
font-size: ${ props => props.theme.size.xs };
|
|
47
|
+
background: ${ props => props.theme.background.neutral };
|
|
36
48
|
border-radius: ${ props => props.theme.borderRadius };
|
|
37
49
|
transition: all 0.3s ease;
|
|
38
50
|
|
|
39
|
-
> svg {
|
|
40
|
-
color: ${ props => props.theme.primary.normal };
|
|
41
|
-
}
|
|
42
|
-
|
|
43
51
|
&:hover {
|
|
44
52
|
background-color: ${ props => props.theme.primary.neutral };
|
|
45
53
|
}
|
|
@@ -5,6 +5,7 @@ import { Editor } from '@tinymce/tinymce-react';
|
|
|
5
5
|
import { Editor as TinyMceEditor } from 'tinymce';
|
|
6
6
|
import { Validate } from '@autobusal/utilities/form';
|
|
7
7
|
import { Textarea } from './styles';
|
|
8
|
+
import { useFileUpload } from '../services';
|
|
8
9
|
|
|
9
10
|
interface Props {
|
|
10
11
|
name: string
|
|
@@ -18,10 +19,18 @@ interface Props {
|
|
|
18
19
|
const TextareaHtml = ({ name, value, validation, t, refs, onUpdate }: Props): JSX.Element => {
|
|
19
20
|
const editorRef = useRef<TinyMceEditor | null>(null);
|
|
20
21
|
|
|
22
|
+
const { mutateAsync: Upload } = useFileUpload();
|
|
23
|
+
|
|
21
24
|
const onChange = (content: string): void => {
|
|
22
25
|
onUpdate(name, content);
|
|
23
26
|
};
|
|
24
27
|
|
|
28
|
+
const onFileUpload = async (blobinfo: any): Promise<string> => {
|
|
29
|
+
const uploaded = await Upload(blobinfo);
|
|
30
|
+
|
|
31
|
+
return uploaded.filename;
|
|
32
|
+
};
|
|
33
|
+
|
|
25
34
|
return (
|
|
26
35
|
<div className="row-data">
|
|
27
36
|
<Editor
|
|
@@ -43,6 +52,7 @@ const TextareaHtml = ({ name, value, validation, t, refs, onUpdate }: Props): JS
|
|
|
43
52
|
'image media table | ' +
|
|
44
53
|
'removeformat | help'
|
|
45
54
|
),
|
|
55
|
+
images_upload_handler: onFileUpload,
|
|
46
56
|
content_style: 'body { font-family: Helvetica, Arial, sans-serif; font-size: 14px; }',
|
|
47
57
|
promotion: false,
|
|
48
58
|
highlight_on_focus: false
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { UseMutationResult, useMutation } from '@tanstack/react-query';
|
|
2
|
+
import { apiClient } from '@autobusal/providers';
|
|
3
|
+
import { UploadData } from '@autobusal/providers/types';
|
|
4
|
+
|
|
5
|
+
export const useFileUpload = (): UseMutationResult<UploadData, Error, any, unknown> => (
|
|
6
|
+
useMutation({
|
|
7
|
+
mutationKey: ['textarea-html'],
|
|
8
|
+
mutationFn: async (blobData) => {
|
|
9
|
+
const formData = new FormData();
|
|
10
|
+
|
|
11
|
+
formData.append('image', blobData.blob(), blobData.filename());
|
|
12
|
+
|
|
13
|
+
return await apiClient
|
|
14
|
+
.post('/api/label/admin/upload', formData, {
|
|
15
|
+
headers: {
|
|
16
|
+
'Content-Type': 'multipart/form-data'
|
|
17
|
+
}
|
|
18
|
+
})
|
|
19
|
+
.then(response => (
|
|
20
|
+
response.data
|
|
21
|
+
))
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
);
|