fixed bug and some UIs

This commit is contained in:
abdurahman
2024-08-26 23:13:32 +01:00
parent 4710a972e4
commit 0efa0cc584
8 changed files with 98 additions and 50 deletions

View File

@@ -19,7 +19,7 @@ function JambonzSwitch({
position="relative" position="relative"
w="50px" w="50px"
h="30px" h="30px"
bg={isToggled ? "green.500" : "grey.500"} bg={isToggled ? "blue.600" : "grey.500"}
borderRadius="full" borderRadius="full"
onClick={() => { onClick={() => {
if (!isDisabled) { if (!isDisabled) {

View File

@@ -58,11 +58,16 @@ export const saveSettings = (settings: AppSettings) => {
el.decoded.sipServerAddress === settings.sipServerAddress el.decoded.sipServerAddress === settings.sipServerAddress
); );
if (!!alreadyExists.length) return; if (!!alreadyExists.length) return;
localStorage.setItem( localStorage.setItem(
SETTINGS_KEY, SETTINGS_KEY,
JSON.stringify([ JSON.stringify([
...parsed, ...parsed,
{ encoded, active: false, id: parsed.length + 1 }, {
encoded,
active: false,
id: parsed.length + 1,
},
]) ])
); );
} else { } else {

View File

@@ -3,6 +3,7 @@ import { extendTheme } from "@chakra-ui/react";
const mainTheme = extendTheme({ const mainTheme = extendTheme({
colors: { colors: {
jambonz: { jambonz: {
0: "#EDDEE3",
50: "#ffe1f1", 50: "#ffe1f1",
100: "#ffb3c6", 100: "#ffb3c6",
200: "#fc839d", 200: "#fc839d",
@@ -26,6 +27,9 @@ const mainTheme = extendTheme({
800: "#6D6D6D", 800: "#6D6D6D",
900: "#434343", 900: "#434343",
}, },
blue: {
600: "#4492FF", //for toggle icon
},
}, },
components: { components: {
FormLabel: { FormLabel: {

View File

@@ -503,48 +503,56 @@ export const Phone = ({
return ( return (
<Box flexDirection="column"> <Box flexDirection="column">
{isConfigured ? ( {allSettings.length >= 1 ? (
<> <>
<Text fontSize={"small"} fontWeight={"semibold"} color={"gray.600"}> <Text fontSize={"small"} fontWeight={"semibold"} color={"gray.600"}>
Account Account
</Text> </Text>
<Box className="relative" w={"full"}> <Box className="relative" w={"full"}>
<HStack {
onClick={() => setShowAccounts(true)} <HStack
_hover={{ onClick={() => setShowAccounts(true)}
cursor: "pointer", _hover={{
}} cursor: "pointer",
spacing={2} }}
boxShadow="md" spacing={2}
w="full" boxShadow="md"
borderRadius={5} w="full"
paddingY={2} borderRadius={5}
paddingX={3.5} paddingY={2}
> paddingX={3.5}
<Image >
src={isStatusRegistered() ? GreenAvatar : Avatar} {sipUsername && sipDomain ? (
boxSize="35px" <>
/> <Image
<VStack alignItems="start" w="full" spacing={0}> src={isStatusRegistered() ? GreenAvatar : Avatar}
<HStack spacing={2} w="full"> boxSize="35px"
<Text fontWeight="bold" fontSize="13px"> />
{sipDisplayName || sipUsername} <VStack alignItems="start" w="full" spacing={0}>
</Text> <HStack spacing={2} w="full">
<Circle <Text fontWeight="bold" fontSize="13px">
size="8px" {sipDisplayName || sipUsername}
bg={isStatusRegistered() ? "green.500" : "gray.500"} </Text>
/> <Circle
</HStack> size="8px"
<Text fontWeight="bold" w="full"> bg={isStatusRegistered() ? "green.500" : "gray.500"}
{`${sipUsername}@${sipDomain}`} />
</Text> </HStack>
</VStack> <Text fontWeight="bold" w="full">
{`${sipUsername}@${sipDomain}`}
</Text>
</VStack>
<Spacer /> <Spacer />
<VStack h="full" align="center"> <VStack h="full" align="center">
<FontAwesomeIcon icon={faChevronDown} /> <FontAwesomeIcon icon={faChevronDown} />
</VStack> </VStack>
</HStack> </>
) : (
<Text fontWeight={"extrabold"}>Select Account</Text>
)}
</HStack>
}
{showAccounts && ( {showAccounts && (
<AnimateOnShow initial={2} exit={0} duration={0.01}> <AnimateOnShow initial={2} exit={0} duration={0.01}>
<AvailableAccounts <AvailableAccounts

View File

@@ -32,9 +32,17 @@ export function AccordionList({
return ( return (
<Accordion index={isOpen ? [openAcc] : []} allowToggle> <Accordion index={isOpen ? [openAcc] : []} allowToggle>
{allSettings.map((data, index) => ( {allSettings.map((data, index) => (
<AccordionItem key={index}> <AccordionItem borderColor={"white"} key={index}>
<AccordionButton onClick={() => handleToggleAcc(index)}> <AccordionButton
<SettingItem data={data} /> _hover={{
backgroundColor: "#fff",
cursor: "default",
}}
>
<SettingItem
onToggleAcc={() => handleToggleAcc(index)}
data={data}
/>
</AccordionButton> </AccordionButton>
<AccordionPanel pb={4}> <AccordionPanel pb={4}>
<AccountForm <AccountForm

View File

@@ -20,6 +20,8 @@ import {
faCheckCircle, faCheckCircle,
faCircleXmark, faCircleXmark,
faShuffle, faShuffle,
faSliders,
faSlidersH,
faTrashCan, faTrashCan,
} from "@fortawesome/free-solid-svg-icons"; } from "@fortawesome/free-solid-svg-icons";
import { normalizeUrl } from "src/utils"; import { normalizeUrl } from "src/utils";
@@ -228,6 +230,7 @@ function AccountForm({
)} )}
<Center flexDirection={"column"} gap={"2.5"}> <Center flexDirection={"column"} gap={"2.5"}>
<Button <Button
variant={"ghost"}
gap={"2.5"} gap={"2.5"}
alignItems={"center"} alignItems={"center"}
onClick={() => setShowAdvanced((prev) => !prev)} onClick={() => setShowAdvanced((prev) => !prev)}
@@ -236,7 +239,7 @@ function AccountForm({
{" "} {" "}
{showAdvanced ? "Hide" : "Show"} Advanced Settings {showAdvanced ? "Hide" : "Show"} Advanced Settings
</Text> </Text>
<FontAwesomeIcon color={colors.jambonz} icon={faShuffle} /> <FontAwesomeIcon color={colors.jambonz} icon={faSliders} />
</Button> </Button>
</Center> </Center>
</VStack> </VStack>
@@ -264,12 +267,20 @@ function AccountForm({
mt={2} mt={2}
> >
<HStack> <HStack>
<Button colorScheme="jambonz" type="submit" w="full"> <Button
textColor={"jambonz.500"}
fontWeight={"semibold"}
bg="jambonz.0"
type="submit"
w="full"
>
Save Save
</Button> </Button>
<Button <Button
variant={"ghost"}
colorScheme="jambonz" colorScheme="jambonz"
type="reset" type="reset"
fontWeight={"semibold"}
w="full" w="full"
onClick={resetSetting} onClick={resetSetting}
> >

View File

@@ -46,6 +46,13 @@ export const Settings = () => {
Add Account Add Account
</Button> </Button>
)} )}
{showForm && (
<AnimateOnShow>
<AccountForm closeForm={handleCloseForm} />
</AnimateOnShow>
)}
<Center marginBottom={"2.5"} flexDirection={"column"}> <Center marginBottom={"2.5"} flexDirection={"column"}>
<Text> <Text>
{allSettings.length} of {MAX_NUM_OF_ACCOUNTS}{" "} {allSettings.length} of {MAX_NUM_OF_ACCOUNTS}{" "}
@@ -55,12 +62,6 @@ export const Settings = () => {
)} )}
</Center> </Center>
{showForm && (
<AnimateOnShow>
<AccountForm closeForm={handleCloseForm} />
</AnimateOnShow>
)}
{/* <Tabs isFitted colorScheme={DEFAULT_COLOR_SCHEME}> {/* <Tabs isFitted colorScheme={DEFAULT_COLOR_SCHEME}>
<TabList mb="1em" gap={1}> <TabList mb="1em" gap={1}>
<Tab>Basic</Tab> <Tab>Basic</Tab>

View File

@@ -2,7 +2,13 @@ import { HStack, Text, VStack } from "@chakra-ui/react";
import React from "react"; import React from "react";
import { IAppSettings } from "src/common/types"; import { IAppSettings } from "src/common/types";
function SettingItem({ data }: { data: IAppSettings }) { function SettingItem({
data,
onToggleAcc,
}: {
data: IAppSettings;
onToggleAcc: () => void;
}) {
return ( return (
<HStack <HStack
w={"full"} w={"full"}
@@ -13,6 +19,11 @@ function SettingItem({ data }: { data: IAppSettings }) {
justifyContent={"start"} justifyContent={"start"}
borderRadius={"2xl"} borderRadius={"2xl"}
padding={"2.5"} padding={"2.5"}
onClick={onToggleAcc}
_hover={{
backgroundColor: "gray.200",
cursor: "pointer",
}}
> >
<VStack gap={"0"} alignItems={"start"}> <VStack gap={"0"} alignItems={"start"}>
<Text fontWeight={"bold"}> <Text fontWeight={"bold"}>