Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

add: auto focus to rating input #126

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
1 change: 1 addition & 0 deletions src/app/rate/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export default function Form({ name = "", owner = "" }) {
value={owner && name && `https://github.com/${owner}/${name}`}
placeholder="URL"
className="block w-full rounded-md border-0 bg-white/5 py-1.5 text-white shadow-sm ring-1 ring-inset ring-white/10 focus:ring-2 focus:ring-inset focus:ring-indigo-500 sm:text-sm sm:leading-6"
autoFocus
required
/>
</div>
Comment on lines 83 to 89
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [13-35]

The save function encapsulates the logic for form submission, including session validation, JWT creation, and the POST request to the /api/rate endpoint. It's crucial to handle errors gracefully, as done here with the catch block that redirects users to an error page if the session is invalid. However, consider adding more detailed error handling for the fetch request itself, such as checking for HTTP status codes that indicate failure (e.g., 4xx, 5xx responses) before assuming data.success or data.error.

if (!res.ok) {
  setSending(false);
  alert("Failed to save rating. Please try again.");
  return;
}

Expand Down
Loading