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
fd0d4343
Commit
fd0d4343
authored
Mar 21, 2018
by
Phuengton Chummuel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add redux actions
parent
751e5f95
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
113 additions
and
0 deletions
+113
-0
appointmentActions.js
src/actions/appointmentActions.js
+50
-0
index.js
src/actions/index.js
+3
-0
reminderAction.js
src/actions/reminderAction.js
+50
-0
types.js
src/actions/types.js
+10
-0
No files found.
src/actions/appointmentActions.js
0 → 100644
View file @
fd0d4343
import
{
APPOINTMENT_FETCH
,
APPOINTMENT_CREATE
,
APPOINTMENT_UPDATE
,
APPOINTMENT_DELETE
}
from
'./../actions/types'
import
realm
from
'./../Database/'
import
moment
from
'moment'
import
{
ToastAndroid
}
from
'react-native'
export
const
appointmentCreate
=
({
id
,
doctorName
,
date
,
place
,
time
})
=>
{
return
(
dispatch
)
=>
{
let
appointment
=
{
id
,
doctorName
,
date
,
place
,
time
}
realm
.
write
(()
=>
{
realm
.
create
(
'Appointments'
,
{
id
:
id
,
doctorName
:
doctorName
,
date
:
date
,
place
:
place
,
timeStamp
:
moment
().
toDate
()
})
})
let
appointments
=
realm
.
objects
(
"Appointments"
)
dispatch
({
type
:
APPOINTMENT_CREATE
,
payload
:
appointments
})
}
}
export
const
appointmentUpdate
=
()
=>
{
return
(
dispatch
)
=>
{
}
}
export
const
appointmentFetch
=
()
=>
{
return
(
dispatch
)
=>
{
let
appointments
=
realm
.
objects
(
"Appointments"
)
dispatch
({
type
:
APPOINTMENT_FETCH
,
payload
:
appointments
})
}
}
export
const
appointmentDelete
=
(
id
)
=>
{
return
(
dispatch
)
=>
{
let
item
=
realm
.
objects
(
"Appointments"
).
filtered
(
'id == '
+
'"'
+
id
+
'"'
)
realm
.
write
(()
=>
{
realm
.
delete
(
item
)
})
let
appointments
=
realm
.
objects
(
"Appointments"
)
dispatch
({
type
:
APPOINTMENT_DELETE
,
payload
:
appointments
})
}
}
src/actions/index.js
0 → 100644
View file @
fd0d4343
export
*
from
'./appointmentActions'
export
*
from
'./reminderAction'
\ No newline at end of file
src/actions/reminderAction.js
0 → 100644
View file @
fd0d4343
import
{
REMINDER_FETCH
,
REMINDER_CREATE
,
REMINDER_UPDATE
,
REMINDER_DELETE
}
from
'./../actions/types'
import
realm
from
'./../Database/'
import
moment
from
'moment'
import
{
ToastAndroid
}
from
'react-native'
export
const
reminderCreate
=
({
id
,
doctorName
,
date
,
place
,
time
})
=>
{
return
(
dispatch
)
=>
{
let
appointment
=
{
id
,
doctorName
,
date
,
place
,
time
}
realm
.
write
(()
=>
{
realm
.
create
(
'Reminder'
,
{
id
:
id
,
doctorName
:
doctorName
,
date
:
date
,
place
:
place
,
timeStamp
:
moment
().
toDate
()
})
})
let
appointments
=
realm
.
objects
(
"Reminder"
)
dispatch
({
type
:
APPOINTMENT_CREATE
,
payload
:
appointments
})
}
}
export
const
reminderUpdate
=
()
=>
{
return
(
dispatch
)
=>
{
}
}
export
const
reminderFetch
=
()
=>
{
return
(
dispatch
)
=>
{
let
appointments
=
realm
.
objects
(
"Reminder"
)
dispatch
({
type
:
APPOINTMENT_FETCH
,
payload
:
appointments
})
}
}
export
const
reminderDelete
=
(
id
)
=>
{
return
(
dispatch
)
=>
{
let
item
=
realm
.
objects
(
"Reminder"
).
filtered
(
'id == '
+
'"'
+
id
+
'"'
)
realm
.
write
(()
=>
{
realm
.
delete
(
item
)
})
let
appointments
=
realm
.
objects
(
"Reminder"
)
dispatch
({
type
:
APPOINTMENT_DELETE
,
payload
:
appointments
})
}
}
src/actions/types.js
0 → 100644
View file @
fd0d4343
export
const
APPOINTMENT_FETCH
=
'APPOINTMENT_FETCH'
;
export
const
APPOINTMENT_CREATE
=
'APPOINTMENT_CREATE'
;
export
const
APPOINTMENT_UPDATE
=
'APPOINTMENT_UPDATE'
;
export
const
APPOINTMENT_DELETE
=
'APPOINTMENT_DELETE'
;
export
const
REMINDER_FETCH
=
'REMINDER_FETCH'
;
export
const
REMINDER_CREATE
=
'REMINDER_CREATE'
;
export
const
REMINDER_UPDATE
=
'REMINDER_UPDATE'
;
export
const
REMINDER_DELETE
=
'REMINDER_DELETE'
;
\ 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