Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moderators UI #646

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
7b9242d
fix solution action
Megha-Dev-19 Dec 7, 2023
a9fee68
Merge branch 'main' of https://github.com/Megha-Dev-19/neardevhub-wid…
Megha-Dev-19 Dec 8, 2023
7c6ee84
Merge branch 'near:main' into main
Megha-Dev-19 Dec 18, 2023
218a120
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Dec 18, 2023
ac0bd6e
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Dec 19, 2023
6d31741
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Dec 29, 2023
1fd7eb1
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Dec 30, 2023
9a4c7a2
Merge branch 'main' of https://github.com/Megha-Dev-19/neardevhub-wid…
Megha-Dev-19 Jan 3, 2024
07c55a3
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Jan 4, 2024
fa8d436
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Jan 5, 2024
4b75fa1
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Jan 8, 2024
238bc31
added trustees dashboard
Megha-Dev-19 Jan 9, 2024
6430351
update links
Megha-Dev-19 Jan 9, 2024
4f5b0c3
css updates
Megha-Dev-19 Jan 9, 2024
f9b4da7
btn css update
Megha-Dev-19 Jan 9, 2024
6fcc830
treasure UI update
Megha-Dev-19 Jan 9, 2024
873c77a
made padding and fontsize changes
Megha-Dev-19 Jan 9, 2024
180d7f1
update treasury padding
Megha-Dev-19 Jan 9, 2024
13704ef
added contract integration
Megha-Dev-19 Jan 13, 2024
1ae23ac
add permissions logic
Megha-Dev-19 Jan 13, 2024
2b5e027
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Jan 19, 2024
b850265
Merge branch 'main' into trustees-dashboard
Megha-Dev-19 Jan 19, 2024
a6e3ddf
made few contract integration updates
Megha-Dev-19 Jan 21, 2024
d2bae2d
Merge branch 'NEAR-DevHub:main' into main
Megha-Dev-19 Jan 23, 2024
505b4a2
Merge branch 'main' into trustees-dashboard
Megha-Dev-19 Jan 23, 2024
ca5a30b
rename files
Megha-Dev-19 Jan 23, 2024
0f87267
remove files
Megha-Dev-19 Jan 23, 2024
fc7fb47
basic setup
Megha-Dev-19 Jan 24, 2024
b1c55f2
added moderators ui
Megha-Dev-19 Jan 25, 2024
51472fa
minor css updates
Megha-Dev-19 Jan 25, 2024
f896480
fix tabs bug
Megha-Dev-19 Jan 25, 2024
dea24c4
fix tabs
Megha-Dev-19 Feb 7, 2024
f7f23a9
updated treasury, create payment req
Megha-Dev-19 Feb 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions replacements.dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"REPL_NEAR": "discom.testnet",
"REPL_MOB": "eugenethedream",
"REPL_EFIZ": "efiz.testnet",
"REPL_TREASURY_CONTRACT": "treasury.dhthomas.testnet",
"REPL_PROPOSAL_CONTRACT": "proposal_feature.testnet",
"REPL_DEVS": "nearbuilders.testnet",
"REPL_SOCIAL_CONTRACT": "v1.social08.testnet"
}
2 changes: 2 additions & 0 deletions replacements.mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"REPL_NEAR": "near",
"REPL_MOB": "mob.near",
"REPL_EFIZ": "efiz.near",
"REPL_TREASURY_CONTRACT": "treasurydevhub.near",
"REPL_PROPOSAL_CONTRACT": "proposal_feature.testnet",
"REPL_DEVS": "devs.near",
"REPL_SOCIAL_CONTRACT": "social.near"
}
2 changes: 2 additions & 0 deletions replacements.testnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"REPL_NEAR": "discom.testnet",
"REPL_MOB": "eugenethedream",
"REPL_EFIZ": "efiz.testnet",
"REPL_TREASURY_CONTRACT": "treasury.dhthomas.testnet",
"REPL_PROPOSAL_CONTRACT": "proposal_feature.testnet",
"REPL_DEVS": "nearbuilders.testnet",
"REPL_SOCIAL_CONTRACT": "v1.social08.testnet"
}
9 changes: 9 additions & 0 deletions src/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ function Page() {
/>
);
}
// ?page=devDaoDashboard
case "devDaoDashboard": {
return (
<Widget
src={"${REPL_DEVHUB}/widget/devhub.page.dashboard"}
props={passProps}
/>
);
}
// ?page=community
case "community": {
return (
Expand Down
24 changes: 24 additions & 0 deletions src/core/lib/timeUtils.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
function getRelativeTime(timestamp) {
const currentTimestamp = new Date().getTime();
const targetTimestamp = new Date(timestamp).getTime();

const differenceInMilliseconds = currentTimestamp - targetTimestamp;
const differenceInDays = Math.floor(
differenceInMilliseconds / (1000 * 60 * 60 * 24)
);
const differenceInHours = Math.floor(
(differenceInMilliseconds % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)
);

if (differenceInDays > 0) {
return `${differenceInDays} ${differenceInDays === 1 ? "day" : "days"} ago`;
} else if (differenceInHours > 0) {
return `${differenceInHours} ${
differenceInHours === 1 ? "hour" : "hours"
} ago`;
} else {
return "Less than an hour ago";
}
}

return { getRelativeTime };
148 changes: 148 additions & 0 deletions src/devhub/components/molecule/DropDownWithSearch.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
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,
});

