diff --git a/src/api/index.ts b/src/api/index.ts index 45ca172..a9af040 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -143,6 +143,16 @@ export const getApplications = () => { ); }; +// validate user advanced credential +export const getAdvancedValidation = ( + apiServer: string, + accountSid: string +) => { + return getFetch( + `${apiServer}/Accounts/${accountSid}/Applications` + ); +}; + export const getQueues = () => { const advancedSettings = getActiveSettings(); return getFetch( diff --git a/src/imgs/icons/invalid.svg b/src/imgs/icons/invalid.svg new file mode 100644 index 0000000..aef2e90 --- /dev/null +++ b/src/imgs/icons/invalid.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/theme.tsx b/src/theme.tsx index ecfaf5e..c9e2a2d 100644 --- a/src/theme.tsx +++ b/src/theme.tsx @@ -13,6 +13,7 @@ const mainTheme = extendTheme({ 200: "#fc839d", 300: "#fa5575", 400: "#f8274e", + 450: "#BD4782", 500: "#BB225B", 550: "#DA1C5C", 600: "#c60921", @@ -33,6 +34,9 @@ const mainTheme = extendTheme({ 800: "#6D6D6D", 900: "#434343", }, + greenish: { + 500: "#158477", + }, blue: { 600: "#4492FF", //for toggle icon }, diff --git a/src/window/phone/index.tsx b/src/window/phone/index.tsx index a271a81..ac7304f 100644 --- a/src/window/phone/index.tsx +++ b/src/window/phone/index.tsx @@ -80,8 +80,8 @@ type PhoneProbs = { allSettings: IAppSettings[]; reload: () => void; sipUA: React.MutableRefObject; - setIsSwitchingUserStatus: React.Dispatch>, - setIsOnline: React.Dispatch> + setIsSwitchingUserStatus: React.Dispatch>; + setIsOnline: React.Dispatch>; }; enum PAGE_VIEW { @@ -105,9 +105,9 @@ export const Phone = ({ advancedSettings, allSettings, reload, - sipUA, + // sipUA, setIsSwitchingUserStatus, - setIsOnline + setIsOnline, }: PhoneProbs) => { const [inputNumber, setInputNumber] = useState(""); const [appName, setAppName] = useState(""); @@ -137,7 +137,7 @@ export const Phone = ({ const inputNumberRef = useRef(inputNumber); const sessionDirectionRef = useRef(sessionDirection); - // const sipUA = useRef(null); + const sipUA = useRef(null); const timerRef = useRef(null); const isRestartRef = useRef(false); const sipDomainRef = useRef(""); @@ -517,7 +517,7 @@ export const Phone = ({ const handleSetActive = (id: number) => { setActiveSettings(id); setShowAccounts(false); - fetchRegisterUser(); + // fetchRegisterUser(); reload(); }; diff --git a/src/window/settings/accountForm.tsx b/src/window/settings/accountForm.tsx index 22160e5..e11cee4 100644 --- a/src/window/settings/accountForm.tsx +++ b/src/window/settings/accountForm.tsx @@ -18,18 +18,13 @@ import PasswordInput from "src/components/password-input"; import { deleteSettings, editSettings, saveSettings } from "src/storage"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { - faCheckCircle, - faCircleXmark, - faShuffle, - faSliders, - faSlidersH, - faTrashCan, + faCheckCircle } from "@fortawesome/free-solid-svg-icons"; import { normalizeUrl } from "src/utils"; -import { getApplications } from "src/api"; -import { colors } from "src/theme"; +import { getAdvancedValidation } from "src/api"; import Switch from "src/imgs/icons/Switch.svg"; import Trash from "src/imgs/icons/Trash.svg"; +import invalid from "src/imgs/icons/invalid.svg"; function AccountForm({ closeForm, @@ -68,13 +63,26 @@ function AccountForm({ setAccountSid(formData.decoded.accountSid); setApiKey(formData.decoded.apiKey || ""); setApiServer(formData.decoded.apiServer); + + if ( + formData.decoded.accountSid || + formData.decoded.apiKey || + formData.decoded.apiServer + ) { + setIsAdvancedMode(true); + checkCredential( + formData.decoded.apiServer || "", + formData.decoded.accountSid || "" + ); + } } }, [formData, handleClose] ); - const checkCredential = () => { - getApplications() + const checkCredential = (apiServer: string, accountSid: string) => { + // getApplications() + getAdvancedValidation(apiServer, accountSid) .then(() => { setIsCredentialOk(true); }) @@ -101,7 +109,7 @@ function AccountForm({ if (showAdvanced) { setIsAdvancedMode(true); - checkCredential(); + checkCredential(settings.apiServer || "", settings.accountSid || ""); } toast({ @@ -239,6 +247,42 @@ function AccountForm({ isRequired /> + + {isAdvancedMode && ( + + + {isCredentialOk + ? "Credentials are valid" + : "We cant verify your credentials"} + + {isCredentialOk ? ( + + ) : ( + + + + )} + + )} )}
@@ -257,22 +301,6 @@ function AccountForm({
- {isAdvancedMode && ( - - - - Credential is {isCredentialOk ? "valid" : "invalid"} - - - )} -