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

Main ← Staging #68

Merged
merged 2 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
38 changes: 38 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Bug report
about: Create a report to help us improve
title: "[BUG] "
labels: bug
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
35 changes: 35 additions & 0 deletions .github/ISSUE_TEMPLATE/design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
name: Design
about: UI/UX design
title: "[DESIGN] "
labels: design
assignees: ""
---

# Summary

[Brief overview of the enhancement and why it is needed or desired]

# Motivation

[More detailed explanation of the motivation for the enhancement, including any benefits it would provide]

# Description

[Detailed description of the enhancement, including how it would work and any design considerations]

## Alternatives

[Discussion of any alternative solutions that were considered and why the proposed solution is preferred]

# Risks

[Identification and mitigation of any potential risks associated with the enhancement]

# Acceptance Criteria

[List of criteria that must be met for the enhancement to be considered accepted]

# Additional Information

[Any other relevant information, such as links to related issues or pull requests]
35 changes: 35 additions & 0 deletions .github/ISSUE_TEMPLATE/enhancement.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
name: Enhancement
about: Small improvement / enhancement (not a full feature request)
title: "[ENHANCE] "
labels: enhancement
assignees: ""
---

# Summary

[Brief overview of the enhancement and why it is needed or desired]

# Motivation

[More detailed explanation of the motivation for the enhancement, including any benefits it would provide]

# Description

[Detailed description of the enhancement, including how it would work and any design considerations]

## Alternatives

[Discussion of any alternative solutions that were considered and why the proposed solution is preferred]

# Risks

[Identification and mitigation of any potential risks associated with the enhancement]

# Acceptance Criteria

[List of criteria that must be met for the enhancement to be considered accepted]

# Additional Information

[Any other relevant information, such as links to related issues or pull requests]
25 changes: 25 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
name: Feature request
about: Suggest an idea for this project
title: "[FEATURE] "
labels: feature-request
assignees: ''

---

# Problem
Explain the problem in details

# User Story(s):
As a _______, I want to ____, so that I can

# Description
Description of solution

# Acceptance Criteria
Outline what needs to be done

# Limitations
Outline any potential limitations
# Resources
- outline links and relevant resources, references implementations
5 changes: 3 additions & 2 deletions src/components/NewHero/NewHero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import { context, useMemo } from "alem";
import HomeBannerStyle from "@app/assets/svgs/HomeBannerBackground";
import { useDonationModal } from "@app/hooks/useDonationModal";
import DonationStats from "@app/pages/Projects/components/DonationStats/DonationStats";
import getProjects from "@app/services/getProjects";
import Button from "../Button";
import { Container, HeroContainer, Line } from "./styles";

