Merge branch 'feature/amiriis_add_units' into 'develop'
Feature/amiriis add units See merge request witel-front-end/rms!70
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import DamagesPage from "@/components/dashboard/receipt/damages";
|
||||
import DamagesPage from "@/components/dashboard/damageItems";
|
||||
import WithPermission from "@/core/middlewares/withPermission";
|
||||
|
||||
const Page = () => {
|
||||
@@ -477,7 +477,7 @@ export const pageMenu = [
|
||||
id: "damageItems",
|
||||
label: "آیتم خسارات",
|
||||
type: "page",
|
||||
route: "/dashboard/receipt/damages",
|
||||
route: "/dashboard/damage-items",
|
||||
icon: <GppMaybeIcon sx={{ width: "inherit", height: "inherit" }} />,
|
||||
permissions: ["manage-damage"],
|
||||
},
|
||||
|
||||
49
src/lib/hooks/usePersianInput.js
Normal file
49
src/lib/hooks/usePersianInput.js
Normal file
@@ -0,0 +1,49 @@
|
||||
import { useEffect } from 'react';
|
||||
function usePersianInput(inputRef, onChange) {
|
||||
useEffect(() => {
|
||||
const input = inputRef.current;
|
||||
if (!input) return;
|
||||
|
||||
const handleInput = (event) => {
|
||||
const originalValue = event.target.value;
|
||||
const filteredValue = originalValue.replace(/[A-Za-z]/g, '');
|
||||
if (filteredValue !== originalValue) {
|
||||
event.target.value = filteredValue;
|
||||
if (onChange) {
|
||||
onChange(filteredValue);
|
||||
}
|
||||
} else if (onChange) {
|
||||
onChange(originalValue);
|
||||
}
|
||||
};
|
||||
|
||||
const handleKeyDown = (event) => {
|
||||
const controlKeys = [
|
||||
'Backspace',
|
||||
'Delete',
|
||||
'Tab',
|
||||
'Escape',
|
||||
'Enter',
|
||||
'ArrowLeft',
|
||||
'ArrowRight',
|
||||
'ArrowUp',
|
||||
'ArrowDown'
|
||||
];
|
||||
if (controlKeys.includes(event.key)) return;
|
||||
|
||||
if (/[A-Za-z]/.test(event.key)) {
|
||||
event.preventDefault();
|
||||
}
|
||||
};
|
||||
|
||||
input.addEventListener('input', handleInput);
|
||||
input.addEventListener('keydown', handleKeyDown);
|
||||
|
||||
return () => {
|
||||
input.removeEventListener('input', handleInput);
|
||||
input.removeEventListener('keydown', handleKeyDown);
|
||||
};
|
||||
}, [inputRef, onChange]);
|
||||
}
|
||||
|
||||
export default usePersianInput;
|
||||
Reference in New Issue
Block a user