From 4b52a8aa2cfe333fbcc08972ec967263b9490903 Mon Sep 17 00:00:00 2001 From: balzack Date: Wed, 13 Nov 2024 13:08:24 -0800 Subject: [PATCH] formatting code --- app/client/web/src/constants/Strings.ts | 15 +- app/client/web/src/contacts/Contacts.tsx | 2 +- app/client/web/src/content/Content.module.css | 2 +- app/client/web/src/content/Content.tsx | 79 +++--- app/client/web/src/content/useContent.hook.ts | 254 +++++++++--------- .../web/src/conversation/Conversation.tsx | 2 +- 6 files changed, 180 insertions(+), 174 deletions(-) diff --git a/app/client/web/src/constants/Strings.ts b/app/client/web/src/constants/Strings.ts index 9d9f2966..a6b06674 100644 --- a/app/client/web/src/constants/Strings.ts +++ b/app/client/web/src/constants/Strings.ts @@ -249,7 +249,7 @@ export const en = { disable: 'Disable', confirmDisable: 'Disabling Multi-Factor Authentication', disablePrompt: 'Are you sure you want to disable multi-factor authentication', -}; +} export const fr = { unknown: 'Inconnu', @@ -503,7 +503,7 @@ export const fr = { disable: 'Désactiver', confirmDisable: "Désactivation de l'authentification multi-facteurs", disablePrompt: "Êtes-vous sûr de vouloir désactiver l'authentification multi-facteurs", -}; +} export const sp = { unknown: 'Desconocido', @@ -756,7 +756,7 @@ export const sp = { disable: 'Desactivar', confirmDisable: 'Desactivación de la autenticación de dos factores', disablePrompt: '¿Estás seguro de que quieres desactivar la autenticación de dos factores?', -}; +} export const pt = { unknown: 'Desconhecido', @@ -765,7 +765,7 @@ export const pt = { server: 'Servidor', token: 'Code', delayMessage: 'A geração da chave pode levar vários minutos.', - + code: 'pt', settings: 'Configurações', contacts: 'Contatos', @@ -1009,7 +1009,7 @@ export const pt = { disable: 'Desativar', confirmDisable: 'Desativando Autenticação de Dois Fatores', disablePrompt: 'Tem certeza de que deseja desativar a autenticação de dois fatores?', -}; +} export const de = { unknown: 'Unbekannt', @@ -1262,7 +1262,7 @@ export const de = { disable: 'Deaktivieren', confirmDisable: 'Deaktivierung der Zwei-Faktor-Authentifizierung', disablePrompt: 'Sind Sie sicher, dass Sie die Zwei-Faktor-Authentifizierung deaktivieren möchten?', -}; +} export const ru = { unknown: 'Неизвестно', @@ -1515,5 +1515,4 @@ export const ru = { disable: 'Отключить', confirmDisable: 'Отключение двухфакторной аутентификации', disablePrompt: 'Вы уверены, что хотите отключить двухфакторную аутентификацию?', -}; - +} diff --git a/app/client/web/src/contacts/Contacts.tsx b/app/client/web/src/contacts/Contacts.tsx index b00f1539..30a18ae6 100644 --- a/app/client/web/src/contacts/Contacts.tsx +++ b/app/client/web/src/contacts/Contacts.tsx @@ -8,7 +8,7 @@ import { ProfileParams } from '../profile/Profile' import { Colors } from '../constants/Colors' import { modals } from '@mantine/modals' -function Action({ icon, color, strings, select }: { icon: ReactNode; color: string; strings: { operationFailed: string, tryAgain: string}; select: () => Promise }) { +function Action({ icon, color, strings, select }: { icon: ReactNode; color: string; strings: { operationFailed: string; tryAgain: string }; select: () => Promise }) { const [loading, setLoading] = useState(false) const onClick = async () => { setLoading(true) diff --git a/app/client/web/src/content/Content.module.css b/app/client/web/src/content/Content.module.css index e5c11f0b..c5e17b5b 100644 --- a/app/client/web/src/content/Content.module.css +++ b/app/client/web/src/content/Content.module.css @@ -103,7 +103,7 @@ height: 128px; align-items: center; justify-content: center; - + .noContactsLabel { color: var(--mantine-color-text-6); } diff --git a/app/client/web/src/content/Content.tsx b/app/client/web/src/content/Content.tsx index 4027d8ef..0be0aff0 100644 --- a/app/client/web/src/content/Content.tsx +++ b/app/client/web/src/content/Content.tsx @@ -1,36 +1,39 @@ -import React, {useState} from 'react'; +import React, { useState } from 'react' import { useContent } from './useContent.hook' import { Modal, Text, Switch, TextInput, Button } from '@mantine/core' import { IconSearch, IconMessagePlus, IconLabel } from '@tabler/icons-react' import classes from './Content.module.css' import { Channel } from '../channel/Channel' import { Focus } from 'databag-client-sdk' -import { Card } from '../card/Card'; +import { Card } from '../card/Card' import { modals } from '@mantine/modals' export function Content({ select }: { select: (focus: Focus) => void }) { const { state, actions } = useContent() - const [add, setAdd] = useState(false); - const [adding, setAdding] = useState(false); - const [sealed, setSealed] = useState(false); - const [subject, setSubject] = useState(''); - const [added, setAdded] = useState([]); - const cards = (state.sealSet && sealed) ? state.sealable : state.connected; + const [add, setAdd] = useState(false) + const [adding, setAdding] = useState(false) + const [sealed, setSealed] = useState(false) + const [subject, setSubject] = useState('') + const [added, setAdded] = useState([]) + const cards = state.sealSet && sealed ? state.sealable : state.connected const addTopic = async () => { - setAdding(true); + setAdding(true) try { - await actions.addTopic(sealed, subject, added.filter(id => Boolean(cards.find(card => card.cardId === id)))) - setAdd(false); - setSealed(false); - setAdded([]); - setSubject(''); + await actions.addTopic( + sealed, + subject, + added.filter((id) => Boolean(cards.find((card) => card.cardId === id))) + ) + setAdd(false) + setSealed(false) + setAdded([]) + setSubject('') + } catch (err) { + console.log(err) + showError() } - catch (err) { - console.log(err); - showError(); - } - setAdding(false); + setAdding(false) } const showError = () => { @@ -48,17 +51,23 @@ export function Content({ select }: { select: (focus: Focus) => void }) { } const contacts = cards.map((card, idx) => { - const enable = ( id === card.cardId))} onChange={(ev) => { - if (ev.currentTarget.checked) { - setAdded([ ...added, card.cardId ]); - } else { - setAdded(added.filter(id => id !== card.cardId)) - } - }} />) - return ( - + const enable = ( + id === card.cardId))} + onChange={(ev) => { + if (ev.currentTarget.checked) { + setAdded([...added, card.cardId]) + } else { + setAdded(added.filter((id) => id !== card.cardId)) + } + }} + /> ) - }); + return + }) const channels = state.filtered.map((channel, idx) => { return ( @@ -118,21 +127,19 @@ export function Content({ select }: { select: (focus: Focus) => void }) { onChange={(event) => setSubject(event.currentTarget.value)} />
- { state.strings.members } + {state.strings.members}
- { cards.length === 0 && ( + {cards.length === 0 && (
- { state.strings.noContacts } + {state.strings.noContacts}
)} - { contacts } + {contacts}
- { state.sealSet && ( - setSealed(ev.currentTarget.checked)} /> - )} + {state.sealSet && setSealed(ev.currentTarget.checked)} />}