useEffect(() => {
if (selectedOption.value !== selectedValue) {
setSelectedOption({
label:
options?.find((item) => item.value === selectedValue)?.label ??
defaultLabel,
value: defaultLabel,
});
}
}, [selectedValue]);

useEffect(() => {
setFilteredOptions(options);
}, [options]);

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.value);
};
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 (
<Container>
<label>{label}</label>
<div className="custom-select">
<div className="select-header" onClick={toggleDropdown}>
<div
className={`selected-option ${
selectedOption.label === defaultLabel ? "text-grey" : ""
}`}
>
{selectedOption.label}
</div>
<i class={`bi bi-chevron-${isOpen ? "up" : "down"}`}></i>
</div>

{isOpen && (
<div className="options-card">
{showSearch && (
<input
type="text"
className="form-control mb-2"
placeholder="Search options"
value={searchTerm}
onChange={handleSearch}
/>
)}
<div className="scroll-box">
{filteredOptions.map((option) => (
<div
key={option.value}
className={`option ${
selectedOption.value === option.value ? "selected" : ""
}`}
onClick={() => handleOptionClick(option)}
>
{option.label}
</div>
))}
</div>
</div>
)}
</div>
</Container>
);
2 changes: 1 addition & 1 deletion src/devhub/components/molecule/Input.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const TextInput = ({
const renderedLabels = [
(label?.length ?? 0) > 0 ? (
<span className="d-inline-flex gap-1 text-wrap">
<span>{label}</span>
<label>{label}</label>

{inputProps.required ? <span className="text-danger">*</span> : null}
</span>
Expand Down
97 changes: 97 additions & 0 deletions src/devhub/components/molecule/Pagination.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
const totalPages = props.totalPages ?? 12; // Assume you have 12 pages
const maxVisiblePages = props.maxVisiblePages ?? 5;
const onPageClick = props.onPageClick
? props.onPageClick
: () => console.log("clicked");
const pagesToShow = Math.min(totalPages, maxVisiblePages);
const [selectedPage, setSelectedPage] = useState(props.selectedPage ?? 1);
const totalPageSets = Math.ceil(totalPages / maxVisiblePages);
const [currentPageSet, setCurrentPageSet] = useState(1);

const Pagination = styled.div`
display: flex;
gap: 12px;

div {
display: flex;
height: 30px;
min-width: 30px;
padding: 12px;
justify-content: center;
align-items: center;
gap: 10px;
border-radius: 8px;
transition: all 300ms;
cursor: pointer;

/* Other/Button_text */
font-size: 14px;
font-style: normal;
font-weight: 500;
line-height: normal;

&.selected,
&:hover {
background-color: #23242b;
color: white;
}

&.arrow {
border: 1px solid rgba(255, 255, 255, 0.2);
}

&.disabled {
cursor: not-allowed;
}
}
`;

const handlePageClick = (pageNumber) => {
onPageClick(pageNumber);
};

const handleArrowClick = (direction) => {
if (direction === "left") {
setCurrentPageSet(Math.max(currentPageSet - 1, 1));
} else {
setCurrentPageSet(
Math.min(currentPageSet + 1, Math.ceil(totalPages / maxVisiblePages))
);
}
};

const getPageNumber = (index) =>
(currentPageSet - 1) * maxVisiblePages + index + 1;

return (
<Pagination>
<div
className={`arrow ${currentPageSet === 1 ? "disabled" : undefined}`}
onClick={() => handleArrowClick("left")}
>
<i className="bi bi-arrow-left"></i>
</div>
{Array.from({ length: pagesToShow }).map((_, index) => {
const pageNumber = getPageNumber(index);
return (
<div
key={pageNumber}
className={pageNumber === selectedPage ? "selected" : undefined}
onClick={() => handlePageClick(pageNumber)}
>
{pageNumber}
</div>
);
})}
<div
className={`arrow ${
currentPageSet === Math.ceil(totalPages / maxVisiblePages)
? "disabled"
: undefined
}`}
onClick={() => handleArrowClick("right")}
>
<i className="bi bi-arrow-right"></i>
</div>
</Pagination>
);
1 change: 1 addition & 0 deletions src/devhub/entity/moderator/Accounting.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
return <div>Accounting Page</div>;
Loading
Loading