Skip to content

Commit

Permalink
🐛 fix: template not null seller
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrogomes18 committed Jul 6, 2024
1 parent 1b17617 commit d6f7a22
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/screens/EvaluateVisit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,20 @@ const EvaluateVisit = () => {
}, [user.id, user.job]);

const handleSelectSeller = async (seller: ISeller) => {
setSelectedSeller(seller);
try {
setSelectedSeller(seller);

const { directorId, managerId } = await SellerService.getManagerAndDirectorFromSeller(seller.id);
const fetchedCategories: ICategories[] = [];
let templates: any[] | ((prevState: ITemplateVisit[]) => ITemplateVisit[]);
const {directorId, managerId} = await SellerService.getManagerAndDirectorFromSeller(seller.id);

if (managerId) {
if (managerId !== undefined || managerId !== null) {
templates = await VisitService.getTemplateByManagerId(managerId);
}else if (directorId){
} else if (directorId !== undefined || directorId !== null){
templates = await VisitService.getTemplateByDirectorId(directorId);
}else{
} else {
templates = await VisitService.getTemplateByCompanyId(seller.companyId);
}
console.log(templates)

await Promise.all(
templates.map(async (template) => {
Expand All @@ -85,6 +86,10 @@ const EvaluateVisit = () => {
);
setTemplate(templates);
setCategories(fetchedCategories);
} catch (error) {
console.error('Erro ao buscar dados de vendedores:', error);
}

};

const showToast = (message: string, type: string) => {
Expand Down

0 comments on commit d6f7a22

Please sign in to comment.