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

Removing all unnecessary console.log or changing them on console.error in the frontend code base #1423

Merged
merged 4 commits into from
Oct 16, 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
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const HeaderLoginModal = () => {
)
.catch(
(e) => {
console.log(e);
console.error(e);
},
);
}, [login.isOpen]);
Expand Down
4 changes: 2 additions & 2 deletions src/app/common/services/auth-service/AuthService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default class AuthService {
localStorage.setItem(this.refreshTokenStorageName, response.refreshToken);
})
.catch((error) => {
console.log(error);
console.error(error);
return Promise.reject(error);
});
}
Expand Down Expand Up @@ -69,7 +69,7 @@ export default class AuthService {
localStorage.setItem(this.accessTokenStorageName, response.accessToken);
})
.catch((error) => {
console.log(error);
console.error(error);
return Promise.reject(error);
});
};
Expand Down
2 changes: 1 addition & 1 deletion src/app/common/utils/paginateRequest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function paginateRequest(
const fetchNextPage = async () => {
const currentPage = page;
const response = await request(currentPage, pageSize, args).catch((error) => {
console.error('Error in request:', error);
console.error(error);
});

if (response.length === 0) {
Expand Down
9 changes: 6 additions & 3 deletions src/app/stores/news-store/news-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,20 @@ export default class NewsStore {
.then((news) => {
this.CurrentNewsId = news.id;
})
.catch((error) => console.error(error));
.catch((error) => {
console.error(error);
});
};

public getAll = async (pageSize?: number) => {
await NewsApi.getAll(this.CurrentPage, pageSize ?? 1)
.then((resp) => {
console.log(resp);
this.PaginationInfo = resp.paginationInfo;
this.setNewsMap(resp.data);
})
.catch((error) => console.error(error));
.catch((error) => {
console.error(error);
});
};

public createNews = async (news: News) => {
Expand Down
4 changes: 2 additions & 2 deletions src/app/stores/position-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default class PositionsStore {
try {
return await PositionsApi.getAll();
} catch (error: unknown) {
console.log(error);
console.error(error);
}
return [];
}
Expand All @@ -27,7 +27,7 @@ export default class PositionsStore {
.then((value) => {
this.positions = value.map((s) => ({ id: s.id, position: s.position }));
}).catch((error) => {
console.log(error);
console.error(error);
});
};

Expand Down
8 changes: 4 additions & 4 deletions src/app/stores/sourceadmin-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default class SourcesAdminStore {
try {
this.setInternalSourceCategories(await sourcesApi.getAllCategories());
} catch (error: unknown) {
console.log(error);
console.error(error);
}
};

Expand All @@ -48,7 +48,7 @@ export default class SourcesAdminStore {
this.srcSourcesMap.delete(srcId);
});
} catch (error: unknown) {
console.log(error);
console.error(error);
}
};

Expand All @@ -58,7 +58,7 @@ export default class SourcesAdminStore {
this.setSource(created);
});
} catch (e: unknown) {
console.log(e);
console.error(e);
}
};

Expand All @@ -69,7 +69,7 @@ export default class SourcesAdminStore {
try {
await sourcesApi.update(sourceItem);
} catch (e: unknown) {
console.log(e);
console.error(e);
}
};
}
22 changes: 15 additions & 7 deletions src/app/stores/sources-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,29 @@ export default class SourcesStore {
try {
this.setInternalCategoriesMap(await sourcesApi.getCategoriesByStreetcodeId(streetcodeId));
this.srcCategoriesMap.forEach(async (value, key) => {
const content = await sourcesApi.getCategoryContentByStreetcodeId(streetcodeId,key);
const content = await sourcesApi.getCategoryContentByStreetcodeId(streetcodeId, key);
this.srcCategoriesContentMap.set(key, content);
})
} catch (error: unknown) { }
});
} catch (error: unknown) {
console.error(error);
}
};

public fetchSrcCategoriesAll = async () => {
try {
this.setInternalCategoriesMap(await sourcesApi.getAllCategories());
} catch (error: unknown) {
console.log(error);
console.error(error);
}
};

public createSourceCategory = async (srcCategory: SourceCategory) => {
try {
await sourcesApi.create(srcCategory);
this.setCategoryItem(srcCategory);
} catch (error: unknown) { }
} catch (error: unknown) {
console.error(error);
}
};

public updateSourceCategory = async (srcCategory: SourceCategory) => {
Expand All @@ -58,7 +62,9 @@ export default class SourcesStore {
};
this.setCategoryItem(updatedSourceCategory as SourceCategory);
});
} catch (error: unknown) { }
} catch (error: unknown) {
console.error(error);
}
};

public deleteSourceCategory = async (SourceCategoryId: number) => {
Expand All @@ -67,6 +73,8 @@ export default class SourcesStore {
runInAction(() => {
this.srcCategoriesMap.delete(SourceCategoryId);
});
} catch (error: unknown) { }
} catch (error: unknown) {
console.error(error);
}
};
}
8 changes: 4 additions & 4 deletions src/app/stores/team-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,23 @@ export default class TeamStore {
try {
this.setInternalMap(await teamApi.getAll());
} catch (error: unknown) {
console.log(error);
console.error(error);
}
};

public getById = async (teamId: number) => {
try {
this.setItem(await teamApi.getById(teamId));
} catch (error: unknown) {
console.log(error);
console.error(error);
}
};

public fetchTeamAll = async () => {
try {
this.setInternalMap(await teamApi.getAll());
} catch (error: unknown) {
console.log(error);
console.error(error);
}
};

