diff --git a/.eslintrc-auto-import.json b/.eslintrc-auto-import.json index 288d60d..34dc331 100644 --- a/.eslintrc-auto-import.json +++ b/.eslintrc-auto-import.json @@ -360,6 +360,7 @@ "requiredEmail": true, "requiredExcelValidator": true, "requiredImageValidator": true, - "requiredName": true + "requiredName": true, + "requiredAmountFloat": true } } diff --git a/auto-imports.d.ts b/auto-imports.d.ts index 4be24c0..808560f 100644 --- a/auto-imports.d.ts +++ b/auto-imports.d.ts @@ -121,6 +121,7 @@ declare global { const refWithControl: typeof import('@vueuse/core')['refWithControl'] const regexValidator: typeof import('./resources/js/@core/utils/validators.js')['regexValidator'] const registerPlugins: typeof import('./resources/js/@core/utils/plugins.js')['registerPlugins'] + const requiredAmountFloat: typeof import('./resources/js/@core/utils/validators.js')['requiredAmountFloat'] const requiredEmail: typeof import('./resources/js/@core/utils/validators.js')['requiredEmail'] const requiredExcelValidator: typeof import('./resources/js/@core/utils/validators.js')['requiredExcelValidator'] const requiredFirstName: typeof import('./resources/js/@core/utils/validators.js')['requiredFirstName'] @@ -483,6 +484,7 @@ declare module 'vue' { readonly refWithControl: UnwrapRef readonly regexValidator: UnwrapRef readonly registerPlugins: UnwrapRef + readonly requiredAmountFloat: UnwrapRef readonly requiredEmail: UnwrapRef readonly requiredExcelValidator: UnwrapRef readonly requiredFirstName: UnwrapRef @@ -838,6 +840,7 @@ declare module '@vue/runtime-core' { readonly refWithControl: UnwrapRef readonly regexValidator: UnwrapRef readonly registerPlugins: UnwrapRef + readonly requiredAmountFloat: UnwrapRef readonly requiredEmail: UnwrapRef readonly requiredExcelValidator: UnwrapRef readonly requiredFirstName: UnwrapRef diff --git a/resources/js/@core/utils/validators.js b/resources/js/@core/utils/validators.js index fdb710e..b0090cf 100644 --- a/resources/js/@core/utils/validators.js +++ b/resources/js/@core/utils/validators.js @@ -142,3 +142,31 @@ export const requiredExcelValidator = value => { return !!String(value).trim().length || 'Email is required' } +export const requiredAmountFloat = (value) => { + // Check if the value is null, undefined, an empty array, or false + if (isNullOrUndefined(value) || isEmptyArray(value) || value === false) { + return 'Amount field is required'; + } + + // Check if the value is a valid float number + if (!isFloat(value)) { + return 'Please enter a valid amount'; + } + + // Additional checks as needed... + + // Return true if the value passes validation + return true; +}; + + + + +// Check if a value is a valid float number +const isFloat = (value) => { + if (typeof value !== 'number' && typeof value !== 'string') { + return false; + } + // Use regex to match a valid float number (including negatives and decimals) + return /^-?\d*\.?\d+$/.test(value); +}; diff --git a/resources/js/constants.js b/resources/js/constants.js index 35fa5dd..40dd673 100644 --- a/resources/js/constants.js +++ b/resources/js/constants.js @@ -37,3 +37,10 @@ export const ADMIN_GET_SITE_SETTING = MAIN_DOMAIN + "/api/admin/site-settings" export const ADMIN_UPDATE_SITE_SETTING = MAIN_DOMAIN + "/api/admin/update-settings/" export const ADMIN_UPDATE_PASSWORD = MAIN_DOMAIN + "/api/admin/password-update" export const PROFILE_UPDATE_API = MAIN_DOMAIN + "/api/admin/admin-update-profile" + +export const ADMIN_LAB_KIT_LIST_API = MAIN_DOMAIN + "/api/admin/labkit-list" +export const ADMIN_LAB_KIT_UPDATE_API = MAIN_DOMAIN + "/api/admin/labkit-update/" +export const ADMIN_LAB_KIT_ADD_API = MAIN_DOMAIN + "/api/admin/labkit-list-create" +export const ADMIN_LAB_KIT_DELETE_API = MAIN_DOMAIN + "/api/admin/labkit-delete/" + + diff --git a/resources/js/navigation/vertical/dashboard.js b/resources/js/navigation/vertical/dashboard.js index 3d71aba..1d14c01 100644 --- a/resources/js/navigation/vertical/dashboard.js +++ b/resources/js/navigation/vertical/dashboard.js @@ -41,9 +41,9 @@ export default [ to: 'admin-providers', }, { - title: 'Labs', + title: 'Lab Kites', icon: { icon: 'ri-test-tube-line' }, - to: 'admin-labs', + to: 'admin-lab-kites', }, { diff --git a/resources/js/pages/labs/labs-kit.vue b/resources/js/pages/labs/labs-kit.vue new file mode 100644 index 0000000..30a139f --- /dev/null +++ b/resources/js/pages/labs/labs-kit.vue @@ -0,0 +1,444 @@ + + + diff --git a/resources/js/pages/medicines/medicines.vue b/resources/js/pages/medicines/medicines.vue index 1e0bf69..9596992 100644 --- a/resources/js/pages/medicines/medicines.vue +++ b/resources/js/pages/medicines/medicines.vue @@ -241,8 +241,8 @@ const save = async () => { list_two_title: defaultItem.value.list_two_title, price: defaultItem.value.price, currency: currencySign.value, - excel:'', //ecelData, - image:''//imageBase64.value + excel:'',//ecelData, + image:imageBase64.value }) } @@ -299,8 +299,8 @@ const update = async () => { list_two_title: editedItem.value.list_two_title, price: editedItem.value.price, currency: currencySign.value, - excel:'', //ecelData, - image:''//imageBase64.value + excel:'',//ecelData, + image:imageBase64.value }) } @@ -393,7 +393,7 @@ onMounted(() => { outlined /> - + import('@/pages/labs/labs.vue'), }, + { + path: '/admin/lab-kites', + name: 'admin-lab-kites', + component: () => import('@/pages/labs/labs-kit.vue'), + }, { path: '/admin/medicines', name: 'admin-medicines', diff --git a/resources/js/store.js b/resources/js/store.js index 6721a6b..85bf53f 100644 --- a/resources/js/store.js +++ b/resources/js/store.js @@ -2,6 +2,10 @@ import axios from 'axios'; import { createStore } from 'vuex'; import { ADMIN_GET_SITE_SETTING, + ADMIN_LAB_KIT_ADD_API, + ADMIN_LAB_KIT_DELETE_API, + ADMIN_LAB_KIT_LIST_API, + ADMIN_LAB_KIT_UPDATE_API, ADMIN_LOGIN_DETAIL, ADMIN_UPDATE_PASSWORD, ADMIN_UPDATE_SITE_SETTING, @@ -48,7 +52,8 @@ export default createStore({ siteSetting: null, showMessage: null, timeout: null, - checkLoginExpire:false + checkLoginExpire: false, + labKitList:[] }, mutations: { setLoading(state, payload) { @@ -95,6 +100,9 @@ export default createStore({ setLabsList(state, payload) { state.labsList = payload }, + setLabKitList(state, payload) { + state.labKitList = payload + }, setPrescription(state, payload) { state.patientPrescription = payload }, @@ -278,7 +286,11 @@ export default createStore({ }) .then(response => { commit('setLoading', false) console.log('Response:', response.data); - + if (response.data.message && response.status === 200) { + commit('setSuccessMsg', true) + console.log('Response:', response.data.message); + commit('setShowMsg', response.data.message) + } }) .catch(error => { commit('setLoading', false) @@ -503,7 +515,11 @@ export default createStore({ }) .then(response => { commit('setLoading', false) console.log('Response:', response.data); - + if (response.data.message=='success' && response.status === 200) { + commit('setSuccessMsg', true) + console.log('Response:', response.data.message); + commit('setShowMsg', 'Successfully Updated') + } }) .catch(error => { commit('setLoading', false) @@ -520,7 +536,11 @@ export default createStore({ }) .then(response => { commit('setLoading', false) console.log('Response:', response.data); - + if (response.data.message && response.status === 200) { + commit('setSuccessMsg', true) + console.log('Response:', response.data.message); + commit('setShowMsg', 'Successfully Deleted') + } }) .catch(error => { commit('setLoading', false) @@ -576,7 +596,11 @@ export default createStore({ }) .then(response => { commit('setLoading', false) console.log('Response:', response.data); - + if (response.data.message=='success' && response.status === 200) { + commit('setSuccessMsg', true) + console.log('Response:', response.data.message); + commit('setShowMsg', 'Successfully Added') + } }) .catch(error => { commit('setLoading', false) @@ -638,7 +662,11 @@ export default createStore({ }) .then(response => { commit('setLoading', false) console.log('Response:', response.data); - + if (response.data.msg && response.status === 200) { + commit('setSuccessMsg', true) + console.log('Response:', response.data.message); + commit('setShowMsg', response.data.msg) + } }) .catch(error => { commit('setLoading', false) @@ -714,6 +742,96 @@ export default createStore({ } }); }, + async labsKitList({ commit }, payload) { + commit('setLoading', true) + + await axios.post(ADMIN_LAB_KIT_LIST_API, {}, { + headers: { + 'Authorization': `Bearer ${localStorage.getItem('admin_access_token')}`, + } + }) .then(response => { + commit('setLoading', false) + console.log('Response:', response.data); + + + + commit('setLabKitList',response.data.labkit) + + }) + .catch(error => { + commit('setLoading', false) + console.error('Error:', error); + }); + }, + async labKitUpdate({ commit }, payload) { + commit('setLoading', true) + await axios.post(ADMIN_LAB_KIT_UPDATE_API+payload.id, { + name: payload.name, + amount: payload.amount, + }, { + headers: { + 'Authorization': `Bearer ${localStorage.getItem('admin_access_token')}`, + } + }) .then(response => { + commit('setLoading', false) + console.log('Response:', response.data); + if (response.data.message && response.status === 200) { + commit('setSuccessMsg', true) + console.log('Response:', response.data.message); + commit('setShowMsg', response.data.message) + } + }) + .catch(error => { + commit('setLoading', false) + console.error('Error:', error); + }); + }, + async labKitAdd({ commit }, payload) { + commit('setLoading', true) + await axios.post(ADMIN_LAB_KIT_ADD_API, { + name: payload.name, + amount: payload.amount, + }, { + headers: { + 'Authorization': `Bearer ${localStorage.getItem('admin_access_token')}`, + } + }) .then(response => { + commit('setLoading', false) + console.log('Response:', response.data); + if (response.data.message && response.status === 200) { + commit('setSuccessMsg', true) + console.log('Response:', response.data.message); + commit('setShowMsg', response.data.message) + } + + }) + .catch(error => { + commit('setLoading', false) + console.error('Error:', error); + }); + }, + async labKitDelete({ commit }, payload) { + commit('setLoading', true) + console.log(localStorage.getItem('admin_access_token')) + await axios.post(ADMIN_LAB_KIT_DELETE_API+payload.id, {}, { + headers: { + 'Authorization': `Bearer ${localStorage.getItem('admin_access_token')}`, + } + }) .then(response => { + commit('setLoading', false) + console.log('Response:', response.data); + if (response.data.message && response.status === 200) { + commit('setSuccessMsg', true) + console.log('Response:', response.data.message); + commit('setShowMsg', response.data.message) + } + + }) + .catch(error => { + commit('setLoading', false) + console.error('Error:', error); + }); + }, }, getters: { getIsLoading(state){ @@ -770,5 +888,8 @@ export default createStore({ getCheckLoginExpire(state){ return state.checkLoginExpire }, + getLabKitList(state) { + return state.labKitList + }, } }) diff --git a/typed-router.d.ts b/typed-router.d.ts index b31a49f..4e1c78c 100644 --- a/typed-router.d.ts +++ b/typed-router.d.ts @@ -119,6 +119,7 @@ declare module 'vue-router/auto/routes' { 'front-pages-payment': RouteRecordInfo<'front-pages-payment', '/front-pages/payment', Record, Record>, 'front-pages-pricing': RouteRecordInfo<'front-pages-pricing', '/front-pages/pricing', Record, Record>, 'labs-labs': RouteRecordInfo<'labs-labs', '/labs/labs', Record, Record>, + 'labs-labs-kit': RouteRecordInfo<'labs-labs-kit', '/labs/labs-kit', Record, Record>, 'login': RouteRecordInfo<'login', '/login', Record, Record>, 'medicines-medicines': RouteRecordInfo<'medicines-medicines', '/medicines/medicines', Record, Record>, 'not-authorized': RouteRecordInfo<'not-authorized', '/not-authorized', Record, Record>,