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

feat: add name missing error in new brain modal #1055

Merged
merged 2 commits into from
Aug 30, 2023

Conversation

mamadoudicko
Copy link
Contributor

Description

Screenshot 2023-08-29 at 15 59 22

@mamadoudicko mamadoudicko temporarily deployed to preview August 29, 2023 13:59 — with GitHub Actions Inactive
@vercel
Copy link

vercel bot commented Aug 29, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 30, 2023 7:53am
quivrapp ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 30, 2023 7:53am

@github-actions
Copy link
Contributor

github-actions bot commented Aug 29, 2023

Risk Level 2 - /home/runner/work/quivr/quivr/frontend/lib/components/AddBrainModal/hooks/useAddBrainModal.ts

The code changes in this file are generally good, but there are a few areas that could be improved for better readability and maintainability.

  1. Error handling: The error handling in the handleSubmit function could be improved. Currently, the error message is directly converted to a string and displayed to the user. This could potentially expose sensitive information. It would be better to have a predefined error message for known errors and a generic error message for unknown errors.
if (axios.isAxiosError(err) && err.response?.status === 429) {
  publish({
    variant: \"danger\",
    text: t(\"errorRateLimitExceeded\", { ns: \"config\" }),
  });
} else {
  publish({
    variant: \"danger\",
    text: t(\"errorUnknown\", { ns: \"config\" }),
  });
}
  1. Use of trim function: The trim function is used multiple times in the code. It would be better to create a helper function that trims the input and checks if it's empty. This would make the code cleaner and more maintainable.
const isNotEmpty = (input: string) => input.trim() !== \"\";

if (isNotEmpty(name) || isPending) {
  // ...
}
  1. Use of useState: The useState hook is used multiple times in the code. It would be better to use the useReducer hook instead when dealing with complex state logic that involves multiple sub-values or when the next state depends on the previous one. This would make the code more predictable and easier to test.

🔒💡🔄


Powered by Code Review GPT

@gozineb gozineb merged commit 5612c2b into main Aug 30, 2023
StanGirard pushed a commit that referenced this pull request Sep 12, 2023
* feat: update toast z index

* feat(brain modal): add name missing message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants