diff --git a/src/containers/internal/views/accounts/subscription.tsx b/src/containers/internal/views/accounts/subscription.tsx index fe6080d..036e4c3 100644 --- a/src/containers/internal/views/accounts/subscription.tsx +++ b/src/containers/internal/views/accounts/subscription.tsx @@ -1,11 +1,16 @@ import React from "react"; -import { STRIPE_PUBLISHABLE_KEY } from "src/api/constants"; +import { + ENABLE_HOSTED_SYSTEM, + STRIPE_PUBLISHABLE_KEY, +} from "src/api/constants"; import { Elements } from "@stripe/react-stripe-js"; import { loadStripe } from "@stripe/stripe-js"; import SubscriptionForm from "./subscription-form"; -export const stripePromise = loadStripe(STRIPE_PUBLISHABLE_KEY); +export const stripePromise = ENABLE_HOSTED_SYSTEM + ? loadStripe(STRIPE_PUBLISHABLE_KEY) + : null; export const Subscription = () => { return ( diff --git a/src/containers/internal/views/clients/add.tsx b/src/containers/internal/views/clients/add.tsx index 27a2369..21d8b41 100644 --- a/src/containers/internal/views/clients/add.tsx +++ b/src/containers/internal/views/clients/add.tsx @@ -5,7 +5,7 @@ import ClientsForm from "./form"; export const ClientsAdd = () => { return ( <> -

Add client

+

Add sip client

); diff --git a/src/containers/internal/views/clients/delete.tsx b/src/containers/internal/views/clients/delete.tsx index 01bea49..87950ae 100644 --- a/src/containers/internal/views/clients/delete.tsx +++ b/src/containers/internal/views/clients/delete.tsx @@ -17,7 +17,7 @@ export const ClientsDelete = ({ <>

- Are you sure you want to delete the client{" "} + Are you sure you want to delete the sip client{" "} {client.username}?

diff --git a/src/containers/internal/views/clients/edit.tsx b/src/containers/internal/views/clients/edit.tsx index f782e05..2eaf471 100644 --- a/src/containers/internal/views/clients/edit.tsx +++ b/src/containers/internal/views/clients/edit.tsx @@ -21,7 +21,7 @@ export const ClientsEdit = () => { return ( <> -

Edit client

+

Edit sip client

); diff --git a/src/containers/internal/views/clients/index.tsx b/src/containers/internal/views/clients/index.tsx index be461f0..5d76fc7 100644 --- a/src/containers/internal/views/clients/index.tsx +++ b/src/containers/internal/views/clients/index.tsx @@ -2,7 +2,7 @@ import { Button, H1, Icon, M } from "@jambonz/ui-kit"; import React, { useMemo, useState } from "react"; import { Link } from "react-router-dom"; import { deleteClient, useApiData, useServiceProviderData } from "src/api"; -import { Account, Client } from "src/api/types"; +import { Account, Client, CurrentUserData } from "src/api/types"; import { AccountFilter, Icons, @@ -20,10 +20,14 @@ import { USER_ACCOUNT } from "src/api/constants"; export const Clients = () => { const user = useSelectState("user"); + const [userData] = useApiData("Users/me"); const [accounts] = useServiceProviderData("Accounts"); const [clients, refetch] = useApiData("Clients"); const [accountSid, setAccountSid] = useState(""); + const [selectedAccount, setSelectedAccount] = useState< + Account | null | undefined + >(null); const [filter, setFilter] = useState(""); const [client, setClient] = useState(); @@ -33,6 +37,12 @@ export const Clients = () => { return clients; } + setSelectedAccount( + accountSid + ? accounts?.find((a: Account) => a.account_sid === accountSid) + : null + ); + return clients ? clients.filter((c) => { return accountSid @@ -52,7 +62,7 @@ export const Clients = () => { .then(() => { toastSuccess( <> - Deleted outbound call route {client.username} + Deleted sip client {client.username} ); setClient(null); @@ -67,8 +77,48 @@ export const Clients = () => { return ( <>
-

Clients

- +
+

SIP client credentials

+ {user?.scope === USER_ACCOUNT ? ( + userData?.account?.sip_realm ? ( + <> + + Your sip realm is {userData?.account?.sip_realm} + + + You can add sip credentials below to allow sip devices to + register to this realm and make calls. + + + ) : ( + + You need to associate a sip realm to this account in order to + add sip credentials. + + ) + ) : selectedAccount ? ( + selectedAccount?.sip_realm ? ( + <> + + Your sip realm is {selectedAccount.sip_realm} + + + You can add sip credentials below to allow sip devices to + register to this realm and make calls. + + + ) : ( + + You need to associate a sip realm to this account in order to + add sip credentials. + + ) + ) : ( + <> + )} +
+ + {" "} @@ -156,13 +206,13 @@ export const Clients = () => { )) ) : ( - No Clients. + No sip clients. )}
{client && (