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

Welcome page and select date to view appointment #53

Merged
merged 21 commits into from
Oct 29, 2024
Merged

Welcome page and select date to view appointment #53

merged 21 commits into from
Oct 29, 2024

Conversation

pemba1s1
Copy link
Collaborator

@pemba1s1 pemba1s1 commented Oct 29, 2024

Issue: #45 #47

Screenshot

image
image
image
image

Summary by Sourcery

Add a welcome screen to guide users through the app's features and implement date selection for viewing appointments. Enhance the user interface with improved styling and update the README for better clarity on project setup.

New Features:

  • Introduce a welcome screen to provide an overview of the app's features and guide users through the initial setup.

Enhancements:

  • Add functionality to select and view appointments by date, allowing users to navigate through different days.
  • Improve the user interface with updated styles for headers, buttons, and date selectors.

Documentation:

  • Update the README to clarify the steps for starting the project and handling native code changes.

Copy link

sourcery-ai bot commented Oct 29, 2024

Reviewer's Guide by Sourcery

This PR implements a welcome page and adds date selection functionality for viewing appointments. The changes include a new welcome screen component, enhanced appointment list with date navigation, improved UI styling, and simplified local authentication checks. The implementation focuses on improving user experience with better navigation and clearer UI elements.

Updated class diagram for AppointmentList component

classDiagram
    class AppointmentList {
        - manager
        - appointments
        - loading
        - date
        - selectDate
        + fetchAppointments()
        + changeDate(days: number)
        + onNextDate()
        + onPrevDate()
    }
    note for AppointmentList "Added date and selectDate state variables and methods for date navigation"
Loading

Class diagram for new WelcomeScreen component

classDiagram
    class WelcomeScreen {
        + onNext: () => void
    }
    note for WelcomeScreen "New component for displaying welcome message and app features"
Loading

File-Level Changes

Change Details Files
Added welcome screen with app introduction and features overview
  • Created new welcome screen component with app description and feature list
  • Implemented navigation flow from welcome screen to terms and conditions
  • Added styling for welcome screen UI elements
app/welcome.tsx
app/index.tsx
Enhanced appointment list with date selection and navigation
  • Added date selector with previous/next day navigation
  • Implemented date picker for selecting specific dates
  • Updated appointment fetching to use selected date
  • Added 'Today' shortcut button
  • Improved UI styling for header and refresh button
components/AppointmentList.tsx
Simplified local authentication and improved UI elements
  • Simplified device authentication check using security level
  • Updated refresh button styling across components
  • Added URL format guidelines in settings
  • Updated home info with new date selection instructions
utils/localAuth.ts
app/(tabs)/setting.tsx
components/info/homeInfo.tsx
app/patient-detail/[id]/appointment.tsx
Updated build and navigation configurations
  • Simplified Android build instructions
  • Added prebuild command documentation
  • Updated stack navigation options
  • Added base URL validation check before login
README.md
app/_layout.tsx
app/(tabs)/home.tsx

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@pemba1s1 pemba1s1 requested a review from yingbull October 29, 2024 15:07
Copy link

sweep-ai bot commented Oct 29, 2024

Hey @pemba1s1, here is an example of how you can ask me to improve this pull request:

@Sweep Add unit tests for the `navigateDate` function in `AppointmentList.tsx` to verify it correctly increments and decrements dates when given different DateDirection values.

📖 For more information on how to use Sweep, please read our documentation.

Copy link

socket-security bot commented Oct 29, 2024

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@react-native-community/datetimepicker@8.0.1 None +1 227 kB vonovak

View full report↗︎

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @pemba1s1 - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

setLoading(false);
} else {
// Handle unauthorized access
if (res?.code == 401) {
Copy link

Choose a reason for hiding this comment

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

suggestion: Consider handling other error cases explicitly rather than silently failing

Add error handling for other status codes and consider showing an error message to the user when the request fails

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

errors are handled somewhere else. This is only checking if token has expired.

* Changes the current date by a specified number of days.
* @param days - The number of days to change the date by.
*/
const changeDate = (days: number) => {
Copy link

Choose a reason for hiding this comment

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

issue (complexity): Consider consolidating date navigation logic into a single handler with an enum-based approach.

The date selection logic can be simplified while maintaining functionality:

  1. Replace the three date navigation functions with a single handler using a direction enum:
enum DateDirection {
  PREV = -1,
  NEXT = 1
}

const navigateDate = (direction: DateDirection) => {
  setDate(prevDate => {
    const newDate = new Date(prevDate);
    newDate.setDate(prevDate.getDate() + direction);
    return newDate;
  });
};
  1. Simplify the date picker integration by handling it directly in the component:
<View style={styles.dateSelector}>
  <TouchableOpacity onPress={() => navigateDate(DateDirection.PREV)}>
    <Ionicons name="chevron-back-outline" size={20} color="black" />
  </TouchableOpacity>
  <RNDateTimePicker
    value={date}
    onChange={(event, selectedDate) => {
      if (event.type === 'set' && selectedDate) {
        setDate(selectedDate);
      }
    }}
    mode="date"
  />
  <TouchableOpacity onPress={() => navigateDate(DateDirection.NEXT)}>
    <Ionicons name="chevron-forward-outline" size={20} color="black" />
  </TouchableOpacity>
</View>

This approach:

  • Reduces state by removing selectDate
  • Consolidates date navigation logic
  • Simplifies the date picker integration
  • Maintains the same functionality with less code

Comment on lines 51 to 63
if (res.status === StatusType.SUCCESS) {
// Split appointments into past and upcoming
const { pastAppointments, upcomingAppointments } = splitAppointments(
res.data
);
setAppointments(upcomingAppointments.concat(pastAppointments));
setLoading(false);
} else {
// Handle unauthorized access
if (res?.code == 401) {
setHasAccessToken(false);
}
}
Copy link

Choose a reason for hiding this comment

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

suggestion (code-quality): Merge else clause's nested if statement into else if (merge-else-if)

Suggested change
if (res.status === StatusType.SUCCESS) {
// Split appointments into past and upcoming
const { pastAppointments, upcomingAppointments } = splitAppointments(
res.data
);
setAppointments(upcomingAppointments.concat(pastAppointments));
setLoading(false);
} else {
// Handle unauthorized access
if (res?.code == 401) {
setHasAccessToken(false);
}
}
if (res.status === StatusType.SUCCESS) {
// Split appointments into past and upcoming
const { pastAppointments, upcomingAppointments } = splitAppointments(
res.data
);
setAppointments(upcomingAppointments.concat(pastAppointments));
setLoading(false);
}
else if (res?.code == 401) {
setHasAccessToken(false);
}


ExplanationFlattening if statements nested within else clauses generates code that is
easier to read and expand upon.

@yingbull yingbull merged commit 9b951af into main Oct 29, 2024
2 checks 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.

2 participants