Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(messaging-view): In ticket show a note with allowed attachment type and size #458

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions assets/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@
"virtualClassroom_plural": "Virtual classrooms",
"visualization": "Visualization",
"year": "year",
"yesterday": "Yesterday"
"yesterday": "Yesterday",
"sizeExc": "Excessive file size, maximum 32 MB"
},
"contactsScreen": {
"cancelRecentSearch": "Remove",
Expand Down Expand Up @@ -505,7 +506,7 @@
"youHaveUnreadMessages": "You have {{total}} unread messages"
},
"messagingView": {
"pickFile": "Pick file",
"pickFile": "Pick file max 32MB",
"pickFileHint": "From your device or from the cloud",
"pickPhoto": "Pick image",
"pickPhotoHint": "From your library",
Expand Down
5 changes: 3 additions & 2 deletions assets/translations/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@
"virtualClassroom_plural": "Virtual classroom",
"visualization": "Visualizzazione",
"year": "anno",
"yesterday": "Ieri"
"yesterday": "Ieri",
"sizeExc": "File di dimensioni eccessive, massimo 32 MB"
},
"contactsScreen": {
"cancelRecentSearch": "Rimuovi",
Expand Down Expand Up @@ -505,7 +506,7 @@
"youHaveUnreadMessages": "Hai {{total}} messaggi non letti"
},
"messagingView": {
"pickFile": "Scegli un file",
"pickFile": "Scegli un file max 32MB",
"pickFileHint": "Dal tuo dispositivo o dal cloud",
"pickPhoto": "Scegli un'immagine",
"pickPhotoHint": "Dalla tua galleria",
Expand Down
24 changes: 21 additions & 3 deletions src/features/tickets/components/MessagingView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { MenuView } from '@react-native-menu/menu';

import { TranslucentView } from '../../../core/components/TranslucentView';
import { IS_IOS } from '../../../core/constants';
import { useFeedbackContext } from '../../../core/contexts/FeedbackContext';
import { pdfSizes } from '../../courses/constants';
import { Attachment } from '../../services/types/Attachment';
import { AttachmentChip } from './AttachmentChip';
Expand Down Expand Up @@ -49,11 +50,28 @@ export const MessagingView = ({
}: Props) => {
const { t } = useTranslation();
const styles = useStylesheet(createStyles);

const types = [
DocumentPicker.types.pdf,
DocumentPicker.types.images,
DocumentPicker.types.video,
DocumentPicker.types.zip,
DocumentPicker.types.doc,
DocumentPicker.types.docx,
DocumentPicker.types.xlsx,
DocumentPicker.types.xls,
];
const { setFeedback } = useFeedbackContext();
const pickFile = async () => {
DocumentPicker.pickSingle().then(res => {
DocumentPicker.pickSingle({ type: types }).then(res => {
if (!res.name || !res.size || !res.type) return;

if (res.size > 32 * 1000000) {
setFeedback({
text: t('common.sizeExc'),
isError: true,
isPersistent: false,
});
return;
}
onAttachmentChange({
uri: res.uri,
name: res.name,
Expand Down
Loading