From 218a32821a25c3fb26a5a9cb7276dea32060d36e Mon Sep 17 00:00:00 2001 From: danidfra Date: Thu, 19 Sep 2024 01:09:27 -0300 Subject: [PATCH] Created new component "AddNewAccount" --- .../ui/components/new-account-zap-split.tsx | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 src/features/ui/components/new-account-zap-split.tsx diff --git a/src/features/ui/components/new-account-zap-split.tsx b/src/features/ui/components/new-account-zap-split.tsx new file mode 100644 index 000000000..e0e634f92 --- /dev/null +++ b/src/features/ui/components/new-account-zap-split.tsx @@ -0,0 +1,97 @@ +import React, { useEffect, useState } from 'react'; +import { FormattedMessage } from 'react-intl'; + +import Account from 'soapbox/components/account'; +import { ListItem } from 'soapbox/components/list'; +import { Button, HStack, Input, Slider } from 'soapbox/components/ui'; +import SearchZapSplit from 'soapbox/features/compose/components/search-zap-split'; +import { type Account as AccountEntity } from 'soapbox/schemas'; + +const closeIcon = require('@tabler/icons/outline/x.svg'); + +interface INewAccount { + acc: string; + message: string; + weight: number; +} + +interface AddNewAccountProps { + newAccount: INewAccount; + newWeight: number; + setNewAccount: React.Dispatch>; + handleChange: (newWeight: number) => void; + formattedWeight: (weight: number) => number; + closeNewAccount: () => void; +} + +const AddNewAccount: React.FC = ({ + newAccount, + newWeight, + setNewAccount, + handleChange, + formattedWeight, + closeNewAccount, +}) => { + + const [accountSelected, setAccountSelected] = useState(null); + + useEffect(() => { + if (accountSelected) { + setNewAccount((previousValue) => ({ + ...previousValue, + acc: accountSelected?.id || '', + })); + } + }, [accountSelected, setNewAccount]); + + return ( + }> +
+
+ + {accountSelected ? +
+ +
+ : +
+ + +
+ } + +
+ + + setNewAccount((previousValue) => ({ + ...previousValue, + message: e.target.value, + })) + } + /> +
+
+ + +
+ {formattedWeight(newWeight)}% + handleChange(e)} /> +
+ +
+
+ ); +}; + +export default AddNewAccount; \ No newline at end of file