Conversation
baseurl to be changed
Summary of ChangesHello @vvshk, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a new feature to collect feedback for Utsav events, enhancing the application's ability to gather user insights. It provides a dedicated, user-friendly form for participants to rate their experience across multiple categories and offer suggestions. The feedback mechanism is seamlessly integrated into the existing event booking flow, making it accessible at the appropriate time. Additionally, minor technical updates were made to dependencies and development environment configurations. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a feedback form for "Utsavs". The implementation includes a new screen for the form, integration with the existing booking list to show a "Give Feedback" button, and necessary routing changes. The code is generally well-structured, but there are a few critical and high-severity issues that must be addressed. A hardcoded local development URL has been introduced, which will break API calls in production. There's also a console.log statement that should be removed, and a potential bug in promise handling that could cause the app to hang. I've also included some suggestions to improve maintainability and prevent potential race conditions.
src/utils/HandleApiCall.js
Outdated
| if (useDevBackend) { | ||
| if (devPrNumber) { | ||
| currentBaseUrl = `https://aashray-backend-pr-${devPrNumber}.onrender.com/api/v1`; | ||
| currentBaseUrl = `http://10.0.2.2:3000/api/v1`; |
There was a problem hiding this comment.
This change hardcodes the base URL to a local development address (10.0.2.2). This is a critical issue as it will break all API calls for production builds and other developers. This line should be reverted to use the production or PR-specific Render URL.
| currentBaseUrl = `http://10.0.2.2:3000/api/v1`; | |
| currentBaseUrl = `https://aashray-backend-pr-${devPrNumber}.onrender.com/api/v1`; |
| const validateFeedbackAccess = async () => { | ||
| setIsValidating(true); | ||
| await new Promise((resolve, reject) => { | ||
| handleAPICall( | ||
| 'GET', | ||
| '/utsav/feedback/validate', | ||
| { utsav_id: utsavId, cardno: user.cardno }, | ||
| null, | ||
| () => resolve(true), | ||
| () => { | ||
| setIsValidating(false); | ||
| } | ||
| // (err) => { | ||
| // setValidationError( | ||
| // err?.message || 'You are not authorized to submit feedback for this utsav' | ||
| // ); | ||
| // }, | ||
| // false | ||
| ); | ||
| }); | ||
| setValidationError(null); | ||
| }; |
There was a problem hiding this comment.
There's a potential hanging promise here. In the case of an API error, the Promise is never rejected because no errorCallback is provided to handleAPICall. This will cause the await to hang indefinitely, and the UI will be stuck. To fix this, you should provide an errorCallback that rejects the promise, and wrap the await in a try/catch/finally block to handle the error and loading states correctly.
const validateFeedbackAccess = async () => {
setIsValidating(true);
try {
await new Promise((resolve, reject) => {
handleAPICall(
'GET',
'/utsav/feedback/validate',
{ utsav_id: utsavId, cardno: user.cardno },
null,
(res) => resolve(res),
() => {},
(err) => reject(err)
);
});
setValidationError(null);
} catch (err: any) {
setValidationError(
err?.message || 'You are not authorized to submit feedback for this utsav'
);
} finally {
setIsValidating(false);
}
};
| (res: any) => { | ||
| resolve(Array.isArray(res.data) ? res.data : []); | ||
| }, | ||
| console.log('UTSAV BOOKINGS RESPONSE:', res.data); |
src/app/utsav/feedback/[id].tsx
Outdated
| const UtsavFeedbackForm: React.FC<{ | ||
| value: UtsavFeedbackData; | ||
| onChange: (data: UtsavFeedbackData) => void; | ||
| onSubmit: () => void; | ||
| isSubmitting?: boolean; | ||
| containerStyles?: string; | ||
| showValidation?: boolean; | ||
| }> = ({ | ||
| value, | ||
| onChange, | ||
| onSubmit, | ||
| isSubmitting = false, | ||
| containerStyles = '', | ||
| showValidation = false, | ||
| }) => { | ||
| const fieldError = (cond: boolean) => showValidation && cond; | ||
|
|
||
| return ( | ||
| <View className={`w-full ${containerStyles}`}> | ||
| <FieldLabel label="How would you rate the accommodation?" /> | ||
| <StarRating | ||
| value={value.accommodation_rating} | ||
| onChange={(n) => onChange({ ...value, accommodation_rating: n })} | ||
| /> | ||
| <ErrorText | ||
| show={fieldError(!value.accommodation_rating)} | ||
| message="Accommodation rating is required" | ||
| /> | ||
|
|
||
| <FieldLabel label="How convenient was the QR code system?" /> | ||
| <StarRating value={value.qr_rating} onChange={(n) => onChange({ ...value, qr_rating: n })} /> | ||
| <ErrorText show={fieldError(!value.qr_rating)} message="QR rating is required" /> | ||
|
|
||
| <FieldLabel label="How was the food quality & variety?" /> | ||
| <StarRating | ||
| value={value.food_rating} | ||
| onChange={(n) => onChange({ ...value, food_rating: n })} | ||
| /> | ||
| <ErrorText show={fieldError(!value.food_rating)} message="Food rating is required" /> | ||
|
|
||
| <FieldLabel label="How was the program structure & engagement?" /> | ||
| <StarRating | ||
| value={value.program_rating} | ||
| onChange={(n) => onChange({ ...value, program_rating: n })} | ||
| /> | ||
| <ErrorText show={fieldError(!value.program_rating)} message="Program rating is required" /> | ||
|
|
||
| <FieldLabel label="How would you rate the volunteer performance?" /> | ||
| <StarRating | ||
| value={value.volunteer_rating} | ||
| onChange={(n) => onChange({ ...value, volunteer_rating: n })} | ||
| /> | ||
| <ErrorText | ||
| show={fieldError(!value.volunteer_rating)} | ||
| message="Volunteer rating is required" | ||
| /> | ||
|
|
||
| <FieldLabel label="How was the infrastructure?" /> | ||
| <StarRating | ||
| value={value.infrastructure_rating} | ||
| onChange={(n) => onChange({ ...value, infrastructure_rating: n })} | ||
| /> | ||
| <ErrorText | ||
| show={fieldError(!value.infrastructure_rating)} | ||
| message="Infrastructure rating is required" | ||
| /> | ||
|
|
||
| <FieldLabel label="How was the decor?" /> | ||
| <StarRating | ||
| value={value.decor_rating} | ||
| onChange={(n) => onChange({ ...value, decor_rating: n })} | ||
| /> | ||
| <ErrorText show={fieldError(!value.decor_rating)} message="Decor rating is required" /> | ||
|
|
||
| <FieldLabel label="How was the internal transport coordination?" /> | ||
| <StarRating | ||
| value={value.internal_transport_rating} | ||
| onChange={(n) => onChange({ ...value, internal_transport_rating: n })} | ||
| /> | ||
| <ErrorText | ||
| show={fieldError(!value.internal_transport_rating)} | ||
| message="Internal transport rating is required" | ||
| /> | ||
|
|
||
| <FieldLabel label="How was the Raj Pravas transport (Mumbai → Venue)?" /> | ||
| <StarRating | ||
| value={value.raj_pravas_rating} | ||
| onChange={(n) => onChange({ ...value, raj_pravas_rating: n })} | ||
| /> | ||
| <ErrorText | ||
| show={fieldError(!value.raj_pravas_rating)} | ||
| message="Raj Pravas rating is required" | ||
| /> | ||
|
|
||
| <FieldLabel label="How was the Sparsh performance?" /> | ||
| <StarRating | ||
| value={value.sparsh_rating} | ||
| onChange={(n) => onChange({ ...value, sparsh_rating: n })} | ||
| /> | ||
| <ErrorText show={fieldError(!value.sparsh_rating)} message="Sparsh rating is required" /> | ||
|
|
||
| <FieldLabel label="How was the audio-visual setup?" /> | ||
| <StarRating value={value.av_rating} onChange={(n) => onChange({ ...value, av_rating: n })} /> | ||
| <ErrorText show={fieldError(!value.av_rating)} message="AV rating is required" /> | ||
|
|
||
| <FormField | ||
| text="What did you love the most about this Utsav?" | ||
| placeholder="What did you love the most?" | ||
| value={value.loved_most} | ||
| handleChangeText={(t: string) => onChange({ ...value, loved_most: t })} | ||
| otherStyles="mt-5" | ||
| inputStyles="font-pmedium text-base" | ||
| error={fieldError(!value.loved_most)} | ||
| errorMessage="Required" | ||
| useNeomorphic | ||
| /> | ||
|
|
||
| <FormField | ||
| text="Any suggestions for improvement?" | ||
| placeholder="What can be improved?" | ||
| value={value.improvement_suggestions} | ||
| handleChangeText={(t: string) => onChange({ ...value, improvement_suggestions: t })} | ||
| otherStyles="mt-5" | ||
| inputStyles="font-pmedium text-base" | ||
| error={fieldError(!value.improvement_suggestions)} | ||
| errorMessage="Required" | ||
| useNeomorphic | ||
| /> | ||
|
|
||
| <CustomButton | ||
| text="Submit Feedback" | ||
| handlePress={onSubmit} | ||
| containerStyles="my-7 min-h-[62px]" | ||
| bgcolor="bg-secondary" | ||
| textStyles="text-white" | ||
| isLoading={isSubmitting} | ||
| isDisabled={isSubmitting} | ||
| /> | ||
| </View> | ||
| ); |
There was a problem hiding this comment.
The UtsavFeedbackForm component has a lot of repetitive code for rendering each rating field. This makes the component large and harder to maintain. You can refactor this by creating an array of field configurations and mapping over it to render the fields dynamically. This will significantly reduce code duplication and make it easier to add or remove fields in the future.
src/app/utsav/feedback/[id].tsx
Outdated
| CustomAlert.alert('Thank you!', 'Your feedback has been submitted successfully.'); | ||
| router.back(); | ||
| setSubmitting(false); |
There was a problem hiding this comment.
Calling router.back() before setSubmitting(false) could lead to a React warning about setting state on an unmounted component if the navigation happens before the state update is processed. It's safer to update the component's state first, and then navigate away.
| CustomAlert.alert('Thank you!', 'Your feedback has been submitted successfully.'); | |
| router.back(); | |
| setSubmitting(false); | |
| setSubmitting(false); | |
| CustomAlert.alert('Thank you!', 'Your feedback has been submitted successfully.'); | |
| router.back(); |
…av and Adhyayan feedback forms to use it.
… handling, and update button and form field components.
No description provided.