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
0bfe30a6
Commit
0bfe30a6
authored
Mar 21, 2018
by
Phuengton Chummuel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add new appointmentlist
parent
8225be47
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
89 additions
and
0 deletions
+89
-0
AppointmentList.js
src/components/AppointmentList.js
+56
-0
ListItem.js
src/components/ListItem.js
+33
-0
No files found.
src/components/AppointmentList.js
0 → 100644
View file @
0bfe30a6
import
React
,
{
Component
}
from
'react'
;
import
{
ListView
}
from
'react-native'
;
import
{
connect
}
from
'react-redux'
;
import
{
View
}
from
'native-base'
;
import
{
appointmentFetch
,
appointmentDelete
}
from
'./../actions'
import
ListItem
from
'./../components/ListItem'
import
realm
from
'./../Database'
class
AppointmentList
extends
Component
{
componentWillMount
()
{
this
.
props
.
appointmentFetch
()
this
.
createDataSource
(
this
.
props
)
}
componentWillReceiveProps
(
nextProps
)
{
// nextProps are the next set of props that this component
// will be rendered with
// this.props is still the old set of props
this
.
createDataSource
(
nextProps
);
}
createDataSource
({
appointments
})
{
const
ds
=
new
ListView
.
DataSource
({
rowHasChanged
:
(
r1
,
r2
)
=>
r1
!==
r2
});
this
.
dataSource
=
ds
.
cloneWithRows
(
appointments
.
appointments
);
}
renderRow
({
id
,
doctorName
,
date
,
time
,
place
})
{
let
appointment
=
{
id
,
doctorName
,
date
:
date
.
toString
(),
time
,
place
}
return
<
ListItem
data
=
{
appointment
}
/
>
}
render
()
{
return
(
<
View
>
<
ListView
enableEmptySections
dataSource
=
{
this
.
dataSource
}
renderRow
=
{
this
.
renderRow
}
/
>
<
/View
>
)
}
}
const
mapStateToProps
=
state
=>
{
return
{
appointments
:
state
.
appointments
}
};
export
default
connect
(
mapStateToProps
,
{
appointmentFetch
,
appointmentDelete
})(
AppointmentList
);
\ No newline at end of file
src/components/ListItem.js
0 → 100644
View file @
0bfe30a6
import
React
,
{
Component
}
from
'react'
;
import
{
TouchableOpacity
}
from
'react-native'
;
import
{
View
,
Text
}
from
'native-base'
;
import
{
appointmentDelete
}
from
'./../actions'
import
{
connect
}
from
'react-redux'
;
import
moment
from
'moment'
;
class
ListItem
extends
Component
{
constructor
(
props
)
{
super
(
props
)
}
deleteAppointment
(
id
)
{
this
.
props
.
appointmentDelete
(
id
)
}
render
()
{
return
(
<
TouchableOpacity
onPress
=
{()
=>
this
.
deleteAppointment
(
this
.
props
.
data
.
id
)}
>
<
View
>
<
Text
>
{
this
.
props
.
data
.
doctorName
}
<
/Text
>
<
Text
>
{
this
.
props
.
data
.
date
}
<
/Text
>
<
Text
>
{
this
.
props
.
data
.
time
}
<
/Text
>
<
Text
>
{
this
.
props
.
data
.
place
}
<
/Text
>
<
/View
>
<
/TouchableOpacity
>
)
}
}
export
default
connect
(
null
,
{
appointmentDelete
})(
ListItem
);
\ 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