const NewHero = ({ projectsData }: any) => {
const { allProjects, approvedProjects } = projectsData;
const NewHero = () => {
const { allProjects, approvedProjects } = getProjects();

const { setDonationModalProps } = useDonationModal();

Expand Down
8 changes: 6 additions & 2 deletions src/pages/Project/Project.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ const ProjectPage = () => {

const addressExist = account?.body?.account[0];

if (!isObjectNotEmpty(addressExist || {}) && !registration)
return <div style={{ marginTop: "1rem", fontSize: "1.5rem" }}>Account does not exist.</div>;
if (!isObjectNotEmpty(addressExist || {}) && !registration) {
if (account) {
return <div style={{ marginTop: "1rem", fontSize: "1.5rem" }}>Account does not exist.</div>;
}
return "";
}

const [directDonations, setDirectDonations] = useState(null);
// mapping of pot IDs to array of Round Matching Donations for the project
Expand Down
34 changes: 6 additions & 28 deletions src/pages/Projects/Projects.tsx
Original file line number Diff line number Diff line change
@@ -1,39 +1,17 @@
import { Storage, useEffect, useState } from "alem";
import ListsSDK from "@app/SDK/lists";
import NewHero from "@app/components/NewHero/NewHero";
import AllProjects from "./components/AllProjects/AllProjects";
import FeaturedProjects from "./components/FeaturedProjects/FeaturedProjects";

const ProjectsPage = () => {
// Use storage to improve project data availability.
const PROJECTS_STORAGE_KEY = "previous-projects";
const [projectsData, setProjectsData] = useState<any>(Storage.get(PROJECTS_STORAGE_KEY));

useEffect(() => {
ListsSDK.asyncGetRegistrations().then((allProjects: any) => {
if (!allProjects) {
return { allProjects: [], featuredProjects: [] };
}

allProjects.sort((a: any, b: any) => b.submitted_ms - a.submitted_ms);

const featuredProjectIds = ["v1.foodbank.near", "potlock.near", "yearofchef.near"];

const featuredProjects = allProjects.filter((project: any) => featuredProjectIds.includes(project.registrant_id));

const approvedProjects = allProjects.filter((project: any) => project.status === "Approved");

if (projectsData?.allProjects.length !== allProjects.length)
setProjectsData({ allProjects, approvedProjects, featuredProjects });
Storage.set(PROJECTS_STORAGE_KEY, { allProjects, approvedProjects, featuredProjects });
});
}, []);
// TODO: Além -> Gerar o erro
// 1 - Comenta a linha 39 e inicia o projeto
// 2 - Descomenta a linha 39, vai gerar o erro

return (
<>
<NewHero projectsData={projectsData} />
<FeaturedProjects projectsData={projectsData} isLoading={!projectsData} />
<AllProjects projectsData={projectsData} />
<NewHero />
<FeaturedProjects />
<AllProjects />
</>
);
};
Expand Down
16 changes: 11 additions & 5 deletions src/pages/Projects/components/AllProjects/AllProjects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Social, createDebounce, useEffect, useState } from "alem";
import DonateSDK from "@app/SDK/donate";
import Card from "@app/components/Card/Card";
import FilterDropdown from "@app/components/Inputs/FilterDropdown/FilterDropdown";
import getProjects from "@app/services/getProjects";
import { Project } from "@app/types";
import getTagsFromSocialProfileData from "@app/utils/getTagsFromSocialProfileData";
import getTeamMembersFromSocialProfileData from "@app/utils/getTeamMembersFromSocialProfileData";
Expand All @@ -11,10 +12,8 @@ import SearchBar from "../SearchBar/SearchBar";
import { ProjectsContainer, FilterWrapper, Title, Container, Header } from "./styles";
import tagsList from "./tagsList";

// import ListsSDK from "@app/SDK/lists";

const AllProjects = ({ projectsData }: { projectsData: any }) => {
// const isRegistryAdmin = ListsSDK.isRegistryAdmin(context.accountId);
const AllProjects = () => {
const projectsData = getProjects();

const [totalDonation, setTotalDonation] = useState(0);
const [totalDonated, setTotalDonated] = useState("0");
Expand All @@ -34,7 +33,7 @@ const AllProjects = ({ projectsData }: { projectsData: any }) => {
return "";
}

const donateConfig = DonateSDK.getConfig();
const donateConfig: any = DonateSDK.getConfig();
if (donateConfig && !totalDonated && !totalDonation) {
const lastDonationAmount = yoctosToUsd(donateConfig.net_donations_amount);
setTotalDonated(lastDonationAmount);
Expand Down Expand Up @@ -156,7 +155,14 @@ const AllProjects = ({ projectsData }: { projectsData: any }) => {
</Header>
<ProjectsContainer>
{filteredProjects.length ? (
// TODO: Isso quebra (incluindo o "shouldShuffle")
// <ListSection
// shouldShuffle
// items={filteredProjects}
// renderItem={(project: Project) => <Card projectId={project.registrant_id} />}
// />
<ListSection
shouldShuffle={true}
items={filteredProjects}
renderItem={(project: Project) => <Card projectId={project.registrant_id} />}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import { useEffect, useMemo, useState } from "alem";
import Card from "@app/components/Card/Card";
import getProjects from "@app/services/getProjects";
import { Project } from "@app/types";
import CardSkeleton from "../CardSkeleton";
import { ContainerHeader, Header, OnBottom, ProjectList, Title } from "./styles";

const FeaturedProjects = ({ projectsData, isLoading }: { projectsData: any; isLoading: boolean }) => {
const FeaturedProjects = () => {
const projectsData = getProjects();
const [projects, setProjects] = useState<Project[]>([]);

// console.log("B", projectsData, projects, isLoading);
// console.log('FeaturedProjects - Render');

// TODO: Criar um formato para o compilador saber quando é um arquivo
// de custom hook e injetar no arquivo
useEffect(() => {
if (projectsData) {
const { featuredProjects } = projectsData;
Expand Down Expand Up @@ -44,9 +41,7 @@ const FeaturedProjects = ({ projectsData, isLoading }: { projectsData: any; isLo
<Title>Featured projects</Title>
</Header>

<ProjectList>
{projects.length === 0 || !projectsData || isLoading ? <LoadingCards /> : <>{projectCards}</>}
</ProjectList>
<ProjectList>{projects.length === 0 || !projectsData ? <LoadingCards /> : <>{projectCards}</>}</ProjectList>
<OnBottom></OnBottom>
</ContainerHeader>
);
Expand Down
22 changes: 20 additions & 2 deletions src/services/getProjects.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
import { Storage } from "alem";
import ListsSDK from "@app/SDK/lists";
import { Project } from "@app/types";

const PROJECTS_STORAGE_KEY = "previous-projects";

type Data = {
allProjects: Project[];
approvedProjects: Project[];
featuredProjects: Project[];
};

/**
* Get current projects.
Expand All @@ -8,7 +18,7 @@ const getProjects = () => {
const allProjects = ListsSDK.getRegistrations();

if (!allProjects) {
return { allProjects: [], featuredProjects: [] };
return { allProjects: [], approvedProjects: [], featuredProjects: [] } as Data;
}

allProjects.sort((a: any, b: any) => b.submitted_ms - a.submitted_ms);
Expand All @@ -19,7 +29,15 @@ const getProjects = () => {

const approvedProjects = allProjects.filter((project: any) => project.status === "Approved");

return { allProjects, approvedProjects, featuredProjects };
const previousData = Storage.get(PROJECTS_STORAGE_KEY);

if (previousData) {
return previousData as Data;
}

Storage.set(PROJECTS_STORAGE_KEY, { allProjects, approvedProjects, featuredProjects });

return { allProjects, approvedProjects, featuredProjects } as Data;
};

export default getProjects;
Loading