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

CHANGE #625: Ocultar pesquisa avançada #626

Merged
merged 4 commits into from
Sep 5, 2024
Merged
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
85 changes: 38 additions & 47 deletions src/pages/Group/GroupTabs/GroupPeople/GroupPeople.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useContext, useState, useMemo, useEffect } from "react";
import { Link } from "react-router-dom";

import { EMPTY_LIST_CLASS, GroupContext, GroupContextType } from "@/pages/Group";
import { EMPTY_LIST_CLASS, GroupContext } from "@/pages/Group";
import { ProfileClass } from "@/types/Profile";
import { ProfileImage } from "@/components/ProfileImage/ProfileImage";

Expand All @@ -10,6 +10,7 @@ import { Filter } from "@/components/Filter/Filter";
import Select from 'react-select'
import { CompetenceType, LevelToLabel, Level, intToLevel } from "@/types/Competence";
import UniversimeApi from "@/services/UniversimeApi";
import ActionButton from "@/components/ActionButton";

type competenceSearch = {
typeId?: string,
Expand Down Expand Up @@ -45,7 +46,7 @@ export function GroupPeople() {
else
searchUsers();

}, [addedCompetences])
}, [ addedCompetences, matchEveryCompetence ])


const competenceTypeOptions = useMemo(() => {
Expand All @@ -69,6 +70,7 @@ export function GroupPeople() {
let searchCriteria = document.getElementById("search-criteria");
if(searchCriteria)
searchCriteria?.classList.remove("hidden")
setShowAdvancedSearch(false);
}

if (!groupContext)
Expand Down Expand Up @@ -116,11 +118,26 @@ export function GroupPeople() {
}

</div>
<p className="clear-search" onClick={()=>{
let searchCriteriaText = document.getElementById("search-criteria")
if(searchCriteriaText) searchCriteriaText.classList.add("hidden")
clearFilteredPeople();
}}>Limpar busca</p>

<div className="levels-div checkbox">
<label htmlFor="matchEveryCompetence">Exigir todas as competências</label>
<input
type="checkbox"
name="matchEveryCompetence"
checked={matchEveryCompetence}
onChange={()=>{setMatchEveryCompetence(!matchEveryCompetence)}}
/>
</div>

<ActionButton name="Limpar busca" biIcon="x-lg" buttonProps={{
className: "clear-search",
onClick( ) {
const searchCriteriaText = document.getElementById("search-criteria")
if(searchCriteriaText) searchCriteriaText.classList.add("hidden")
clearFilteredPeople();
setAddedCompetences([]);
}
}} />
</div>

<div className="people-list tab-list"> {
Expand Down Expand Up @@ -157,53 +174,27 @@ export function GroupPeople() {
}


<div className="add-competence-button" onClick={()=>{
if(!currentCompetence || currentCompetence.level == undefined || !currentCompetence.label || !currentCompetence.typeId) return
<ActionButton name="Adicionar competência à busca" biIcon="search" buttonProps={{
onClick( ) {
if(currentCompetence?.level == undefined || !currentCompetence.label || !currentCompetence.typeId)
return;

currentCompetence.label += ": " + LevelToLabel[currentCompetence.level]
setAddedCompetences([...addedCompetences, currentCompetence]);
currentCompetence.label += ": " + LevelToLabel[currentCompetence.level]
setAddedCompetences([...addedCompetences, currentCompetence]);

let radio = document.getElementById(`radio${currentCompetence.level}`) as HTMLInputElement

radio.checked = false
setCurrentCompetence(undefined)
}
}>
Adicionar competência à busca
</div>
let radio = document.getElementById(`radio${currentCompetence.level}`) as HTMLInputElement

<div className="levels-div checkbox">
<label htmlFor="matchEveryCompetence">Exigir todas as competências</label>
<input
type="checkbox"
name="matchEveryCompetence"
checked={matchEveryCompetence}
onChange={()=>{setMatchEveryCompetence(!matchEveryCompetence)}}
/>
</div>

<div className="added-competences-container">
{ addedCompetences.length != 0?
addedCompetences.map((competence)=>(
<div className="added-competence" key={competence.typeId??"" + competence.level}>
{competence.label}
<i className="bi bi-x" onClick={()=>{
if(competence.typeId == undefined || competence.level == undefined)
return
removeAddedCompetence(competence.typeId, competence.level);
}}></i>
</div>
))
: <></>
radio.checked = false
setCurrentCompetence(undefined)
}
</div>
}} />

<div className="search-button" onClick={searchUsers}>
Pesquisar
</div>
<ActionButton name="Fechar" biIcon="x-lg" buttonProps={{
onClick() { setShowAdvancedSearch(false) },
className: 'search-button'
}} />

</div>

)
}

Expand Down
Loading