Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
pill_minder
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Phuengton Chummuel
pill_minder
Commits
7ad61941
Commit
7ad61941
authored
Mar 21, 2018
by
Phuengton Chummuel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor code to use redux
parent
cbd2029f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
52 deletions
+24
-52
AppointmentListScreen.js
src/screens/AppointmentListScreen.js
+5
-2
AppointmentsScreen.js
src/screens/AppointmentsScreen.js
+19
-50
No files found.
src/screens/AppointmentListScreen.js
View file @
7ad61941
...
@@ -13,9 +13,11 @@ import {
...
@@ -13,9 +13,11 @@ import {
Left
,
Left
,
}
from
'native-base'
;
}
from
'native-base'
;
import
AppHeader
from
'./../components/Header'
;
import
AppHeader
from
'./../components/Header'
;
import
appointmentList
from
'./../components/AppointmentList'
import
realm
from
'./../Database/'
;
import
realm
from
'./../Database/'
;
import
moment
from
'moment'
;
import
moment
from
'moment'
;
import
{
cancleNotification
}
from
'./../Utils'
;
import
{
cancleNotification
}
from
'./../Utils'
;
import
AppointmentList
from
'./../components/AppointmentList'
;
class
AppointmentListScreen
extends
Component
{
class
AppointmentListScreen
extends
Component
{
...
@@ -51,7 +53,8 @@ class AppointmentListScreen extends Component {
...
@@ -51,7 +53,8 @@ class AppointmentListScreen extends Component {
}
}
/
>
/
>
<
Content
>
<
Content
>
<
View
style
=
{{
flex
:
1
,
backgroundColor
:
'white'
,
height
:
60
}}
>
<
AppointmentList
/>
{
/* <View style={{ flex: 1, backgroundColor: 'white', height: 60 }}>
<Text style={headerStyle}>Appointment List</Text>
<Text style={headerStyle}>Appointment List</Text>
</View>
</View>
<View>
<View>
...
@@ -71,7 +74,7 @@ class AppointmentListScreen extends Component {
...
@@ -71,7 +74,7 @@ class AppointmentListScreen extends Component {
</ListItem>
</ListItem>
}>
}>
</List>
</List>
<
/View
>
</View>
*/
}
<
/Content
>
<
/Content
>
<
/Container
>
<
/Container
>
)
)
...
...
src/screens/AppointmentsScreen.js
View file @
7ad61941
...
@@ -12,10 +12,12 @@ import {
...
@@ -12,10 +12,12 @@ import {
Input
,
Input
,
Text
Text
}
from
'native-base'
;
}
from
'native-base'
;
import
{
connect
}
from
'react-redux'
;
import
AppHeader
from
'./../components/Header'
;
import
AppHeader
from
'./../components/Header'
;
import
MedForm
from
'./../components/MedForm'
;
import
MedForm
from
'./../components/MedForm'
;
import
{
Grid
,
Col
}
from
'react-native-easy-grid'
;
import
{
Grid
,
Col
}
from
'react-native-easy-grid'
;
import
{
appointmentNotification
}
from
'./../Utils'
;
import
{
appointmentNotification
,
generateID
}
from
'./../Utils'
;
import
{
appointmentCreate
}
from
'./../actions'
import
realm
from
'./../Database'
;
import
realm
from
'./../Database'
;
import
moment
from
'moment'
;
import
moment
from
'moment'
;
...
@@ -31,6 +33,20 @@ class AppointmentsScreen extends React.Component {
...
@@ -31,6 +33,20 @@ class AppointmentsScreen extends React.Component {
}
}
}
}
_addAppointment
()
{
let
id
=
generateID
();
let
time
=
this
.
state
.
time
.
split
(
':'
)
let
appointment
=
{
id
:
id
,
doctorName
:
this
.
state
.
doctor
,
date
:
moment
(
this
.
state
.
date
).
hour
(
time
[
0
]).
minute
(
time
[
1
]).
second
(
0
).
toDate
(),
place
:
this
.
state
.
place
,
time
:
moment
().
date
()
};
this
.
props
.
appointmentCreate
(
appointment
)
this
.
props
.
navigation
.
goBack
(
null
)
}
render
()
{
render
()
{
const
{
goBack
}
=
this
.
props
.
navigation
;
const
{
goBack
}
=
this
.
props
.
navigation
;
...
@@ -105,54 +121,7 @@ class AppointmentsScreen extends React.Component {
...
@@ -105,54 +121,7 @@ class AppointmentsScreen extends React.Component {
// ToastAndroid.show("reset", ToastAndroid.SHORT)
// ToastAndroid.show("reset", ToastAndroid.SHORT)
}
}
_addAppointment() {
if (this.state.doctor && this.state.date && this.state.time) {
Alert.alert(
'
Confirm
',
'
Are
you
sure
to
add
this
appointment
?
',
[
// { text: '
CANCLE
', onPress: () => ToastAndroid.show("Cancled", ToastAndroid.SHORT) },
{ text: '
CANCLE
', onPress: () => { } },
{
text: '
OK
', onPress: () => {
var id = Math.random() * 10000
var time = this.state.time.split('
:
')
var appointmentDate = moment(this.state.date).hour(time[0]).minute(time[1]).second(0).toDate()
var msg = "แจ้งเตือนการนัดพบแพทย์
\
n" + "แพทย์: " + this.state.doctor + "เวลา: " + this.state.time
appointmentNotification(msg, appointmentDate, id)
realm.write(() => {
realm.create('
Appointments
', {
id: id,
doctorName: this.state.doctor,
date: appointmentDate,
place: this.state.place,
timeStamp: moment().toDate()
})
})
this.props.navigation.goBack(null)
}
},
],
{ cancelable: false }
)
} else {
Alert.alert(
'
Please
enter
Doctor
name
/
Select
appointment
date
and
time
',
'',
[
// { text: '
OK
', onPress: () => ToastAndroid.show("Please enter medine name / Select reminder time", ToastAndroid.SHORT) },
{ text: '
OK
', onPress: () => { } },
],
{ cancelable: false }
)
}
}
_datePicker() {
_datePicker() {
try {
try {
...
@@ -224,4 +193,4 @@ const styles = {
...
@@ -224,4 +193,4 @@ const styles = {
}
}
}
}
export default AppointmentsScreen;
export default connect(null, { appointmentCreate })(AppointmentsScreen);
\ No newline at end of file
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment