From 0efa0cc584c04d48f087d149582171e29251bb94 Mon Sep 17 00:00:00 2001 From: abdurahman Date: Mon, 26 Aug 2024 23:13:32 +0100 Subject: [PATCH] fixed bug and some UIs --- src/components/switch/index.tsx | 2 +- src/storage/index.ts | 7 ++- src/theme.tsx | 4 ++ src/window/phone/index.tsx | 80 +++++++++++++++------------ src/window/settings/accordionList.tsx | 14 ++++- src/window/settings/accountForm.tsx | 15 ++++- src/window/settings/index.tsx | 13 +++-- src/window/settings/settingItem.tsx | 13 ++++- 8 files changed, 98 insertions(+), 50 deletions(-) diff --git a/src/components/switch/index.tsx b/src/components/switch/index.tsx index b3863d2..6731d69 100644 --- a/src/components/switch/index.tsx +++ b/src/components/switch/index.tsx @@ -19,7 +19,7 @@ function JambonzSwitch({ position="relative" w="50px" h="30px" - bg={isToggled ? "green.500" : "grey.500"} + bg={isToggled ? "blue.600" : "grey.500"} borderRadius="full" onClick={() => { if (!isDisabled) { diff --git a/src/storage/index.ts b/src/storage/index.ts index b035baf..f96cccd 100644 --- a/src/storage/index.ts +++ b/src/storage/index.ts @@ -58,11 +58,16 @@ export const saveSettings = (settings: AppSettings) => { el.decoded.sipServerAddress === settings.sipServerAddress ); if (!!alreadyExists.length) return; + localStorage.setItem( SETTINGS_KEY, JSON.stringify([ ...parsed, - { encoded, active: false, id: parsed.length + 1 }, + { + encoded, + active: false, + id: parsed.length + 1, + }, ]) ); } else { diff --git a/src/theme.tsx b/src/theme.tsx index 661aa77..9811943 100644 --- a/src/theme.tsx +++ b/src/theme.tsx @@ -3,6 +3,7 @@ import { extendTheme } from "@chakra-ui/react"; const mainTheme = extendTheme({ colors: { jambonz: { + 0: "#EDDEE3", 50: "#ffe1f1", 100: "#ffb3c6", 200: "#fc839d", @@ -26,6 +27,9 @@ const mainTheme = extendTheme({ 800: "#6D6D6D", 900: "#434343", }, + blue: { + 600: "#4492FF", //for toggle icon + }, }, components: { FormLabel: { diff --git a/src/window/phone/index.tsx b/src/window/phone/index.tsx index 92d5571..44b8558 100644 --- a/src/window/phone/index.tsx +++ b/src/window/phone/index.tsx @@ -503,48 +503,56 @@ export const Phone = ({ return ( - {isConfigured ? ( + {allSettings.length >= 1 ? ( <> Account - setShowAccounts(true)} - _hover={{ - cursor: "pointer", - }} - spacing={2} - boxShadow="md" - w="full" - borderRadius={5} - paddingY={2} - paddingX={3.5} - > - - - - - {sipDisplayName || sipUsername} - - - - - {`${sipUsername}@${sipDomain}`} - - + { + setShowAccounts(true)} + _hover={{ + cursor: "pointer", + }} + spacing={2} + boxShadow="md" + w="full" + borderRadius={5} + paddingY={2} + paddingX={3.5} + > + {sipUsername && sipDomain ? ( + <> + + + + + {sipDisplayName || sipUsername} + + + + + {`${sipUsername}@${sipDomain}`} + + - - - - - + + + + + + ) : ( + Select Account + )} + + } {showAccounts && ( {allSettings.map((data, index) => ( - - handleToggleAcc(index)}> - + + + handleToggleAcc(index)} + data={data} + /> @@ -264,12 +267,20 @@ function AccountForm({ mt={2} > - )} + + {showForm && ( + + + + )} +
{allSettings.length} of {MAX_NUM_OF_ACCOUNTS}{" "} @@ -55,12 +62,6 @@ export const Settings = () => { )}
- {showForm && ( - - - - )} - {/* Basic diff --git a/src/window/settings/settingItem.tsx b/src/window/settings/settingItem.tsx index 52d90ef..c496388 100644 --- a/src/window/settings/settingItem.tsx +++ b/src/window/settings/settingItem.tsx @@ -2,7 +2,13 @@ import { HStack, Text, VStack } from "@chakra-ui/react"; import React from "react"; import { IAppSettings } from "src/common/types"; -function SettingItem({ data }: { data: IAppSettings }) { +function SettingItem({ + data, + onToggleAcc, +}: { + data: IAppSettings; + onToggleAcc: () => void; +}) { return (