Skip to content

Commit 071a0ed

Browse files
authored
Ft- updating and cancel appointment (#131)
**#### What does this pr do ?** This practice is about when a patient want to update or cancel his or her appointment ### Required in this pr 1. First, login to your account and update your account in order to be patient 2. Book any appointment if you have not already booked ### How to view this pr After logging in, go to your appointment. You will see your appointment booked; if not, go to the doctor to view her or his appointment and book an appointment. so in the appointment, you see button fro cancel and reschedule appointments, and then start to cancel or reschedule according to your choice ### How to test this 1. If you finish canceling an appointment, you see it removed in upcoming and it is going to cancelled 2. If you finish to reschedule appointment you will see the date and time can be changed on appointment found in upcoming
2 parents 128acff + 37af9c6 commit 071a0ed

File tree

6 files changed

+550
-440
lines changed

6 files changed

+550
-440
lines changed
Lines changed: 48 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
21
import React, { useState } from 'react';
3-
import { View, Text, TouchableOpacity, StyleSheet,Image } from 'react-native';
2+
import { View, Text, TouchableOpacity, StyleSheet, Image } from 'react-native';
43
import { format, addMonths, subMonths, startOfMonth, endOfMonth, startOfWeek, endOfWeek, eachDayOfInterval, isSameDay } from 'date-fns';
54
import { useFonts } from 'expo-font';
65

7-
const CalendarScreen: React.FC = () => {
6+
const CalendarScreen: React.FC<{ onDateChange: (date: string) => void }> = ({ onDateChange }) => {
87
const [currentDate, setCurrentDate] = useState(new Date());
98
const [selectedDate, setSelectedDate] = useState<Date | null>(new Date());
109

11-
const [fontLoaded]=useFonts({
12-
'UrbanistBold':require('../../../assets/fonts/Urbanist-Bold.ttf'),
13-
'UrbanistMedium':require("../../../assets/fonts/Urbanist-Medium.ttf"),
14-
'Urbanist-SemiBold':require("../../../assets/fonts/Urbanist-SemiBold.ttf")
15-
})
10+
const [fontLoaded] = useFonts({
11+
'UrbanistBold': require('../../../assets/fonts/Urbanist-Bold.ttf'),
12+
'UrbanistMedium': require("../../../assets/fonts/Urbanist-Medium.ttf"),
13+
'Urbanist-SemiBold': require("../../../assets/fonts/Urbanist-SemiBold.ttf")
14+
});
1615

1716
const handlePrevMonth = () => {
1817
setCurrentDate(prevDate => subMonths(prevDate, 1));
@@ -23,24 +22,25 @@ const CalendarScreen: React.FC = () => {
2322
};
2423

2524
const handleDayPress = (day: Date) => {
26-
setSelectedDate(prevSelectedDate =>
27-
isSameDay(prevSelectedDate || new Date(), day) ? null : day
28-
);
25+
const newSelectedDate = isSameDay(selectedDate || new Date(), day) ? null : day;
26+
setSelectedDate(newSelectedDate);
27+
if (newSelectedDate) {
28+
onDateChange(format(newSelectedDate, 'yyyy-MM-dd'));
29+
}
2930
};
30-
3131

3232
const renderHeader = () => {
3333
return (
3434
<View style={styles.header}>
3535
<Text style={styles.headerText}>{format(currentDate, 'MMMM yyyy')}</Text>
36-
<View className='flex flex-row gap-1'>
37-
<TouchableOpacity onPress={handlePrevMonth}>
38-
<Image source={require("../../../assets/appointmentIcon/Arcl1.png")}/>
39-
</TouchableOpacity>
40-
<TouchableOpacity onPress={handleNextMonth}>
41-
<Image source={require("../../../assets/appointmentIcon/Arcal.png")}/>
42-
</TouchableOpacity>
43-
</View>
36+
<View className='flex flex-row gap-1'>
37+
<TouchableOpacity onPress={handlePrevMonth}>
38+
<Image source={require("../../../assets/appointmentIcon/Arcl1.png")} />
39+
</TouchableOpacity>
40+
<TouchableOpacity onPress={handleNextMonth}>
41+
<Image source={require("../../../assets/appointmentIcon/Arcal.png")} />
42+
</TouchableOpacity>
43+
</View>
4444
</View>
4545
);
4646
};
@@ -50,7 +50,7 @@ const CalendarScreen: React.FC = () => {
5050
return (
5151
<View style={styles.daysOfWeek}>
5252
{daysOfWeek.map(day => (
53-
<Text key={day} className='font-UrbanistBold' style={styles.dayOfWeekText}>{day}</Text>
53+
<Text key={day} style={styles.dayOfWeekText}>{day}</Text>
5454
))}
5555
</View>
5656
);
@@ -69,10 +69,10 @@ const CalendarScreen: React.FC = () => {
6969
onPress={() => handleDayPress(day)}
7070
style={[
7171
styles.dayButton,
72-
isSameDay(selectedDate || new Date(), day) && styles.selectedDayButton,
72+
selectedDate && isSameDay(selectedDate, day) && styles.selectedDayButton,
7373
]}
7474
>
75-
<Text style={[styles.dayText, isSameDay(selectedDate || new Date(), day) && styles.selectedDayText]}>
75+
<Text style={[styles.dayText, selectedDate && isSameDay(selectedDate, day) && styles.selectedDayText]}>
7676
{format(day, 'd')}
7777
</Text>
7878
</TouchableOpacity>
@@ -81,9 +81,10 @@ const CalendarScreen: React.FC = () => {
8181
);
8282
};
8383

84-
if(!fontLoaded){
85-
return null
86-
}
84+
if (!fontLoaded) {
85+
return null;
86+
}
87+
8788
return (
8889
<View style={styles.container}>
8990
{renderHeader()}
@@ -96,33 +97,33 @@ const CalendarScreen: React.FC = () => {
9697
const styles = StyleSheet.create({
9798
container: {
9899
padding: 20,
99-
backgroundColor:'#d3dae7',
100-
borderRadius:20,
101-
display:'flex',
102-
justifyContent:'center',
103-
alignItems:'center'
100+
backgroundColor: '#d3dae7',
101+
borderRadius: 20,
102+
display: 'flex',
103+
justifyContent: 'center',
104+
alignItems: 'center'
104105
},
105106
header: {
106107
flexDirection: 'row',
107108
justifyContent: 'space-between',
108109
alignItems: 'center',
109-
marginBottom:5,
110-
width:315
110+
marginBottom: 5,
111+
width: 315
111112
},
112-
navButton: {
113-
fontSize: 16,
114-
fontWeight: 'bold',
113+
navButtons: {
114+
flexDirection: 'row',
115+
gap: 1,
115116
},
116117
headerText: {
117118
fontSize: 18,
118-
fontFamily:'UrbanistBold'
119+
fontFamily: 'UrbanistBold'
119120
},
120121
daysOfWeek: {
121122
flexDirection: 'row',
122123
flexWrap: 'wrap',
123-
marginTop:10,
124-
gap:16,
125-
marginBottom:10
124+
marginTop: 10,
125+
gap: 16,
126+
marginBottom: 10
126127
},
127128
dayOfWeekText: {
128129
width: 32,
@@ -131,8 +132,8 @@ const styles = StyleSheet.create({
131132
days: {
132133
flexDirection: 'row',
133134
flexWrap: 'wrap',
134-
gap:16,
135-
paddingLeft:5
135+
gap: 16,
136+
paddingLeft: 5
136137
},
137138
dayButton: {
138139
width: 32,
@@ -143,21 +144,19 @@ const styles = StyleSheet.create({
143144
},
144145
selectedDayButton: {
145146
backgroundColor: '#246bfd',
146-
display:'flex',
147-
justifyContent:'center',
148-
alignItems:'center'
147+
display: 'flex',
148+
justifyContent: 'center',
149+
alignItems: 'center'
149150
},
150151
dayText: {
151152
width: 60,
152153
textAlign: 'center',
153-
fontFamily:'UrbanistMedium',
154-
color:'#424242'
154+
fontFamily: 'UrbanistMedium',
155+
color: '#424242'
155156
},
156157
selectedDayText: {
157158
color: 'white',
158159
},
159160
});
160161

161162
export default CalendarScreen;
162-
163-

app/Appointments/doctorcard/cardss.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ function Cardscomponent(props: any) {
99
});
1010
}
1111
};
12-
12+
13+
1314
return (
1415
<View
1516
style={props.bacColor}

0 commit comments

Comments
 (0)