From 8fb3bdaca5c29f45d2ee308abc4ae3dee38e362c Mon Sep 17 00:00:00 2001 From: mkue Date: Sat, 28 Oct 2023 09:07:06 +0000 Subject: [PATCH] Prettified Code! --- shared/src/firebase/client/init.ts | 22 ++++++++++--------- shared/src/utils/messaging/email.ts | 12 +++------- shared/src/utils/messaging/whatsapp.ts | 9 +++----- shared/src/utils/templates.ts | 9 +++----- ui/CONTRIBUTING.md | 8 +++---- ui/src/components/carousel.tsx | 11 +++------- ui/src/components/form.tsx | 6 ++--- ui/src/components/typography/typography.tsx | 22 ++++++++++--------- .../[currency]/charts/transparency-charts.tsx | 9 +++----- .../finances/[currency]/info-card.tsx | 12 +++------- website/src/components/book/book.tsx | 15 +++---------- 11 files changed, 51 insertions(+), 84 deletions(-) diff --git a/shared/src/firebase/client/init.ts b/shared/src/firebase/client/init.ts index 91f45f180..9f97fd025 100644 --- a/shared/src/firebase/client/init.ts +++ b/shared/src/firebase/client/init.ts @@ -17,16 +17,18 @@ interface InitializeFirebaseClientProps { functionsEmulatorPort?: number; } -export const initializeFirebaseClient = ({ - firebaseConfig, - authEmulatorUrl, - firestoreEmulatorHost, - firestoreEmulatorPort, - storageEmulatorHost, - storageEmulatorPort, - functionsEmulatorHost, - functionsEmulatorPort, -}: InitializeFirebaseClientProps) => { +export const initializeFirebaseClient = ( + { + firebaseConfig, + authEmulatorUrl, + firestoreEmulatorHost, + firestoreEmulatorPort, + storageEmulatorHost, + storageEmulatorPort, + functionsEmulatorHost, + functionsEmulatorPort, + }: InitializeFirebaseClientProps, +) => { const app = getOrInitializeFirebaseClientApp(firebaseConfig); const auth = getAuth(app); const functions = getFunctions(app, DEFAULT_REGION); diff --git a/shared/src/utils/messaging/email.ts b/shared/src/utils/messaging/email.ts index 631127674..3024783d8 100644 --- a/shared/src/utils/messaging/email.ts +++ b/shared/src/utils/messaging/email.ts @@ -16,15 +16,9 @@ interface SendEmailProps { password: string; } -export const sendEmail = async ({ - from = 'no-reply@socialincome.org', - to, - subject, - content, - attachments = [], - user, - password, -}: SendEmailProps) => { +export const sendEmail = async ( + { from = 'no-reply@socialincome.org', to, subject, content, attachments = [], user, password }: SendEmailProps, +) => { let transporter: Transporter; if (!user) { const testAccount = await nodemailer.createTestAccount(); diff --git a/shared/src/utils/messaging/whatsapp.ts b/shared/src/utils/messaging/whatsapp.ts index bde18e4ed..6dd0c75c0 100644 --- a/shared/src/utils/messaging/whatsapp.ts +++ b/shared/src/utils/messaging/whatsapp.ts @@ -12,12 +12,9 @@ export interface SendWhatsappProps { templateProps: RenderTemplateProps; } -export const sendWhatsapp = async ({ - to, - from, - twilioConfig, - templateProps, -}: SendWhatsappProps): Promise => { +export const sendWhatsapp = async ( + { to, from, twilioConfig, templateProps }: SendWhatsappProps, +): Promise => { const client = new Twilio(twilioConfig.sid, twilioConfig.token); const body = await renderTemplate(templateProps); return client.messages.create({ body: body, from: `whatsapp:${from}`, to: `whatsapp:${to}` }); diff --git a/shared/src/utils/templates.ts b/shared/src/utils/templates.ts index 7fc2365d7..984ef5375 100644 --- a/shared/src/utils/templates.ts +++ b/shared/src/utils/templates.ts @@ -28,12 +28,9 @@ const partials = [ ]; partials.forEach((partial) => Handlebars.registerPartial(partial.name, readHbs(partial.path))); -export const renderTemplate = async ({ - language, - translationNamespace = [], - hbsTemplatePath, - context, -}: RenderTemplateProps) => { +export const renderTemplate = async ( + { language, translationNamespace = [], hbsTemplatePath, context }: RenderTemplateProps, +) => { const i18n = i18next.createInstance(); await i18n .use( diff --git a/ui/CONTRIBUTING.md b/ui/CONTRIBUTING.md index b25c7d2f1..f7a8867a8 100644 --- a/ui/CONTRIBUTING.md +++ b/ui/CONTRIBUTING.md @@ -54,11 +54,9 @@ UI elements: **Example**: ```tsx - export const SoExampleComponent = ({ - children, - exampleProperty, - ...props - }: SoExampleComponentProps) => { + export const SoExampleComponent = ( + { children, exampleProperty, ...props }: SoExampleComponentProps, + ) => { return (

{children} diff --git a/ui/src/components/carousel.tsx b/ui/src/components/carousel.tsx index 0aa33b9fd..c1b9658b1 100644 --- a/ui/src/components/carousel.tsx +++ b/ui/src/components/carousel.tsx @@ -14,14 +14,9 @@ type CarouselProps = { showControls?: boolean; } & React.HTMLAttributes; -export const Carousel = ({ - children, - className, - options = {}, - showDots = false, - showControls = false, - ...props -}: CarouselProps) => { +export const Carousel = ( + { children, className, options = {}, showDots = false, showControls = false, ...props }: CarouselProps, +) => { const [emblaRef, emblaApi] = useEmblaCarousel( options, options?.autoPlay?.enabled ? [Autoplay(options.autoPlay)] : [], diff --git a/ui/src/components/form.tsx b/ui/src/components/form.tsx index aab225efa..3da7d006d 100644 --- a/ui/src/components/form.tsx +++ b/ui/src/components/form.tsx @@ -22,9 +22,9 @@ const FormFieldContext = React.createContext({} as FormFi const FormField = < TFieldValues extends FieldValues = FieldValues, TName extends FieldPath = FieldPath, ->({ - ...props -}: ControllerProps) => { +>( + { ...props }: ControllerProps, +) => { return ( diff --git a/ui/src/components/typography/typography.tsx b/ui/src/components/typography/typography.tsx index 5f339233b..3a53698bf 100644 --- a/ui/src/components/typography/typography.tsx +++ b/ui/src/components/typography/typography.tsx @@ -66,16 +66,18 @@ export type TypographyProps = { lineHeight?: LineHeight; } & ComponentPropsWithoutRef; -export function Typography({ - as, - size = 'md', - weight = 'normal', - color = 'foreground', - lineHeight = 'normal', - className, - children, - ...props -}: TypographyProps) { +export function Typography( + { + as, + size = 'md', + weight = 'normal', + color = 'foreground', + lineHeight = 'normal', + className, + children, + ...props + }: TypographyProps, +) { const Component = as || 'p'; return (

diff --git a/website/src/components/book/book.tsx b/website/src/components/book/book.tsx index c5a38ebca..5efc32eb0 100644 --- a/website/src/components/book/book.tsx +++ b/website/src/components/book/book.tsx @@ -15,18 +15,9 @@ type BookProps = { currentlyReading?: boolean; }; -export default async function Book({ - cover, - author, - authorLink, - title, - description, - quote, - publisher, - publisherLink, - year, - currentlyReading, -}: BookProps) { +export default async function Book( + { cover, author, authorLink, title, description, quote, publisher, publisherLink, year, currentlyReading }: BookProps, +) { return (