mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
fix(phone/contacts): provide user feedback on max length data
This commit is contained in:
1 parent
02f0abd761
commit
dd99f7e241
4 files changed
+35
-9
No files matched your search
@@ -7,7 +7,7 @@ import { useContactActions } from '../../hooks/useContactActions';
|
||||
import ArrowBackIcon from '@material-ui/icons/ArrowBack';
|
||||
import LogDebugEvent from '../../../../os/debug/LogDebugEvents';
|
||||
import { useQueryParams } from '../../../../common/hooks/useQueryParams';
|
||||
import { Contact, ContactEvents } from '../../../../../../typings/contact';
|
||||
import { Contact, ContactEvents, ContactsDatabaseLimits } from '../../../../../../typings/contact';
|
||||
import { TextField } from '../../../../ui/components/Input';
|
||||
import { fetchNui } from '../../../../utils/fetchNui';
|
||||
import { ServerPromiseResp } from '../../../../../../typings/common';
|
||||
@@ -72,6 +72,24 @@ const ContactsInfoPage = () => {
|
||||
|
||||
const { t } = useTranslation();
|
||||
|
||||
const handleNumberChange: React.ChangeEventHandler<HTMLInputElement> = (e) => {
|
||||
const inputVal = e.target.value;
|
||||
if (inputVal.length === ContactsDatabaseLimits.number) return;
|
||||
setNumber(e.target.value);
|
||||
};
|
||||
|
||||
const handleDisplayChange: React.ChangeEventHandler<HTMLInputElement> = (e) => {
|
||||
const inputVal = e.target.value;
|
||||
if (inputVal.length === ContactsDatabaseLimits.display) return;
|
||||
setName(e.target.value);
|
||||
};
|
||||
|
||||
const handleAvatarChange: React.ChangeEventHandler<HTMLInputElement> = (e) => {
|
||||
const inputVal = e.target.value;
|
||||
if (inputVal.length === ContactsDatabaseLimits.avatar) return;
|
||||
setAvatar(e.target.value);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (addNumber) {
|
||||
setNumber(addNumber);
|
||||
@@ -173,9 +191,10 @@ const ContactsInfoPage = () => {
|
||||
<MuiAvatar className={classes.avatar} src={avatar} />
|
||||
<TextField
|
||||
autoFocus
|
||||
error={name.length === ContactsDatabaseLimits.display}
|
||||
className={classes.input}
|
||||
value={name}
|
||||
onChange={(e) => setName(e.target.value)}
|
||||
onChange={handleDisplayChange}
|
||||
label={t('APPS_CONTACT_FORM_NAME')}
|
||||
fullWidth
|
||||
inputProps={{
|
||||
@@ -184,8 +203,8 @@ const ContactsInfoPage = () => {
|
||||
/>
|
||||
<TextField
|
||||
className={classes.input}
|
||||
value={number}
|
||||
onChange={(e) => setNumber(e.target.value)}
|
||||
value={number.length === ContactsDatabaseLimits.number}
|
||||
onChange={handleNumberChange}
|
||||
label={t('APPS_CONTACT_FORM_NUMBER')}
|
||||
fullWidth
|
||||
inputProps={{
|
||||
@@ -193,11 +212,12 @@ const ContactsInfoPage = () => {
|
||||
}}
|
||||
/>
|
||||
<TextField
|
||||
error={avatar.length === ContactsDatabaseLimits.avatar}
|
||||
className={classes.input}
|
||||
label={t('APPS_CONTACT_FORM_AVATAR')}
|
||||
fullWidth
|
||||
value={avatar}
|
||||
onChange={(e) => setAvatar(e.target.value)}
|
||||
onChange={handleAvatarChange}
|
||||
inputProps={{
|
||||
className: classes.inputProps,
|
||||
}}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import React, { useCallback } from 'react';
|
||||
import MUITextField from '@material-ui/core/TextField';
|
||||
import MUIInputBase from '@material-ui/core/InputBase';
|
||||
import MUIInputBase, { InputBaseProps } from '@material-ui/core/InputBase';
|
||||
import { useNuiRequest } from 'fivem-nui-react-lib';
|
||||
import { PhoneEvents } from '../../../../typings/phone';
|
||||
import { TextFieldProps } from '@material-ui/core/TextField/TextField';
|
||||
|
||||
const useToggleFocus = () => {
|
||||
const Nui = useNuiRequest();
|
||||
@@ -16,7 +17,7 @@ const useToggleFocus = () => {
|
||||
);
|
||||
};
|
||||
|
||||
export const TextField = (props) => {
|
||||
export const TextField: React.FC<TextFieldProps> = (props) => {
|
||||
const toggleKeys = useToggleFocus();
|
||||
return (
|
||||
<MUITextField
|
||||
@@ -37,7 +38,7 @@ export const TextField = (props) => {
|
||||
);
|
||||
};
|
||||
|
||||
export const InputBase = (props) => {
|
||||
export const InputBase: React.FC<InputBaseProps> = (props) => {
|
||||
const toggleKeys = useToggleFocus();
|
||||
return (
|
||||
<MUIInputBase
|
||||
|
||||
Reference in new issue
Block a user