mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
Fix possibly\
This commit is contained in:
1 file changed
+10
-8
@@ -1,4 +1,4 @@
|
|||||||
import React, { FormEvent, useEffect, useMemo, useState } from 'react';
|
import React, { FormEvent, useCallback, useEffect, useMemo, useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { TextField, Button } from '@material-ui/core';
|
import { TextField, Button } from '@material-ui/core';
|
||||||
|
|
||||||
@@ -8,7 +8,6 @@ import { useHistory } from 'react-router-dom';
|
|||||||
|
|
||||||
const sendNuiCreateMessageGroup = ({ parts, isGroupChat, labelValue }) =>
|
const sendNuiCreateMessageGroup = ({ parts, isGroupChat, labelValue }) =>
|
||||||
Nui.send('phone:createMessageGroup', {
|
Nui.send('phone:createMessageGroup', {
|
||||||
asd: true,
|
|
||||||
phoneNumbers: parts,
|
phoneNumbers: parts,
|
||||||
label: isGroupChat && labelValue ? labelValue : null,
|
label: isGroupChat && labelValue ? labelValue : null,
|
||||||
});
|
});
|
||||||
@@ -25,20 +24,23 @@ const NewMessageGroupForm = ({ phoneNumber }: { phoneNumber?: string }) => {
|
|||||||
// handles phone numbers in a csv format and strips all spaces and
|
// handles phone numbers in a csv format and strips all spaces and
|
||||||
// external characters out of them:
|
// external characters out of them:
|
||||||
// 123-4567, 987-6543, 333-4444
|
// 123-4567, 987-6543, 333-4444
|
||||||
const parts = useMemo(
|
const getGroupParts = useCallback(
|
||||||
() => participants.split(',').map((part) => part.replace(/[^0-9]/g, '')),
|
(numbers) => numbers.split(',').map((part) => part.replace(/[^0-9]/g, '')),
|
||||||
[participants]
|
[]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const parts = useMemo(() => getGroupParts(participants), [participants, getGroupParts]);
|
||||||
|
|
||||||
const isGroupChat = parts.length > 1;
|
const isGroupChat = parts.length > 1;
|
||||||
|
|
||||||
const labelValue = label.trim();
|
const labelValue = label.trim();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (phoneNumber && parts) {
|
if (phoneNumber) {
|
||||||
sendNuiCreateMessageGroup({ parts, isGroupChat, labelValue });
|
sendNuiCreateMessageGroup({ parts: getGroupParts(phoneNumber), isGroupChat: false, labelValue });
|
||||||
history.push('/messages');
|
history.push('/messages');
|
||||||
}
|
}
|
||||||
}, [isGroupChat, parts, phoneNumber, labelValue, history]);
|
}, [phoneNumber, labelValue, history, getGroupParts]);
|
||||||
|
|
||||||
const handleSubmit = (event: FormEvent) => {
|
const handleSubmit = (event: FormEvent) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|||||||
Reference in new issue
Block a user