-
Notifications
You must be signed in to change notification settings - Fork 1
Kaumadi #140
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
Conversation
WalkthroughThe changes introduce several new components and functionalities related to exam management within the application. A new Changes
Possibly related PRs
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🧹 Outside diff range and nitpick comments (7)
src/pages/examSetter/AdditionalFeatures.tsx (3)
22-22: Remove unused state variablesThe state variables
isLoadingandsetIsLoadingare declared but never used. Removing unused variables improves code readability and maintainability.Apply this diff to remove the unused state variables:
- const [isLoading, setIsLoading] = useState(false);🧰 Tools
🪛 eslint
[error] 22-22: 'isLoading' is assigned a value but never used.
(@typescript-eslint/no-unused-vars)
[error] 22-22: 'setIsLoading' is assigned a value but never used.
(@typescript-eslint/no-unused-vars)
35-35: Remove debuggingconsole.logstatementThe
console.logstatement on line 35 appears to be for debugging purposes and should be removed to clean up the code.Apply this diff to remove the
console.logstatement:- console.log(hostedResponse.data.hosted);
15-15: InitializeexamIdonce and reuse it throughoutCurrently,
examIdis retrieved and converted to a number multiple times. InitializeexamIdas a number when first retrieved and reuse it to avoid redundancy.Apply these diffs:
At line 15:
- const examId = sessionStorage.getItem("examId"); + const examId = Number(sessionStorage.getItem("examId"));At lines 25, 55, 77, 87, and 99, remove the redundant declarations:
- const examId = Number(sessionStorage.getItem("examId"));Also applies to: 25-25, 55-55, 77-77, 87-87, 99-99
src/pages/examSetter/ExamSetterDashbord.tsx (2)
11-11: Remove unused importgetModeratingExamsThe
getModeratingExamsfunction is imported but never used. Removing unused imports improves code cleanliness.Apply this diff:
- import { getModeratingExams } from '../../api/services/ExamSetter';🧰 Tools
🪛 eslint
[error] 11-11: 'getModeratingExams' is defined but never used.
(@typescript-eslint/no-unused-vars)
56-57: Remove unused state variablesThe state variables
proctoringExams,setProctoringExams,moderatingExams, andsetModeratingExamsare declared but never used. Removing unused variables cleans up the code.Apply this diff:
- const [proctoringExams, setProctoringExams] = useState<ExamResponse[]>([]); - const [moderatingExams, setModeratingExams] = useState<ModerateExamResponse[]>([]);🧰 Tools
🪛 eslint
[error] 56-56: 'proctoringExams' is assigned a value but never used.
(@typescript-eslint/no-unused-vars)
[error] 56-56: 'setProctoringExams' is assigned a value but never used.
(@typescript-eslint/no-unused-vars)
[error] 56-56: React Hook "useState" is called conditionally. React Hooks must be called in the exact same order in every component render. Did you accidentally call a React Hook after an early return?
(react-hooks/rules-of-hooks)
[error] 57-57: 'moderatingExams' is assigned a value but never used.
(@typescript-eslint/no-unused-vars)
[error] 57-57: 'setModeratingExams' is assigned a value but never used.
(@typescript-eslint/no-unused-vars)
[error] 57-57: React Hook "useState" is called conditionally. React Hooks must be called in the exact same order in every component render. Did you accidentally call a React Hook after an early return?
(react-hooks/rules-of-hooks)
src/pages/examSetter/MakeQuestions.tsx (2)
19-19: Remove commented-out codeThe commented-out code for
getOrganizationis no longer needed and can be removed to clean up the code.Apply this diff:
- //const { getOrganization } = useAuth();
Line range hint
68-68: Use the existingexamIdvariable instead of hardcoded valueThe
examIdis already retrieved fromsessionStorage. Using a hardcoded value may cause incorrect API requests. Use the existingexamIdvariable.Apply this diff:
- const examId = 'example-exam-id'; // This should be dynamically fetched or set + // Reuse the existing examId variable
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (5)
src/pages/examSetter/AddCandidate.tsx(1 hunks)src/pages/examSetter/AddProctors.tsx(1 hunks)src/pages/examSetter/AdditionalFeatures.tsx(1 hunks)src/pages/examSetter/ExamSetterDashbord.tsx(2 hunks)src/pages/examSetter/MakeQuestions.tsx(2 hunks)
🧰 Additional context used
🪛 eslint
src/pages/examSetter/AdditionalFeatures.tsx
[error] 22-22: 'isLoading' is assigned a value but never used.
(@typescript-eslint/no-unused-vars)
[error] 22-22: 'setIsLoading' is assigned a value but never used.
(@typescript-eslint/no-unused-vars)
src/pages/examSetter/ExamSetterDashbord.tsx
[error] 11-11: 'getModeratingExams' is defined but never used.
(@typescript-eslint/no-unused-vars)
[error] 55-55: React Hook "useState" is called conditionally. React Hooks must be called in the exact same order in every component render. Did you accidentally call a React Hook after an early return?
(react-hooks/rules-of-hooks)
[error] 56-56: 'proctoringExams' is assigned a value but never used.
(@typescript-eslint/no-unused-vars)
[error] 56-56: 'setProctoringExams' is assigned a value but never used.
(@typescript-eslint/no-unused-vars)
[error] 56-56: React Hook "useState" is called conditionally. React Hooks must be called in the exact same order in every component render. Did you accidentally call a React Hook after an early return?
(react-hooks/rules-of-hooks)
[error] 57-57: 'moderatingExams' is assigned a value but never used.
(@typescript-eslint/no-unused-vars)
[error] 57-57: 'setModeratingExams' is assigned a value but never used.
(@typescript-eslint/no-unused-vars)
[error] 57-57: React Hook "useState" is called conditionally. React Hooks must be called in the exact same order in every component render. Did you accidentally call a React Hook after an early return?
(react-hooks/rules-of-hooks)
[error] 79-79: React Hook "useEffect" is called conditionally. React Hooks must be called in the exact same order in every component render. Did you accidentally call a React Hook after an early return?
(react-hooks/rules-of-hooks)
🪛 Biome (1.9.4)
src/pages/examSetter/AddProctors.tsx
[error] 103-103: Missing key property for this element in iterable.
The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.
(lint/correctness/useJsxKeyInIterable)
src/pages/examSetter/AddCandidate.tsx
[error] 276-276: Missing key property for this element in iterable.
The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.
(lint/correctness/useJsxKeyInIterable)
|
|
||
| await setModerator(examId, moderatorEmail); | ||
| message.success('Moderator set successfully.'); | ||
| setCurrentModerator(moderatorEmail); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure consistent currentModerator value assignment
In fetchInitialValues, currentModerator is set to the moderator's full name, but in handleSetModerator, it's set to moderatorEmail. This inconsistency may cause confusion when displaying the current moderator.
Consider fetching the moderator's details after setting the moderator to obtain the full name.
Apply this diff to update the current moderator consistently:
try {
await setModerator(examId, moderatorEmail);
message.success('Moderator set successfully.');
- setCurrentModerator(moderatorEmail);
+ const moderatorResponse = await getModerator(examId);
+ if (moderatorResponse) {
+ setCurrentModerator(
+ `${moderatorResponse.data.firstName} ${moderatorResponse.data.lastName}`
+ );
+ }
} catch (error) {Committable suggestion skipped: line range outside the PR's diff.
| bordered | ||
| dataSource={selectedCandidates} | ||
| renderItem={(item) => ( | ||
| <List.Item actions={[<a onClick={() => removeCandidate(item.id)}>Remove</a>]}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add key prop to list items in renderItem
Each item in a list should have a unique key prop to help React identify which items have changed, are added, or are removed. This prevents potential rendering issues.
Apply this diff:
- <List.Item actions={[<a onClick={() => removeCandidate(item.id)}>Remove</a>]}>
+ <List.Item
+ key={item.id}
+ actions={[<a onClick={() => removeCandidate(item.id)}>Remove</a>]}>📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| <List.Item actions={[<a onClick={() => removeCandidate(item.id)}>Remove</a>]}> | |
| <List.Item | |
| key={item.id} | |
| actions={[<a onClick={() => removeCandidate(item.id)}>Remove</a>]}> |
🧰 Tools
🪛 Biome (1.9.4)
[error] 276-276: Missing key property for this element in iterable.
The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.
(lint/correctness/useJsxKeyInIterable)
| <List | ||
| dataSource={filteredProctors} | ||
| renderItem={(proctor: any) => ( | ||
| <List.Item |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add key prop to list items in renderItem
Each item in a list should have a unique key prop to help React identify which items have changed, are added, or are removed. This prevents potential rendering issues.
Apply this diff:
- <List.Item
- actions={[
+ <List.Item
+ key={proctor.email}
+ actions={[Committable suggestion skipped: line range outside the PR's diff.
|
|
||
| const organizationId = Number(sessionStorage.getItem('orgId')); | ||
| const [examsData, setExams] = useState<ExamResponse[]>([]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid conditional React Hooks
React Hooks must be called unconditionally and in the same order on every render. The early return before the hooks causes conditional hook calls, which can lead to runtime errors.
Refactor the code to ensure that all hooks are called before any returns. Place the early return after the hooks.
Apply this diff:
export const ExamSetterDashBoardPage = () => {
const loggedInUser = getLoggedInUser();
+ const organizationId = Number(sessionStorage.getItem('orgId'));
+ const [examsData, setExams] = useState<ExamResponse[]>([]);
+ const [proctoringExams, setProctoringExams] = useState<ExamResponse[]>([]);
+ const [moderatingExams, setModeratingExams] = useState<ModerateExamResponse[]>([]);
if (!loggedInUser) {
message.error('You must be logged in to perform this action.');
return null;
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const organizationId = Number(sessionStorage.getItem('orgId')); | |
| const [examsData, setExams] = useState<ExamResponse[]>([]); | |
| export const ExamSetterDashBoardPage = () => { | |
| const loggedInUser = getLoggedInUser(); | |
| const organizationId = Number(sessionStorage.getItem('orgId')); | |
| const [examsData, setExams] = useState<ExamResponse[]>([]); | |
| const [proctoringExams, setProctoringExams] = useState<ExamResponse[]>([]); | |
| const [moderatingExams, setModeratingExams] = useState<ModerateExamResponse[]>([]); | |
| if (!loggedInUser) { | |
| message.error('You must be logged in to perform this action.'); | |
| return null; | |
| } |
🧰 Tools
🪛 eslint
[error] 55-55: React Hook "useState" is called conditionally. React Hooks must be called in the exact same order in every component render. Did you accidentally call a React Hook after an early return?
(react-hooks/rules-of-hooks)
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
MakeQuestionscomponent.