mirror of
https://github.com/jambonz/jambonz-webapp.git
synced 2026-07-04 19:21:58 +00:00
Bug/sp user check before sp delete (#198)
* fix bug where you could not delete carriers and speech * remove activeSP from localstore after delete --------- Co-authored-by: EgleHelms <e.helms@cognigy.com>
This commit is contained in:
@@ -49,7 +49,8 @@ export const Carriers = () => {
|
||||
|
||||
const carriersFiltered = useMemo(() => {
|
||||
setAccountSid(getAccountFilter());
|
||||
if (user?.scope === USER_ACCOUNT) {
|
||||
if (user?.account_sid && user?.scope === USER_ACCOUNT) {
|
||||
setAccountSid(user?.account_sid);
|
||||
return carriers;
|
||||
}
|
||||
|
||||
@@ -119,9 +120,7 @@ export const Carriers = () => {
|
||||
|
||||
useEffect(() => {
|
||||
setLocation();
|
||||
if (accountSid) {
|
||||
setApiUrl(`Accounts/${accountSid}/VoipCarriers`);
|
||||
} else if (currentServiceProvider) {
|
||||
if (currentServiceProvider) {
|
||||
setApiUrl(
|
||||
`ServiceProviders/${currentServiceProvider.service_provider_sid}/VoipCarriers`
|
||||
);
|
||||
|
||||
@@ -14,6 +14,7 @@ import { Modal } from "src/components";
|
||||
import { Checkzone, LocalLimits } from "src/components/forms";
|
||||
import { withSelectState } from "src/utils";
|
||||
import type { Limit, ServiceProvider } from "src/api/types";
|
||||
import { removeActiveSP } from "src/store/localStore";
|
||||
|
||||
export type ServiceProviderSettingsProps = {
|
||||
serviceProviders: ServiceProvider[];
|
||||
@@ -94,6 +95,7 @@ export const ServiceProviderSettings = ({
|
||||
<strong>{currentServiceProvider.name}</strong>
|
||||
</>
|
||||
);
|
||||
removeActiveSP();
|
||||
})
|
||||
.catch((error) => {
|
||||
toastError(error.msg);
|
||||
|
||||
@@ -39,7 +39,8 @@ export const SpeechServices = () => {
|
||||
|
||||
const credentialsFiltered = useMemo(() => {
|
||||
setAccountSid(getAccountFilter());
|
||||
if (user?.scope === USER_ACCOUNT) {
|
||||
if (user?.account_sid && user?.scope === USER_ACCOUNT) {
|
||||
setAccountSid(user?.account_sid);
|
||||
return credentials;
|
||||
}
|
||||
|
||||
@@ -86,9 +87,7 @@ export const SpeechServices = () => {
|
||||
|
||||
useEffect(() => {
|
||||
setLocation();
|
||||
if (accountSid) {
|
||||
setApiUrl(`Accounts/${accountSid}/SpeechCredentials`);
|
||||
} else if (currentServiceProvider) {
|
||||
if (currentServiceProvider) {
|
||||
setApiUrl(
|
||||
`ServiceProviders/${currentServiceProvider?.service_provider_sid}/SpeechCredentials`
|
||||
);
|
||||
|
||||
@@ -14,6 +14,10 @@ export const setActiveSP = (sid: string) => {
|
||||
localStorage.setItem(storeActiveSP, sid);
|
||||
};
|
||||
|
||||
export const removeActiveSP = () => {
|
||||
localStorage.removeItem(storeActiveSP);
|
||||
};
|
||||
|
||||
/**
|
||||
* The key used to store active Filter in localStorage
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user