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

Project/[id] dashboard page #9

Merged
merged 8 commits into from
Feb 25, 2025
Merged

Project/[id] dashboard page #9

merged 8 commits into from
Feb 25, 2025

Conversation

yolanda-y-li
Copy link
Contributor

@yolanda-y-li yolanda-y-li commented Feb 15, 2025

Closes #5

Displays project name at the top of the screen:

Screenshot 2025-02-15 at 6 40 21 PM

Form for linking user with ID or email:

image

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Disclaimer: This comment was AI-generated and is not necessarily completely accurate. Please take code comments with a grain of salt.

PR Summary

This PR introduces a project dashboard page with user linking functionality, implementing form validation and server-side actions using the Juno SDK.

  • Project name display in /src/app/(dashboard)/projects/[projectId]/page.tsx lacks loading state management and proper TypeScript typing for projectName state
  • Server actions in /src/lib/sdkActions.ts could benefit from more detailed error messages and stricter type validation
  • Form error handling in page.tsx uses basic alerts - should implement proper error UI components
  • Form submission lacks loading state and disable controls during submission
  • Mobile responsiveness needs improvement in the form layout

Score: 75/100

Areas needing attention:
Frontend:

  • Page is responsive for mobile
  • Uses appropriate hooks only when necessary
  • Handles error responses from API calls to backend

Backend:

  • Uses try/catch blocks for error handling
  • Input is appropriately validated
  • Handles edge cases where necessary

💡 (1/5) You can manually trigger the bot by mentioning @greptileai in a comment!

5 file(s) reviewed, 7 comment(s)
Edit PR Review Bot Settings | Greptile

return <></>;
const { projectId } = useParams();

const [projectName, setProjectName] = useState(null);
Copy link

Choose a reason for hiding this comment

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

style: useState(null) should be typed as useState<string | null>(null) for better type safety

Suggested change
const [projectName, setProjectName] = useState(null);
const [projectName, setProjectName] = useState<string | null>(null);

Comment on lines +37 to +38
alert("Failed to get project name");
}
Copy link

Choose a reason for hiding this comment

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

style: alert() is not ideal for error handling in production. Consider using a toast notification or error state in the UI

Comment on lines +29 to +45
useEffect(() => {
const displayProjectName = async () => {
try {
const res = await getJunoProject({ id: Number(projectId) });
if (res.success) {
const name = res.projectName;
setProjectName(name);
} else {
alert("Failed to get project name");
}
} catch (e) {
console.error("Error getting project:", e);
}
};

displayProjectName();
}, [projectId]);
Copy link

Choose a reason for hiding this comment

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

style: missing loading state management during API call

Comment on lines +30 to +32
} catch (e) {
return { success: false, error: `Error getting project: ${e}` };
}
Copy link

Choose a reason for hiding this comment

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

style: error object 'e' is implicitly typed as 'any'. Consider typing the error parameter or using 'unknown' for better type safety

Suggested change
} catch (e) {
return { success: false, error: `Error getting project: ${e}` };
}
} catch (e: unknown) {
return { success: false, error: `Error getting project: ${e}` };
}

Comment on lines +41 to +42
await juno.project.linkProjectToUser(options);
return { success: true };
Copy link

Choose a reason for hiding this comment

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

style: no error information is returned from successful linkProjectToUser operation. Consider returning the linked project/user IDs for confirmation

Comment on lines 27 to 29
const FormFieldContext = React.createContext<FormFieldContextValue>(
{} as FormFieldContextValue
)
Copy link

Choose a reason for hiding this comment

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

logic: Initializing context with empty object cast to type could cause runtime errors if accessed before provider is mounted

Comment on lines 51 to 53
if (!fieldContext) {
throw new Error("useFormField should be used within <FormField>")
}
Copy link

Choose a reason for hiding this comment

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

logic: This error check comes after using fieldContext, which could cause undefined access

Suggested change
if (!fieldContext) {
throw new Error("useFormField should be used within <FormField>")
}
const fieldContext = React.useContext(FormFieldContext)
const itemContext = React.useContext(FormItemContext)
if (!fieldContext) {
throw new Error("useFormField should be used within <FormField>")
}
const { getFieldState, formState } = useFormContext()
const fieldState = getFieldState(fieldContext.name, formState)
const { id } = itemContext

@UZ9 UZ9 merged commit e5ec5ab into main Feb 25, 2025
1 check passed
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.

Juno Dashboard Project Registration
2 participants