// 1 => LOADING // 2 => DONE // 3 => ERROR import * as api from "../api/verificationdoctor.js" export default { namespaced: true, state: { ohid:0, lookup_verification_doctor:0, lookup_error_message:'', verifications:[] }, mutations: { update_ohid(state,val) { state.ohid = val }, update_lookup_error_message(state,msg) { state.lookup_error_message = msg }, update_lookup_verification_doctor(state,status) { state.lookup_verification_doctor = status }, update_verifications(state,data) { state.verifications = data.records }, update_txt_verication_doctor(state,data) { state.verifications[data.idx].note = data.val }, update_cbx_verification_doctor(state,data) { state.verifications[data.idx].check = data.val } }, actions: { async lookup(context,prm) { if(context.state.ohid !== prm.ohid){ context.commit("update_lookup_verification_doctor",1) try { let resp= await api.lookup(prm.ohid) if (resp.status != "OK") { context.commit("update_lookup_verification_doctor",3) context.commit("update_lookup_error_message",resp.message) } else { context.commit("update_lookup_verification_doctor",2) context.commit("update_lookup_error_message","") let data = { records : resp.data.records } context.commit("update_verifications",data) context.commit("update_ohid",prm.ohid) } } catch(e) { context.commit("lookup_verification_doctor",3) context.commit("update_lookup_error_message",e.message ) console.log(e) } } } } }