mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
Merge branch 'master' of https://github.com/project-error/new-phone-who-dis
This commit is contained in:
commit
31241c7e8f
9 files changed
+58
-23
No files matched your search
@@ -1,17 +1,19 @@
|
||||
import React, { useCallback, useEffect, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Box, Button, TextField } from '@material-ui/core';
|
||||
|
||||
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import { Autocomplete } from '@material-ui/lab';
|
||||
import { useContacts } from '../../../contacts/hooks/useContacts';
|
||||
import { Contact } from '../../../../../../typings/contact';
|
||||
import { MessageEvents } from '../../../../../../typings/messages';
|
||||
import { PHONE_NUMBER_REGEX } from '../../../../../../typings/phone';
|
||||
import { useSnackbar } from '../../../../ui/hooks/useSnackbar';
|
||||
|
||||
const NewMessageGroupForm = ({ phoneNumber }: { phoneNumber?: string }) => {
|
||||
const history = useHistory();
|
||||
const { t } = useTranslation();
|
||||
const { addAlert } = useSnackbar();
|
||||
const [participants, setParticipants] = useState([]);
|
||||
const [label, setLabel] = useState('');
|
||||
const { getContactByNumber, contacts } = useContacts();
|
||||
@@ -45,6 +47,10 @@ const NewMessageGroupForm = ({ phoneNumber }: { phoneNumber?: string }) => {
|
||||
const onAutocompleteChange = (_e, value: any) => {
|
||||
const lastIdx = value.length - 1;
|
||||
if (typeof value[lastIdx] === 'string') {
|
||||
const isValid = PHONE_NUMBER_REGEX.test(value[lastIdx]);
|
||||
if (!isValid) {
|
||||
return addAlert({ message: t('APPS_MESSAGES_INVALID_PHONE_NUMBER'), type: 'error' });
|
||||
}
|
||||
value.splice(lastIdx, 1, { number: value[lastIdx] });
|
||||
setParticipants(value);
|
||||
return;
|
||||
|
||||
@@ -8,6 +8,7 @@ import { useCallback } from 'react';
|
||||
import Nui from '../../../os/nui-events/utils/Nui';
|
||||
import { useLocation } from 'react-router';
|
||||
import { MessageEvents } from '../../../../../typings/messages';
|
||||
import { TOptionsBase } from 'i18next';
|
||||
|
||||
export const useMessagesService = () => {
|
||||
const { pathname } = useLocation();
|
||||
@@ -22,9 +23,9 @@ export const useMessagesService = () => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const handleAddAlert = useCallback(
|
||||
({ message, type }: IAlert) => {
|
||||
({ message, type, options = {} }: IAlert & { options: TOptionsBase }) => {
|
||||
addAlert({
|
||||
message: t(`APPS_${message}`),
|
||||
message: t(`${message}`, options),
|
||||
type,
|
||||
});
|
||||
},
|
||||
|
||||
@@ -145,6 +145,9 @@
|
||||
"APPS_MESSAGES_MESSAGE_GROUP_DUPLICATE": "This message group already exists",
|
||||
"APPS_MESSAGES_MESSAGE_GROUP_CREATE_FAILED": "Failed to create message group",
|
||||
"APPS_MESSAGES_MESSAGE_GROUP_CREATE_MINE": "You cannot add yourself!",
|
||||
"APPS_MESSAGES_MESSAGE_GROUP_CREATE_ALL_NUMBERS_FAILED": "None of the phone numbers could be found!",
|
||||
"APPS_MESSAGES_MESSAGE_GROUP_CREATE_ONE_NUMBER_FAILED": "{{ number }} is not a registered number",
|
||||
"APPS_MESSAGES_MESSAGE_GROUP_CREATE_SOME_NUMBERS_FAILED": "({{ numbers }}) are not registered numbers.",
|
||||
"APPS_MESSAGES_INPUT_NAME_OR_NUMBER": "Search contacts or type number and press enter",
|
||||
"APPS_MESSAGES_UNREAD_MESSAGES": "You have {{ count }} unread messages",
|
||||
"APPS_MESSAGES_MEMBERS_TITLE": "Members",
|
||||
|
||||
@@ -6,7 +6,7 @@ export interface IAlert {
|
||||
type: AlertType;
|
||||
}
|
||||
|
||||
export type AlertType = 'success' | 'error' | 'info';
|
||||
export type AlertType = 'success' | 'error' | 'info' | 'warning';
|
||||
|
||||
interface ISnackBar {
|
||||
addAlert: ({ message, type }: IAlert) => void;
|
||||
|
||||
Reference in new issue
Block a user