This commit is contained in:
Quan HL
2023-10-25 05:03:20 +07:00
parent 3c861fc5ef
commit 941fdb9e88
5 changed files with 24 additions and 13 deletions

View File

@@ -18,6 +18,7 @@ type IconButtonMenuProbs = {
onOpen: () => Promise<IconButtonMenuItems[]>;
onClick: (name: string, value: string) => void;
tooltip: string;
noResultLabel: string;
};
export const IconButtonMenu = ({
@@ -25,6 +26,7 @@ export const IconButtonMenu = ({
onOpen,
onClick,
tooltip,
noResultLabel,
}: IconButtonMenuProbs) => {
const [items, setItems] = useState<IconButtonMenuItems[]>([]);
const [isLoading, setIsLoading] = useState(false);
@@ -51,12 +53,14 @@ export const IconButtonMenu = ({
<MenuItem>
<Spinner color="jambonz.500" size="xs" />
</MenuItem>
) : (
) : items.length > 0 ? (
items.map((i, idx) => (
<MenuItem key={idx} onClick={() => onClick(i.name, i.value)}>
{i.name}
</MenuItem>
))
) : (
<MenuItem>{noResultLabel}</MenuItem>
)}
</MenuList>
</Menu>

View File

@@ -61,7 +61,7 @@ export const Recents = ({
</UnorderedList>
) : (
<Text fontSize="24px" fontWeight="bold">
No Call History
{isSaved ? "No saved calls" : "No Call History"}
</Text>
)}
</VStack>

View File

@@ -94,7 +94,11 @@ export const Phone = ({
useEffect(() => {
if (sipDomain && sipUsername && sipPassword && sipServerAddress) {
createSipClient();
if (sipUA.current) {
clientGoOffline();
} else {
createSipClient();
}
setIsConfigured(true);
} else {
setIsConfigured(false);
@@ -181,8 +185,6 @@ export const Phone = ({
};
const createSipClient = () => {
clientGoOffline();
const client = {
username: `${sipUsername}@${sipDomain}`,
password: sipPassword,
@@ -205,7 +207,11 @@ export const Phone = ({
});
sipClient.on(SipConstants.UA_UNREGISTERED, (args) => {
setStatus("offline");
clientGoOffline();
if (sipDomain && sipUsername && sipPassword && sipServerAddress) {
createSipClient();
} else {
clientGoOffline();
}
});
// Call Status
sipClient.on(SipConstants.SESSION_RINGING, (args) => {
@@ -383,7 +389,7 @@ export const Phone = ({
<VStack spacing={2} alignItems="start" w="full">
<HStack spacing={2} w="full">
<Text fontWeight="bold" fontSize="13px">
{sipDisplayName ?? sipUsername}
{sipDisplayName || sipUsername}
</Text>
<Circle size="8px" bg={isOnline() ? "green.500" : "gray.500"} />
<Select
@@ -437,7 +443,8 @@ export const Phone = ({
<HStack spacing={2} align="start" w="full">
<IconButtonMenu
icon={<Users />}
tooltip="Call to user"
tooltip="Call a user"
noResultLabel="No registered users"
onClick={(_, value) => {
setInputNumber(value);
makeOutboundCall(value);
@@ -466,7 +473,8 @@ export const Phone = ({
/>
<IconButtonMenu
icon={<List />}
tooltip="Call to a queue"
tooltip="Take a call from queue"
noResultLabel="No calls in queue"
onClick={(name, value) => {
setAppName(`Queue ${name}`);
const calledQueue = `queue-${value}`;
@@ -493,7 +501,8 @@ export const Phone = ({
<IconButtonMenu
icon={<GitMerge />}
tooltip="Call to an application"
tooltip="Call an application"
noResultLabel="No applications"
onClick={(name, value) => {
setAppName(`App ${name}`);
const calledAppId = `app-${value}`;

View File

@@ -97,7 +97,6 @@ export const AdvancedSettings = () => {
<FormLabel>Jambonz Account Sid</FormLabel>
<Input
type="text"
placeholder="Account Sid"
isRequired
value={accountSid}
onChange={(e) => setAccountSid(e.target.value)}

View File

@@ -128,11 +128,10 @@ export const BasicSettings = () => {
</FormControl>
<FormControl id="sip_display_name">
<FormLabel>SIP Display Name</FormLabel>
<FormLabel>SIP Display Name (Optional)</FormLabel>
<Input
type="text"
placeholder="Display name"
isRequired
value={sipDisplayName}
onChange={(e) => setSipDisplayName(e.target.value)}
/>