Skip to content

Commit

Permalink
[feat] status functionality with bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Neha committed Dec 4, 2024
1 parent a8e15dc commit 9873994
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 9 deletions.
1 change: 0 additions & 1 deletion api/supabase/queries/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export async function queryProjectbyId(id: number): Promise<Project> {
}

export async function queryDefaultImages(category: string) {
console.log('Fetching default image for category:', category);
const { data: defaultImage, error } = await supabase
.from('Renewable Energy Technology')
.select('*')
Expand Down
2 changes: 2 additions & 0 deletions components/Filter/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ export default function Filter({
icon={filter.icon}
label={filter.label}
currFilter={filter}
handleFilterButtonClick={handleFilterButtonClick}
clearFilters={clearFilters}
/>
) : // Add other filter dropdown components here
null
Expand Down
18 changes: 14 additions & 4 deletions components/MapViewScreen/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,21 @@ export default function MapViewScreen({
const handleFilterButtonClick = () => {
/* eslint-disable @typescript-eslint/no-unused-vars */
const { status, technology, projectSize, location } = selectedFilters;
let filteredProjects = projects;

// add all filtering logic here
const technologyProjects = projects?.filter(project =>
technology.includes(project.renewable_energy_technology),
);
setFilteredProjectsFromDropdowns(technologyProjects);
if (technology.length > 0) {
filteredProjects = filteredProjects.filter(project =>
technology.includes(project.renewable_energy_technology),
);
}

if (status.length > 0) {
filteredProjects = filteredProjects.filter(project =>
status.includes(project.project_status),
);
}
setFilteredProjectsFromDropdowns(filteredProjects);
};

// search within all projects or filtered projects from dropdowns
Expand Down
2 changes: 1 addition & 1 deletion components/ProjectItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export default function ProjectItem({
// Sets status label to "Operational" or "In Progress"
let projectStatus = project_status;
if (project_status !== 'Operational') {
projectStatus = 'In Progress';
projectStatus = 'Proposed';
}

// Sets status icon to OperationalIcon or InProgressIcon
Expand Down
13 changes: 10 additions & 3 deletions components/StatusDropdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ interface StatusDropdownProps {
icon: React.ReactNode;
label: string;
currFilter: FilterType;
handleFilterButtonClick: () => void;
clearFilters: () => void;
}

export default function StatusDropdown({
Expand All @@ -36,9 +38,11 @@ export default function StatusDropdown({
icon,
label,
currFilter,
handleFilterButtonClick,
clearFilters,
}: StatusDropdownProps) {
const filterOptions = [
{ title: 'In Progress', color: `${COLORS.ashGrey}` },
{ title: 'Proposed', color: `${COLORS.ashGrey}` },
{ title: 'Operational', color: `${COLORS.chateauGreen}` },
];

Expand All @@ -58,7 +62,7 @@ export default function StatusDropdown({
<ButtonStyles>
<FilterNameText>{label}</FilterNameText>
</ButtonStyles>
<ExitStyles>
<ExitStyles onClick={clearFilters}>
<ExitIcon />
</ExitStyles>
</ButtonWithIconStyles>
Expand All @@ -79,7 +83,10 @@ export default function StatusDropdown({
</CheckboxContainer>
))}
</div>
<ApplyButtonStyles isActive={isApplyButtonActive}>
<ApplyButtonStyles
isActive={isApplyButtonActive}
onClick={handleFilterButtonClick}
>
<ApplyFiltersText>APPLY</ApplyFiltersText>
</ApplyButtonStyles>
</FilterContentDiv>
Expand Down

0 comments on commit 9873994

Please sign in to comment.