...
This commit is contained in:
@@ -498,6 +498,7 @@
|
||||
"trunk_of": "Trunk Of",
|
||||
"title": "Trunks",
|
||||
"trunk_placeholder": "Select Trunk",
|
||||
"missing_trunk": "Missing SIP trunk (remove and reassign)",
|
||||
"row_trunk": "SIP Trunk",
|
||||
"row_duration": "Duration (min)",
|
||||
"row_status": "Enable",
|
||||
@@ -1281,6 +1282,7 @@
|
||||
"lastName": "Last Name",
|
||||
"firstName": "First Name",
|
||||
"companyName": "Company Name",
|
||||
"companyName_error": "Enter company name",
|
||||
"lastName_error": "Enter last name",
|
||||
"firstName_error": "Enter First Name",
|
||||
"email": "Email",
|
||||
|
||||
@@ -485,6 +485,7 @@
|
||||
"trunk": {
|
||||
"sip_trunk": "ترانک",
|
||||
"trunk_placeholder": "انتخاب ترانک...",
|
||||
"missing_trunk": "ترانک سیپ موجود نیست؛ حذف و دوباره انتخاب کنید",
|
||||
"duration": "(دقیقه)مدت زمان",
|
||||
"trunk_of": "ترانک های",
|
||||
"title": "تنظیمات ترانک",
|
||||
@@ -1280,6 +1281,7 @@
|
||||
"firstName": "نام",
|
||||
"lastName": "نام خانوادگی",
|
||||
"companyName": "نام شرکت",
|
||||
"companyName_error": "نام شرکت را وارد کنید",
|
||||
"firstName_error": "نام را وارد کنید",
|
||||
"lastName_error": "نام خانوادگی را وارد کنید",
|
||||
"email": "ایمیل",
|
||||
|
||||
@@ -8,6 +8,7 @@ export interface IAppInfo {
|
||||
website?: string;
|
||||
serial?: string;
|
||||
confirm_link?: string;
|
||||
license_mode?: string;
|
||||
mobile?: string;
|
||||
}
|
||||
interface IAppInfoContext {
|
||||
@@ -33,6 +34,7 @@ export const AppInfoProvider = ({ children }: { children: ReactNode }) => {
|
||||
website: response.data.website,
|
||||
serial: response.data.serial,
|
||||
confirm_link: response.data.confirm_link,
|
||||
license_mode: response.data.license_mode,
|
||||
};
|
||||
setAppInfo(data);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ const Step1 = () => {
|
||||
if (!correct) {
|
||||
target.mobileNumber = '0' + target.mobileNumber;
|
||||
}
|
||||
setAppInfo({ ...appInfo, mobile: state.mobileNumber });
|
||||
setAppInfo({ ...appInfo, mobile: target.mobileNumber });
|
||||
validationError();
|
||||
if (validate()) {
|
||||
const requestPromise = RequestService.PostRequest(
|
||||
|
||||
@@ -17,6 +17,7 @@ const Step3 = () => {
|
||||
const [response, setResponse] = useState<any>();
|
||||
const { goToStep } = useWizard();
|
||||
const { appInfo } = useContext(AppInfoContext);
|
||||
const usesRay2Api = appInfo.license_mode === "ray2";
|
||||
const [state, setState] = useState({
|
||||
serial: appInfo.serial || "",
|
||||
f_name: "",
|
||||
@@ -24,6 +25,8 @@ const Step3 = () => {
|
||||
company_name: "",
|
||||
email: "",
|
||||
mobile_number: appInfo.mobile || "",
|
||||
phone_number: "",
|
||||
address: "",
|
||||
type_job: "",
|
||||
});
|
||||
const [error, setError] = useState<any>({
|
||||
@@ -31,26 +34,20 @@ const Step3 = () => {
|
||||
mobile_number: false,
|
||||
f_name: false,
|
||||
l_name: false,
|
||||
company_name: false,
|
||||
email: false,
|
||||
});
|
||||
const validationError = () => {
|
||||
const newError = {
|
||||
const validate = () => {
|
||||
const validationErrors = {
|
||||
serial: state.serial.trim() === "",
|
||||
mobile_number: state.mobile_number.trim() === "",
|
||||
f_name: state.f_name.trim() === "",
|
||||
l_name: state.l_name.trim() === "",
|
||||
company_name: usesRay2Api && state.company_name.trim() === "",
|
||||
email: state.email ? !PlineTools.isValidEmail(state.email) : false,
|
||||
};
|
||||
setError(newError);
|
||||
};
|
||||
|
||||
const validate = () => {
|
||||
return !Object.values(error).some(Boolean) &&
|
||||
state.serial.trim() !== "" &&
|
||||
state.mobile_number.trim() !== "" &&
|
||||
state.f_name.trim() !== "" &&
|
||||
state.l_name.trim() !== "" &&
|
||||
(!state.email || PlineTools.isValidEmail(state.email));
|
||||
setError(validationErrors);
|
||||
return !Object.values(validationErrors).some(Boolean);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
@@ -66,6 +63,10 @@ const Step3 = () => {
|
||||
company_name: state.company_name,
|
||||
email: state.email,
|
||||
mobile_number: state.mobile_number,
|
||||
...(usesRay2Api ? {
|
||||
phone_number: state.phone_number,
|
||||
address: state.address,
|
||||
} : {}),
|
||||
type_job: state.type_job,
|
||||
},
|
||||
};
|
||||
@@ -74,7 +75,6 @@ const Step3 = () => {
|
||||
if (state.mobile_number.trim() === "") toast.error("Mobile number is required", { id: "mobile-error" });
|
||||
return;
|
||||
}
|
||||
validationError();
|
||||
if (validate()) {
|
||||
RequestService.PostRequest(
|
||||
"/app/register",
|
||||
@@ -135,6 +135,10 @@ const Step3 = () => {
|
||||
setState={setState}
|
||||
label={t("license.online.companyName")}
|
||||
value={state.company_name}
|
||||
error={error.company_name}
|
||||
setError={setError}
|
||||
message={t("license.online.companyName_error")}
|
||||
star={usesRay2Api}
|
||||
/>
|
||||
<TextInputCustom
|
||||
name="email"
|
||||
@@ -146,6 +150,22 @@ const Step3 = () => {
|
||||
message="Invalid Email format"
|
||||
/>
|
||||
</Row>
|
||||
{usesRay2Api && (
|
||||
<Row>
|
||||
<TextInputCustom
|
||||
name="phone_number"
|
||||
label={t("license.online.phone_number")}
|
||||
value={state.phone_number}
|
||||
setState={setState}
|
||||
/>
|
||||
<TextInputCustom
|
||||
name="address"
|
||||
label={t("license.online.address")}
|
||||
value={state.address}
|
||||
setState={setState}
|
||||
/>
|
||||
</Row>
|
||||
)}
|
||||
<CTIButton
|
||||
onClick={() => {
|
||||
goToStep(0);
|
||||
|
||||
@@ -164,6 +164,8 @@ const Trunks = (props: any) => {
|
||||
const columns = [
|
||||
{
|
||||
field: "sipTrunk.name",
|
||||
valueGetter: (params: any) =>
|
||||
params.data?.sipTrunk?.name ?? t("outboundRoute.trunk.missing_trunk"),
|
||||
headerName: t("outboundRoute.trunk.row_trunk"),
|
||||
rowDrag: true,
|
||||
sortable: false,
|
||||
@@ -310,8 +312,8 @@ const Trunks = (props: any) => {
|
||||
if (clipboardData.every((obj: any) => isValidTrunk(obj))) {
|
||||
const uniqueData = clipboardData.filter((newData: any) => {
|
||||
const isDuplicate = rowData.some((existingData: any) =>
|
||||
existingData.sipTrunk.name
|
||||
? existingData.sipTrunk.name === newData.sipTrunk.name
|
||||
existingData.sipTrunk?.name
|
||||
? existingData.sipTrunk.name === newData.sipTrunk?.name
|
||||
: existingData.id === newData.id
|
||||
);
|
||||
return !isDuplicate;
|
||||
|
||||
@@ -250,6 +250,9 @@ const SipUsers = () => {
|
||||
setIsDeleteModalVisible(false);
|
||||
return;
|
||||
}
|
||||
if (result.Error) {
|
||||
return;
|
||||
}
|
||||
toast.success(t("toasts.successful_delete") + ` {${deleteItem.name}}`, {
|
||||
id: "success-delete",
|
||||
});
|
||||
|
||||
@@ -47,7 +47,6 @@ const SipUsersForm = () => {
|
||||
sipUserGroup: {
|
||||
id: 1,
|
||||
},
|
||||
deadTime: "",
|
||||
callWaiting: false,
|
||||
dnd: false,
|
||||
allowCallBack: true,
|
||||
@@ -146,19 +145,22 @@ const SipUsersForm = () => {
|
||||
updatedState.uid,
|
||||
);
|
||||
}
|
||||
const payload = { ...updatedState };
|
||||
// These fields are form-only/empty on creation and do not belong in the API body.
|
||||
if (payload.id == null) delete payload.id;
|
||||
if (validate()) {
|
||||
const url = "/sip-users";
|
||||
const requestPromise =
|
||||
state.id == null
|
||||
? RequestService.PostRequest(
|
||||
url,
|
||||
updatedState,
|
||||
payload,
|
||||
AccessCodeSip.SipUsers,
|
||||
RequestActions.Create,
|
||||
)
|
||||
: RequestService.PatchRequest(
|
||||
url,
|
||||
updatedState,
|
||||
payload,
|
||||
AccessCodeSip.SipUsers,
|
||||
RequestActions.Update,
|
||||
);
|
||||
|
||||
@@ -311,7 +311,9 @@ export default class PlineTools {
|
||||
return result.length === 0;
|
||||
};
|
||||
public static duplicateTrunk = (array: any) => {
|
||||
let data = array.map((a: any) => a.sipTrunk.id);
|
||||
let data = array
|
||||
.map((a: any) => a?.sipTrunk?.id)
|
||||
.filter((id: any) => id != null && id !== 0);
|
||||
let findDuplicates = (arr: any) =>
|
||||
arr.filter((item: any, index: any) => arr.indexOf(item) !== index);
|
||||
let result = findDuplicates(data);
|
||||
|
||||
Reference in New Issue
Block a user