This commit is contained in:
Hoan HL
2025-10-27 11:54:27 +07:00
parent a0dc97487b
commit 7b989456aa

View File

@@ -1408,15 +1408,15 @@ export const CarrierForm = ({
</MXS>
</fieldset>
<fieldset>
{trunkType === "reg" ? (
// For registration trunk, show fields directly without checkzone
<div>
<div className="label">Authentication</div>
<MS>
Registration trunk requires authentication credentials.
</MS>
{/* Authentication Fields - shared component */}
{(() => {
const authFields = (
<>
<label htmlFor="sip_username">
Auth username <span>*</span>
Auth username{" "}
{(sipPass || sipRegister || trunkType === "reg") && (
<span>*</span>
)}
</label>
<input
id="sip_username"
@@ -1424,26 +1424,42 @@ export const CarrierForm = ({
type="text"
value={sipUser}
placeholder="SIP username for authenticating outbound calls"
required
onChange={(e) => {
setSipUser(e.target.value);
}}
required={
trunkType === "reg" || sipRegister || sipPass.length > 0
}
onChange={(e) => setSipUser(e.target.value)}
/>
<label htmlFor="sip_password">
Password <span>*</span>
Password{" "}
{(sipUser || sipRegister || trunkType === "reg") && (
<span>*</span>
)}
</label>
<Passwd
id="sip_password"
name="sip_password"
value={sipPass}
placeholder="SIP password for authenticating outbound calls"
required
onChange={(e) => {
setSipPass(e.target.value);
}}
required={
trunkType === "reg" || sipRegister || sipUser.length > 0
}
onChange={(e) => setSipPass(e.target.value)}
/>
</>
);
if (trunkType === "reg") {
return (
<div>
<div className="label">Authentication</div>
<MS>
Registration trunk requires authentication credentials.
</MS>
{authFields}
</div>
) : (
);
} else {
return (
<Checkzone
key={`sip_credentials_${trunkType}`}
hidden
@@ -1459,47 +1475,20 @@ export const CarrierForm = ({
}}
>
<MS>Does your carrier require authentication?</MS>
<label htmlFor="sip_username">
Auth username {sipPass || sipRegister ? <span>*</span> : ""}
</label>
<input
id="sip_username"
name="sip_username"
type="text"
value={sipUser}
placeholder="SIP username for authenticating outbound calls"
required={sipRegister || sipPass.length > 0}
onChange={(e) => {
setSipUser(e.target.value);
}}
/>
<label htmlFor="sip_password">
Password
{sipUser || sipRegister ? <span>*</span> : ""}
</label>
<Passwd
id="sip_password"
name="sip_password"
value={sipPass}
placeholder="SIP password for authenticating outbound calls"
required={sipRegister || sipUser.length > 0}
onChange={(e) => {
setSipPass(e.target.value);
}}
/>
{authFields}
</Checkzone>
)}
);
}
})()}
</fieldset>
<fieldset>
{trunkType === "reg" ? (
// For registration trunk, show fields directly without checkzone
<div>
<div className="label">SIP Registration</div>
<MS>
Registration trunk requires SIP registration settings.
</MS>
{/* SIP Registration Fields - shared component */}
{(() => {
const sipRegFields = (
<>
<label htmlFor="sip_realm">
SIP realm <span>*</span>
SIP realm{" "}
{(sipRegister || trunkType === "reg") && <span>*</span>}
</label>
<input
id="sip_realm"
@@ -1507,7 +1496,7 @@ export const CarrierForm = ({
type="text"
value={sipRealm}
placeholder="SIP realm for registration"
required
required={trunkType === "reg" || sipRegister}
onChange={(e) => setSipRealm(e.target.value)}
/>
<label htmlFor="from_user">Username</label>
@@ -1528,10 +1517,10 @@ export const CarrierForm = ({
placeholder="Optional: specify host part of SIP From header"
onChange={(e) => setFromDomain(e.target.value)}
/>
<label htmlFor="reg_public_ip_in_contact_3" className="chk">
<label htmlFor="reg_public_ip_in_contact" className="chk">
<input
id="reg_public_ip_in_contact_3"
name="reg_public_ip_in_contact_3"
id="reg_public_ip_in_contact"
name="reg_public_ip_in_contact"
type="checkbox"
checked={regPublicIpInContact}
onChange={(e) =>
@@ -1540,8 +1529,21 @@ export const CarrierForm = ({
/>
<div>Use public IP in contact</div>
</label>
</>
);
if (trunkType === "reg") {
return (
<div>
<div className="label">SIP Registration</div>
<MS>
Registration trunk requires SIP registration settings.
</MS>
{sipRegFields}
</div>
) : (
);
} else {
return (
<Checkzone
key={`sip_register_${trunkType}`}
hidden
@@ -1559,51 +1561,11 @@ export const CarrierForm = ({
}}
>
<MS>Carrier requires SIP Register.</MS>
<label htmlFor="sip_realm">
SIP realm
{sipRegister ? <span>*</span> : ""}
</label>
<input
id="sip_realm"
name="sip_realm"
type="text"
value={sipRealm}
placeholder="SIP realm for registration"
required={sipRegister}
onChange={(e) => setSipRealm(e.target.value)}
/>
<label htmlFor="from_user">Username</label>
<input
id="from_user"
name="from_user"
type="text"
value={fromUser}
placeholder="Optional: specify user part of SIP From header"
onChange={(e) => setFromUser(e.target.value)}
/>
<label htmlFor="from_domain">SIP from domain</label>
<input
id="from_domain"
name="from_domain"
type="text"
value={fromDomain}
placeholder="Optional: specify host part of SIP From header"
onChange={(e) => setFromDomain(e.target.value)}
/>
<label htmlFor="reg_public_ip_in_contact_2" className="chk">
<input
id="reg_public_ip_in_contact_2"
name="reg_public_ip_in_contact_2"
type="checkbox"
checked={regPublicIpInContact}
onChange={(e) =>
setRegPublicIpInContact(e.target.checked)
}
/>
<div>Use public IP in contact</div>
</label>
{sipRegFields}
</Checkzone>
)}
);
}
})()}
</fieldset>
<fieldset>
<Checkzone