From b1c55f24b44c105f9efbf42c0b84a6cc90acda11 Mon Sep 17 00:00:00 2001 From: Megha-Dev-19 Date: Fri, 26 Jan 2024 00:16:15 +0530 Subject: [PATCH] added moderators ui --- .../molecule/DropDownWithSearch.jsx | 133 +++++++++++ src/devhub/components/molecule/Input.jsx | 2 +- src/devhub/components/molecule/Pagination.jsx | 4 +- src/devhub/entity/moderator/Accounting.jsx | 2 +- .../entity/moderator/CreatePaymentRequest.jsx | 187 ++++++++++++++-- .../entity/moderator/CreateRecipient.jsx | 211 ++++++++++++++++++ src/devhub/entity/moderator/Dashboard.jsx | 10 +- .../entity/moderator/ManageRecipients.jsx | 209 ++++++++++++++++- src/devhub/entity/moderator/Staking.jsx | 2 +- .../entity/moderator/TransactionHistory.jsx | 1 - src/devhub/entity/trustee/History.jsx | 2 +- 11 files changed, 732 insertions(+), 31 deletions(-) create mode 100644 src/devhub/components/molecule/DropDownWithSearch.jsx create mode 100644 src/devhub/entity/moderator/CreateRecipient.jsx delete mode 100644 src/devhub/entity/moderator/TransactionHistory.jsx diff --git a/src/devhub/components/molecule/DropDownWithSearch.jsx b/src/devhub/components/molecule/DropDownWithSearch.jsx new file mode 100644 index 000000000..9313d2f8c --- /dev/null +++ b/src/devhub/components/molecule/DropDownWithSearch.jsx @@ -0,0 +1,133 @@ +const { selectedValue, onChange, label, options, defaultLabel, showSearch } = + props; + +const [searchTerm, setSearchTerm] = useState(""); +const [filteredOptions, setFilteredOptions] = useState(options); +const [isOpen, setIsOpen] = useState(false); +const [selectedOption, setSelectedOption] = useState({ + label: + options?.find((item) => item.value === selectedValue)?.label ?? + defaultLabel, + value: defaultLabel, +}); + +const handleSearch = (event) => { + const searchTerm = event.target.value.toLowerCase(); + setSearchTerm(searchTerm); + + const filteredOptions = options.filter((option) => + option.label.toLowerCase().includes(searchTerm) + ); + + setFilteredOptions(filteredOptions); +}; + +const toggleDropdown = () => { + setIsOpen(!isOpen); +}; + +const handleOptionClick = (option) => { + setSelectedOption(option); + setIsOpen(false); + onChange(option); +}; +const Container = styled.div` + .custom-select { + position: relative; + } + + .select-header { + display: flex; + justify-content: space-between; + align-items: center; + padding: 10px; + border: 1px solid #ccc; + border-radius-top: 5px; + cursor: pointer; + background-color: #fff; + } + + .options-card { + position: absolute; + top: 100%; + left: 0; + width: 100%; + border: 1px solid #ccc; + background-color: #fff; + padding: 0.5rem; + z-index: 9999; + } + + .scroll-box { + max-height: 200px; + overflow-y: scroll; + } + + .option { + padding: 10px; + cursor: pointer; + border-bottom: 1px solid #f0f0f0; + transition: background-color 0.3s ease; + } + + .option:hover { + background-color: #f0f0f0; /* Custom hover effect color */ + } + + .option:last-child { + border-bottom: none; + } + + .selected { + background-color: #f0f0f0; + } + + input { + background-color: #f8f9fa; + } +`; + +return ( + + +
+
+
+ {selectedOption.label} +
+ +
+ + {isOpen && ( +
+ {showSearch && ( + + )} +
+ {filteredOptions.map((option) => ( +
handleOptionClick(option)} + > + {option.label} +
+ ))} +
+
+ )} +
+
+); diff --git a/src/devhub/components/molecule/Input.jsx b/src/devhub/components/molecule/Input.jsx index 9aa5db5ad..923eba069 100644 --- a/src/devhub/components/molecule/Input.jsx +++ b/src/devhub/components/molecule/Input.jsx @@ -47,7 +47,7 @@ const TextInput = ({ const renderedLabels = [ (label?.length ?? 0) > 0 ? ( - {label} + {inputProps.required ? * : null} diff --git a/src/devhub/components/molecule/Pagination.jsx b/src/devhub/components/molecule/Pagination.jsx index ed01ba1b7..f7b7786d1 100644 --- a/src/devhub/components/molecule/Pagination.jsx +++ b/src/devhub/components/molecule/Pagination.jsx @@ -14,8 +14,8 @@ const Pagination = styled.div` div { display: flex; - height: 40px; - min-width: 40px; + height: 30px; + min-width: 30px; padding: 12px; justify-content: center; align-items: center; diff --git a/src/devhub/entity/moderator/Accounting.jsx b/src/devhub/entity/moderator/Accounting.jsx index 74603496e..87a747f86 100644 --- a/src/devhub/entity/moderator/Accounting.jsx +++ b/src/devhub/entity/moderator/Accounting.jsx @@ -1 +1 @@ -return
; +return
Accounting Page
; diff --git a/src/devhub/entity/moderator/CreatePaymentRequest.jsx b/src/devhub/entity/moderator/CreatePaymentRequest.jsx index 0713d60c6..51eef9e21 100644 --- a/src/devhub/entity/moderator/CreatePaymentRequest.jsx +++ b/src/devhub/entity/moderator/CreatePaymentRequest.jsx @@ -1,31 +1,178 @@ -const { useState } = require("react"); - const [form, setForm] = useState(null); // dropdown options -const [fromWalletOptions, setFromWalletOptions] = useState([]); +const [fromWalletOptions, setFromWalletOptions] = useState([ + { label: "devhub.near", value: "devhub.near" }, + { label: "devgovgigs.near", value: "devgovgigs.near" }, +]); const [proposals, setProposals] = useState([]); -const [recipientsOptions, setReceientsOptions] = useState([]); -const [tokensOptions, setTokenOptions] = useState([]); +const [recipientsOptions, setReceientsOptions] = useState([ + { label: "devhub.near", value: "devhub.near" }, + { label: "devgovgigs.near", value: "devgovgigs.near" }, +]); +const [tokensOptions, setTokenOptions] = useState([ + { label: "NEAR", value: "near" }, + { label: "USDT", value: "usdt" }, +]); -return ( -
-

Create Payment Request

+const Container = styled.div` + margin-top: 10px; + font-size: 14px; + width: 40%; + + @media screen and (max-width: 1300px) { + width: 60%; + } + + @media screen and (max-width: 1000px) { + width: 100%; + } + + .text-grey { + color: #b9b9b9 !important; + } + + .card-custom { + border-radius: 5px; + background-color: white; + } + + label { + font-weight: 600; + margin-bottom: 3px; + font-size: 15px; + } + + .p-2 { + padding: 0px !important; + } + + .green-btn { + background-color: #04a46e !important; + color: white; + } +`; + +function onCancelClick() {} -
+function onSubmitClick() {} + +const VerificationIconContainer = ({ isVerified, label }) => { + return ( +
+ {isVerified ? ( + + ) : ( + "Need icon" + )} +
{label}
+
+ ); +}; + +return ( + +
Create Payment Request
+ {}, + label: "From Wallet", + options: fromWalletOptions, + showSearch: true, + defaultLabel: "neardevhub.near", + }} + /> + {}, + label: "Choose Proposal", + options: proposals, + showSearch: true, + defaultLabel: "Seach proposals", + }} + /> + {}, + label: "To Wallet (Recipient)", + options: recipientsOptions, + showSearch: true, + defaultLabel: "neardevhub.near", + }} + /> +
+ + +

