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:
EgleH
2023-02-08 13:29:04 +01:00
committed by GitHub
parent 8f849ef290
commit 6df9f0d6da
4 changed files with 12 additions and 8 deletions
@@ -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`
);
+4
View File
@@ -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
*/