Expand All @@ -76,7 +76,7 @@ export default class TeamStore {
this.TeamMap.delete(teamId);
});
} catch (error: unknown) {
console.log(error);
console.error(error);
}
};
}
1 change: 0 additions & 1 deletion src/features/AboutUsPage/AboutUsPage.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const AboutUsPage = () => {
const [hasVacancies, setHasVacancies] = useState(false);
const location = useLocation();
const section = location.hash.substring(1);
console.log('section:', section);

useEffect(() => {
const scrollToSection = (sectionName: string) => {
Expand Down
2 changes: 1 addition & 1 deletion src/features/AboutUsPage/Vacancies/Vacancies.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const Vacancies = ({ setHasVacancies } : { setHasVacancies: (hasVacancies: boole
)
.catch(
(e) => {
console.log(e);
console.error(e);
},
);
}, []);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const PartnersBlock = ({ onlyKeyPartners}: Props) => {
setKeyPartners(res);
})
.catch((error) => {
console.error("Error fetching key partners:", error);
console.error('Error fetching key partners:', error);
});

if (!onlyKeyPartners) {
Expand All @@ -31,7 +31,7 @@ const PartnersBlock = ({ onlyKeyPartners}: Props) => {
setOtherPartners(result);
})
.catch((error) => {
console.error("Error fetching other partners:", error);
console.error('Error fetching other partners:', error);
});
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/features/AdminPage/Analytics/Analytics.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const Analytics = () => {
await ImagesApi.getByStreetcodeId(streetcodeId ?? 1).then((imgs) => {
setImage(imgs.find((image) => image.imageDetails?.alt === ImageAssigment.blackandwhite.toString()));
}).catch((e) => {
console.log(e);
console.error(e);
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const CategoriesMainPage: React.FC = observer(() => {
sourcesStore.srcCategoriesMap.delete(srcCategory.id);
}
}).catch((e) => {
console.log(e);
console.error(e);
});
modalStore.setConfirmationModal('confirmation');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const ContextMainPage: React.FC = observer(() => {
if (context.id !== undefined) {
contextStore.deleteContext(context.id)
.catch((e) => {
console.log(e);
console.error(e);
});
modalStore.setConfirmationModal('confirmation');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const JobsModal = ({ open, setOpen, currentId }: Props) => {
salary: currentJob.salary,
});
} catch (error) {
console.log(error);
console.error(error);
}
} else if (currentId === 0) {
setStoredJob(emptyJob);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const JobsTable = () => {
)
.catch(
(e) => {
console.log(e);
console.error(e);
},
);
modalStore.setConfirmationModal('confirmation');
Expand Down Expand Up @@ -67,13 +67,13 @@ const JobsTable = () => {

modalStore.setConfirmationModal('confirmation');
} catch (e) {
console.log(e);
console.error(e);
}
},
'Ви впевнені, що хочете змінити статус вакансії?',
);
} catch (error) {
console.error('Error occurred:', error);
console.error(error);
}
};

Expand Down Expand Up @@ -137,7 +137,7 @@ const JobsTable = () => {
setMappedJobsShort(response);
})
.catch((error) => {
console.log(error);
console.error(error);
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,6 @@ const NewStreetcode = () => {
? { when: false, message: '' }
: { when: true, message: navigationString }
);
const handleTabClosing = () => {
console.log('Close tab');
};

const alertUser = (event: BeforeUnloadEvent) => {
event.preventDefault();
Expand Down Expand Up @@ -187,10 +184,8 @@ const NewStreetcode = () => {
useEffect(() => {
if (!savedChanges) {
window.addEventListener('beforeunload', alertUser);
window.addEventListener('unload', handleTabClosing);
return () => {
window.removeEventListener('beforeunload', alertUser);
window.removeEventListener('unload', handleTabClosing);
};
}
});
Expand Down Expand Up @@ -284,7 +279,9 @@ const NewStreetcode = () => {
setSubTitle(resultSubtitle);
}
})
.catch((error) => {});
.catch((error) => {
console.error(error);
});
SourcesApi.getCategoriesByStreetcodeId(parseId).then(
(result) => {
const id = result.map((x) => x.id);
Expand Down Expand Up @@ -606,11 +603,11 @@ const NewStreetcode = () => {
.then(() => {
alert('Cтріткод успішно оновлений');
})
.catch((error2) => {
.catch((error) => {
alert('Виникла помилка при оновленні стріткоду');
console.error(error);
});
} else {
console.log(streetcode);
StreetcodesApi.create(streetcode)
.then(() => {
streetcodeArtSlideStore.streetcodeArtSlides = [];
Expand All @@ -635,17 +632,19 @@ const NewStreetcode = () => {
})
.catch((error) => {
alert('Виникла помилка при створенні стріткоду');
console.error(error);
});
}
})
.catch(() => {
.catch((error) => {
const name = form
.getFieldsError()
.find((e) => e.errors.length > 0)?.name;
if (name) {
scrollToErrors();
} else {
alert('Будь ласка, заповніть всі поля валідними даними');
console.error(error);
}
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const MapOSMAdmin = () => {
if (results && status === 'OK') {
setAddress(results[0].formatted_address);
} else {
console.error(`Geocode was not successful for the following reason: ${status}`);
console.error('Geocode was not successful for the following reason:', status);
}
},
);
Expand Down Expand Up @@ -161,7 +161,7 @@ const MapOSMAdmin = () => {
if (results && status === 'OK') {
setAddress(results[0].formatted_address);
} else {
console.error(`Geocode was not successful for the following reason: ${status}`);
console.error('Geocode was not successful for the following reason:', status);
}
},
);
Expand Down
Loading