+ You can add new recipients in the Manage Recipients tab. +

+
+ {}, + label: "Currency", + options: tokensOptions, + showSearch: false, + defaultLabel: "NEAR Tokens", + }} + /> + {}, + placeholder: "Enter amount", + value: form, + inputProps: { + type: "number", + }, + }} + /> + {}, + placeholder: "Enter memo", + value: form, + }} + /> +
+
-
-); \ No newline at end of file + +); diff --git a/src/devhub/entity/moderator/CreateRecipient.jsx b/src/devhub/entity/moderator/CreateRecipient.jsx new file mode 100644 index 000000000..a105b2ecb --- /dev/null +++ b/src/devhub/entity/moderator/CreateRecipient.jsx @@ -0,0 +1,211 @@ +const [form, setForm] = useState(null); + +// dropdown options +const [fromWalletOptions, setFromWalletOptions] = useState([]); +const [selectedOption, setSelectedOption] = useState("Confirmed"); + +const handleOptionChange = (event) => { + setSelectedOption(event.target.value); +}; + +const Container = styled.div` + margin-top: 10px; + font-size: 14px; + width: 40%; + + @media screen and (max-width: 1300px) { + width: 60%; + } + + @media screen and (max-width: 1000px) { + width: 100%; + } + + .text-grey { + color: #b9b9b9 !important; + } + + .card-custom { + border-radius: 5px; + background-color: white; + } + + label { + font-weight: 600; + margin-bottom: 3px; + font-size: 15px; + } + + .p-2 { + padding: 0px !important; + } + + .green-btn { + background-color: #04a46e !important; + color: white; + } + + .text-size-1 { + font-weight: normal; + font-size: 13px; + } + + .text-dark-grey { + color: #818181; + } + + .form-check-input:checked { + background-color: #04a46e; + border-color: #04a46e; + color: #fff; + } +`; + +function onCancelClick() {} + +function onSubmitClick() {} + +const VerificationIconContainer = ({ isVerified, label }) => { + return ( +
+ {isVerified ? ( + + ) : ( + "Need icon" + )} +
{label}
+
+ ); +}; + +return ( + +
Create New Recipient
+ {}, + placeholder: "Enter first name", + value: form, + }} + /> + {}, + placeholder: "Enter last name", + value: form, + }} + /> + {}, + placeholder: "Enter email address", + value: form, + }} + /> +
+ + {}} + placeholder="Enter organisation" + value={form} + /> +
+ + {}, + label: "Wallet Address", + options: fromWalletOptions, + showSearch: true, + defaultLabel: "neardevhub.near", + }} + /> + + {}, + placeholder: "Enter URL", + value: form, + }} + /> +
+ +
+
+ + +
+ +
+ + +
+
+
+
+ + +
+
+); diff --git a/src/devhub/entity/moderator/Dashboard.jsx b/src/devhub/entity/moderator/Dashboard.jsx index e2324f3f8..443304ba1 100644 --- a/src/devhub/entity/moderator/Dashboard.jsx +++ b/src/devhub/entity/moderator/Dashboard.jsx @@ -38,8 +38,10 @@ const tabs = [ }, { title: "Transaction History", - view: "TransactionHistory", - props: {}, + view: "History", + props: { + title: "Transaction History", + }, }, { title: "Manage Recipients", @@ -94,7 +96,9 @@ return ( {currentTab && (
diff --git a/src/devhub/entity/moderator/ManageRecipients.jsx b/src/devhub/entity/moderator/ManageRecipients.jsx index 74603496e..6b493173f 100644 --- a/src/devhub/entity/moderator/ManageRecipients.jsx +++ b/src/devhub/entity/moderator/ManageRecipients.jsx @@ -1 +1,208 @@ -return
; +const treasuryDaoID = "${REPL_TREASURY_CONTRACT}"; +const resPerPage = 50; +const [currentPage, setPage] = useState(0); + +const [showCreatePage, setCreatePage] = useState(false); + +const RecipientsData = [ + { + id: 1, + firstName: "Megha", + lastName: "Goel", + organisation: "", + kycVerified: true, + accountId: "megha19.near", + testTransactionStatus: true, + totalTransactions: 10, + totalPaid: "1500", + }, + { + id: 2, + firstName: "Megha", + lastName: "Goel", + organisation: "", + kycVerified: true, + accountId: "", + testTransactionStatus: false, + totalTransactions: 15, + totalPaid: "1000", + }, +]; + +const Container = styled.div` + font-size: 13px; + + .text-grey { + color: #b9b9b9 !important; + } + + .card-custom { + border-radius: 5px; + background-color: white; + } + + .text-size-2 { + font-size: 15px; + } + + .text-dark-grey { + color: #687076; + } + + .text-grey-100 { + background-color: #f5f5f5; + } + + .text-underline { + text-decoration: underline; + } + + td { + padding: 0.5rem; + color: inherit; + } + + .overflow { + overflow: auto; + } + + .max-w-100 { + max-width: 100%; + } + + tr { + vertical-align: middle; + } + + .text-red { + color: #dc6666; + } + + .green-button { + background-color: #04a46e; + color: white; + border-color: #04a46e; + } + + .grey-button { + background-color: #687076; + color: white; + border: none; + border-radius: 0.3rem; + padding-block: 0.2rem; + padding-inline: 0.5rem; + } +`; + +const RecipientsComponent = () => { + return ( + + {RecipientsData?.map((item, index) => { + // USE API + const isReceiverkycbVerified = true; + + return ( + + {item.id} + {item.firstName} + + {item.lastName} + + + {item.organisation ?? "-"} + + + {isReceiverkycbVerified ? ( + + ) : ( + "Need icon" + )} + + {item.accountId} + + {item.testTransactionStatus ? ( + Confirmed + ) : ( + Not Confirmed + )} + + {item.totalTransactions} + + +{parseFloat(item.totalPaid).toLocaleString("en-US")} + + + +
+ + +
+ + + ); + })} + + ); +}; + +if (showCreatePage) { + return ( + + ); +} + +return ( + +
+
Manage Recipients
+
+ + +
+
+ +
+ + + + + + + + + + + + + + + + +
IDFIRST NAMELAST NAMEORGANISATIONKYC/B VERIFIEDWALLETTEST TRANSACTIONS# TRANSACTIONSTOTAL PAIDACTIONS
+
+
+ setPage(v), + }} + /> +
+
+); diff --git a/src/devhub/entity/moderator/Staking.jsx b/src/devhub/entity/moderator/Staking.jsx index 74603496e..2b485c3b0 100644 --- a/src/devhub/entity/moderator/Staking.jsx +++ b/src/devhub/entity/moderator/Staking.jsx @@ -1 +1 @@ -return
; +return
Staking Page
; diff --git a/src/devhub/entity/moderator/TransactionHistory.jsx b/src/devhub/entity/moderator/TransactionHistory.jsx deleted file mode 100644 index 74603496e..000000000 --- a/src/devhub/entity/moderator/TransactionHistory.jsx +++ /dev/null @@ -1 +0,0 @@ -return
; diff --git a/src/devhub/entity/trustee/History.jsx b/src/devhub/entity/trustee/History.jsx index 1ee91d04a..b9813d5c0 100644 --- a/src/devhub/entity/trustee/History.jsx +++ b/src/devhub/entity/trustee/History.jsx @@ -166,7 +166,7 @@ const ProposalsComponent = () => { return (
-
Payment History
+
{props.title ?? "Payment History"}
{/* currently we don't support any filter */} {/*