Commit c7d2068c authored by Phuengton Chummuel's avatar Phuengton Chummuel

change action in reminderAction.js

parent 72092594
...@@ -8,20 +8,21 @@ import realm from './../Database/' ...@@ -8,20 +8,21 @@ import realm from './../Database/'
import moment from 'moment' import moment from 'moment'
import { ToastAndroid } from 'react-native' import { ToastAndroid } from 'react-native'
export const reminderCreate = ({ id, doctorName, date, place, time }) => { export const reminderCreate = ({ id, medName, reminderTime, meal, period, dose }) => {
return (dispatch) => { return (dispatch) => {
let appointment = { id, doctorName, date, place, time }
realm.write(() => { realm.write(() => {
realm.create('Reminder', { realm.create('Reminder', {
id: id, id: id,
doctorName: doctorName, medName: medName,
date: date, reminderTime: reminderTime,
place: place, meal: meal,
period: period,
dose: dose,
timeStamp: moment().toDate() timeStamp: moment().toDate()
}) })
}) })
let appointments = realm.objects("Reminder") let reminders = realm.objects("Reminder")
dispatch({ type: APPOINTMENT_CREATE, payload: appointments }) dispatch({ type: REMINDER_CREATE, payload: reminders })
} }
} }
...@@ -33,8 +34,8 @@ export const reminderUpdate = () => { ...@@ -33,8 +34,8 @@ export const reminderUpdate = () => {
export const reminderFetch = () => { export const reminderFetch = () => {
return (dispatch) => { return (dispatch) => {
let appointments = realm.objects("Reminder") let reminders = realm.objects("Reminder")
dispatch({ type: APPOINTMENT_FETCH, payload: appointments }) dispatch({ type: REMINDER_FETCH, payload: reminders })
} }
} }
...@@ -44,7 +45,7 @@ export const reminderDelete = (id) => { ...@@ -44,7 +45,7 @@ export const reminderDelete = (id) => {
realm.write(() => { realm.write(() => {
realm.delete(item) realm.delete(item)
}) })
let appointments = realm.objects("Reminder") let reminders = realm.objects("Reminder")
dispatch({ type: APPOINTMENT_DELETE, payload: appointments }) dispatch({ type: REMINDER_DELETE, payload: reminders })
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment