diff --git a/src/components/menus/ProfileMenu.vue b/src/components/menus/ProfileMenu.vue index 8da19ef..e7cf504 100644 --- a/src/components/menus/ProfileMenu.vue +++ b/src/components/menus/ProfileMenu.vue @@ -15,7 +15,6 @@ export default defineComponent({ name: 'ProfileMenu', computed: { getUserId(): number { - console.log(this.$store.state.user.userId) return this.$store.state.user.userId } } diff --git a/src/components/pos/CartTable.vue b/src/components/pos/CartTable.vue index f4de3d2..d7e8c3f 100644 --- a/src/components/pos/CartTable.vue +++ b/src/components/pos/CartTable.vue @@ -2,7 +2,7 @@
- + @@ -13,139 +13,117 @@ - - + + - - + - + - + - + - + - + - +
Item Unit
{{ item.name }}
{{ item.item_name }} {{ item.unit }}{{ item.price }} + {{ item.unit_price }} - + {{ item.qty }} {{ item.price * item.quantity }}{{ item.unit_price * item.qty }} - +
Subtotal {{ getSubtotal }} {{ getCurrency }}{{ getCartSubtotal }} {{ $store.getters.cartCurrency(cart.payment_method) }}
Discount - {{ getDiscount }} {{ getCurrency }}{{ cart.discount }} {{ $store.getters.cartCurrency(cart.payment_method) }}
Tax {{ getTax }} {{ getCurrency }}{{ getCartTax }} {{ $store.getters.cartCurrency(cart.payment_method) }}
Total {{ getTotal }} {{ getCurrency }}{{ getCartTotal }} {{ $store.getters.cartCurrency(cart.payment_method) }}

Total Payment

-

{{ getTotal }} {{ getCurrency }}

+

{{ getCartTotal }} {{ $store.getters.cartCurrency('tnbc') }}

\ No newline at end of file diff --git a/src/components/pos/ItemCard.vue b/src/components/pos/ItemCard.vue index 1f64931..86882eb 100644 --- a/src/components/pos/ItemCard.vue +++ b/src/components/pos/ItemCard.vue @@ -5,22 +5,29 @@

{{ item.name }}

- {{ $store.getters['settings/currency'] }} - {{ item.price }}

+ {{ getCurrency }} + {{ item.price }} +

\ No newline at end of file diff --git a/src/components/pos/Payments.vue b/src/components/pos/Payments.vue index 5970e25..31d3b6b 100644 --- a/src/components/pos/Payments.vue +++ b/src/components/pos/Payments.vue @@ -70,8 +70,7 @@ export default defineComponent({ }, computed: { isTNBCSelected(): boolean { - const method = this.$store.state.pos.paymentType - console.log('method', method) + const method = this.$store.state.pos.cart.payment_method if (method === 'tnbc'){ return true } diff --git a/src/http-common.ts b/src/http-common.ts index e6116d1..42ecdee 100644 --- a/src/http-common.ts +++ b/src/http-common.ts @@ -4,8 +4,8 @@ import router from '@/router'; process.env.NODE_ENV const apiClient: AxiosInstance = axios.create({ - baseURL: process.env.NODE_ENV === 'development' ? "https://tnbposapi.nathanaeljageni.fr/api" : "https://tnbposapi.nathanaeljageni.fr/api", - // baseURL: process.env.NODE_ENV === 'development' ? "http://127.0.0.1:8000/api" : "https://tnbposapi.nathanaeljageni.fr/api", + // baseURL: process.env.NODE_ENV === 'development' ? "https://tnbposapi.nathanaeljageni.fr/api" : "https://tnbposapi.nathanaeljageni.fr/api", + baseURL: process.env.NODE_ENV === 'development' ? "http://127.0.0.1:8000/api" : "https://tnbposapi.nathanaeljageni.fr/api", withCredentials: true, headers: { "Content-type": "application/json", diff --git a/src/store/index.js b/src/store/index.js deleted file mode 100644 index 8982c14..0000000 --- a/src/store/index.js +++ /dev/null @@ -1,18 +0,0 @@ -import { createStore } from 'vuex' -import createPersistedState from 'vuex-persistedstate' -import user from './modules/user' -import session from './modules/session' -import pos from './modules/pos.js' -import settings from './modules/settings' - -export default createStore({ - modules: { - user, - session, - pos, - settings - }, - plugins: [createPersistedState({ - paths: ['user', 'session', 'pos', 'settings'], - })] -}) diff --git a/src/store/index.ts b/src/store/index.ts new file mode 100644 index 0000000..92006c7 --- /dev/null +++ b/src/store/index.ts @@ -0,0 +1,24 @@ +import { createStore } from 'vuex' +import createPersistedState from 'vuex-persistedstate' +import { UserModule } from './modules/user' +import { SessionModule } from './modules/session' +import { PosModule } from './modules/pos' +import { SettingsModule } from './modules/settings' + +export default createStore({ + state: {}, + mutations: { + initializeStore(state) {} + }, + actions: {}, + getters: {}, + modules: { + user: UserModule, + session: SessionModule, + pos: PosModule, + settings: SettingsModule, + }, + plugins: [createPersistedState({ + paths: ['user', 'session', 'pos', 'settings'], + })] +}) diff --git a/src/store/modules/pos.js b/src/store/modules/pos.js deleted file mode 100644 index d85c506..0000000 --- a/src/store/modules/pos.js +++ /dev/null @@ -1,201 +0,0 @@ -const state = () => ({ - cart: { - customerID: null, - items: [] - }, - coupon: {}, - paymentType: null, - isProcessingPayment: false - }) - -const mutations = { - UPDATE_CART(state, payload) { - state.cart = payload - - }, - ADD_ITEM_TO_CART(state, payload) { - const cart = state.cart - - if (cart.items.length) { - const exists = cart.items.filter(i => i.item_id === payload.item_id) - - if (exists.length) { - exists[0].quantity += 1 - - } else { - payload.quantity = 1 - cart.items.push(payload) - - } - } else { - payload.quantity = 1 - cart.items.push(payload) - - } - }, - ADD_QUANTITY_TO_ITEM(state, payload) { - let item = state.cart.items.filter(item => item.item_id === payload)[0] - item.quantity += 1 - - }, - UPDATE_QUANTITY_OF_ITEM(state, payload) { - let item = state.cart.items.filter(item => item.item_id === payload.id)[0] - item.quantity = payload.quantity - - }, - REMOVE_QUANTITY_TO_ITEM(state, payload) { - let item = state.cart.items.filter(item => item.item_id === payload)[0] - item.quantity -= 1 - - }, - DELETE_CART_ITEM(state, payload) { - state.cart.items = state.cart.items.filter(item => item.item_id !== payload) - - }, - UPDATE_INVOICE_NUMBER(state, payload){ - state.cart = {...state.cart, ...payload} - - }, - UPDATE_PAYMENT_METHOD(state, payload){ - state.paymentType = payload - - }, - UPDATE_COUPON(state, payload){ - state.coupon = payload - - }, - UPDATE_IS_PROCESSING_PAYMENT(state, payload){ - state.isProcessingPayment = payload - - }, - ADD_CUSTOMER_TO_CART(state, payload){ - state.cart.customerID = payload - - }, - CONVERT_PRICES_TO_USD(state, payload){ - let items = state.cart.items - - items.map((item) => { - console.log(item.price, payload) - item.price = Math.ceil(item.price * payload) - }) - }, - CONVERT_PRICES_TO_TNBC(state, payload){ - let items = state.cart.items - // console.log(items) - - items.map((item) => { - item.price = Math.ceil(item.price / payload) - }) - }, - CONVERT_PRICES_TO_FIAT(state, payload){ - let cartItems = state.cart.items - let items = payload - - cartItems.map((cartItem) => { - items.map((item) => { - if (cartItem.item_id === item.item_id){ - cartItem.price = item.price - } - }) - }) - } -} -const actions = { - setCart(context, payload){ - context.commit('UPDATE_CART', payload) - - }, - addItemToCart(context, payload){ - context.commit('ADD_ITEM_TO_CART', payload) - - }, - addQuantityToItem(context, payload){ - context.commit('ADD_QUANTITY_TO_ITEM', payload) - - }, - updateQuantityOfItem(context, payload){ - context.commit('UPDATE_QUANTITY_OF_ITEM', payload) - - }, - removeQuantityToItem(context, payload){ - if (payload.quantity > 1){ - context.commit('REMOVE_QUANTITY_TO_ITEM', payload.id) - - } else { - context.commit('DELETE_CART_ITEM', payload.id) - - } - }, - deleteCartItem(context, payload) { - context.commit('DELETE_CART_ITEM', payload) - - }, - setInvoiceNumber(context, payload){ - context.commit('UPDATE_INVOICE_NUMBER', payload) - - }, - setPaymentMethod(context, payload){ - context.commit('UPDATE_PAYMENT_METHOD', payload) - - }, - setCoupon(context, payload){ - context.commit('UPDATE_COUPON', payload) - - }, - setIsProcessingPayment(context, payload){ - context.commit('UPDATE_IS_PROCESSING_PAYMENT', payload) - - }, - addCustomerToCart(context, payload){ - context.commit('ADD_CUSTOMER_TO_CART', payload) - - }, - convertPricesToUSD(context, payload){ - context.commit('CONVERT_PRICES_TO_USD', payload) - - }, - convertPricesToTNBC(context, payload){ - context.commit('CONVERT_PRICES_TO_TNBC', payload) - }, - convertPricesToFIAT(context, payload){ - context.commit('CONVERT_PRICES_TO_FIAT', payload) - } -} -const getters = { - isProcessingPayment: (state) => { - return state.isProcessingPayment - - }, - cart: (state) => { - return state.cart - - }, - subtotal: (state) => { - if (state.cart.items.length) { - return state.cart.items - .map(item => { - return item.price * item.quantity - - }) - .reduce((item1, item2) => item1 + item2 ) - } - - return 0 - }, - discount: (state) => { - if (state.coupon) { - return state.coupon.discount - } - - return 0 - } -} - -export default { - namespaced: true, - state, - actions, - getters, - mutations -} \ No newline at end of file diff --git a/src/store/modules/pos.ts b/src/store/modules/pos.ts new file mode 100644 index 0000000..690214b --- /dev/null +++ b/src/store/modules/pos.ts @@ -0,0 +1,178 @@ +import { Cart, CartItems } from '@/types/pos/Cart' +import { SingleItem } from '@/types/items/Items' + +export const PosModule = { + namespaced: true, + state: () => ({ + cart: { + cartItems: [], + payment_method: '' + } as Cart, + coupon: '' as string, + isProcessingPayment: false as boolean + }), + mutations: { + UPDATE_CART(state: any, payload: any){ + state.cart = {...state.cart, payload} + }, + ADD_ITEM_TO_CART(state: any, cartItem: CartItems){ + state.cart.cartItems.push(cartItem) + }, + REMOVE_ITEM_FROM_CART(state: any, item_id: number){ + const filteredCartItems = state.cart.cartItems.filter((item: CartItems) => { + return item.item_id !== item_id + }) + + state.cart.cartItems = filteredCartItems + }, + ADD_QUANTITY_TO_CART_ITEM(state: any, item_id: number){ + state.cart.cartItems.map((item: CartItems) => { + if (item.item_id === item_id){ + item.qty += 1 + } + }) + }, + REMOVE_QUANTITY_FROM_CART_ITEM(state: any, item_id: number){ + state.cart.cartItems.map((item: CartItems) => { + if (item.item_id === item_id){ + if (item.qty <= 0) + return + + item.qty -= 1 + } + }) + }, + REMOVE_QUANTITY_FROM_CART_ITEM(state: any, item_id: number){ + state.cart.cartItems.map((item: CartItems) => { + if (item.item_id === item_id){ + if (item.qty <= 0) + return + + item.qty -= 1 + } + }) + }, + UPDATE_INVOICE_NUMBER(state: any, payload: any){ + state.cart = {...state.cart, ...payload} + }, + UPDATE_PAYMENT_METHOD(state: any, payload: string){ + state.cart.payment_method = payload + }, + UPDATE_COUPON(state: any, payload: any){ + state.coupon = payload + }, + UPDATE_IS_PROCESSING_PAYMENT(state: any, payload: any){ + state.isProcessingPayment = payload + }, + CONVERT_PRICES_TO_USD(state: any, payload: any){ + let items = state.cart.cartItems + + items.map((item: CartItems) => { + item.price = Math.ceil(item.unit_price * payload) + }) + }, + CONVERT_PRICES_TO_TNBC(state: any, payload: any){ + let items = state.cart.cartItems + + items.map((item: CartItems) => { + item.price = Math.ceil(item.unit_price / payload) + }) + }, + CONVERT_PRICES_TO_FIAT(state: any, payload: any){ + let stateCartItems = state.cart.cartItems + let items = payload + + stateCartItems.map((stateCartItem) => { + items.map((item) => { + if (stateCartItem.item_id === item.item_id){ + stateCartItem.unit_price = item.price + } + }) + }) + } + }, + actions: { + setCart(context: any, payload: any){ + context.commit('UPDATE_CART', payload) + }, + addItemToCart(context: any, payload: SingleItem){ + let stateCart = context.state.cart + const cartItem: CartItems = { + item_id: payload.item_id, + item_name: payload.name, + unit: payload.unit, + unit_price: payload.price, + qty: 1 + } + console.log('cartItems length', stateCart.cartItems.length); + + if (stateCart.cartItems.length) { + const exists = stateCart.cartItems.filter((i: { item_id: Number }) => i.item_id === cartItem.item_id) + console.log('exists length', exists.length); + if (exists.length) { + context.commit('ADD_QUANTITY_TO_CART_ITEM', cartItem.item_id) + } else { + context.commit('ADD_ITEM_TO_CART', cartItem) + } + } else { + context.commit('ADD_ITEM_TO_CART', cartItem) + } + }, + removeItemFromCart(context: any, payload: any){ + context.commit('REMOVE_ITEM_FROM_CART', payload) + }, + addQuantityToCartItem(context: any, item_id: any){ + context.commit('ADD_QUANTITY_TO_CART_ITEM', item_id) + }, + removeQuantityFromCartItem(context: any, payload: any){ + context.commit('REMOVE_QUANTITY_FROM_CART_ITEM', payload) + }, + setInvoiceNumber(context: any, payload: any){ + context.commit('UPDATE_INVOICE_NUMBER', payload) + }, + setPaymentMethod(context: any, payload: string){ + context.commit('UPDATE_PAYMENT_METHOD', payload) + }, + setCoupon(context: any, payload: any){ + context.commit('UPDATE_COUPON', payload) + }, + setIsProcessingPayment(context: any, payload: any){ + context.commit('UPDATE_IS_PROCESSING_PAYMENT', payload) + }, + convertPricesToUSD(context: any, payload: any){ + context.commit('CONVERT_PRICES_TO_USD', payload) + }, + convertPricesToTNBC(context: any, payload: any){ + context.commit('CONVERT_PRICES_TO_TNBC', payload) + }, + convertPricesToFIAT(context: any, payload: any){ + context.commit('CONVERT_PRICES_TO_FIAT', payload) + } + }, + getters: { + isProcessingPayment: (state: any): boolean => { + return state.isProcessingPayment + }, + cartSubtotal: (state: any): number => { + const cartHasItems = state.cart.cartItems.length; + let total = 0; + if (cartHasItems) { + state.cart.cartItems.map((item: CartItems) => { + total += item.unit_price * item.qty + }) + } + + return total + }, + cartTax: (state: any, getters: any, rootState: any): number => { + const subTotal = getters.cartSubtotal + const taxRate = rootState.settings.taxRate / 100 + return subTotal * taxRate + }, + cartTotal: (state: any, getters: any, rootState: any): number => { + const subTotal = getters.cartSubtotal + const taxTotal = getters.cartTax + return subTotal + taxTotal + }, + } +} \ No newline at end of file diff --git a/src/store/modules/session.js b/src/store/modules/session.js deleted file mode 100644 index 0351a5e..0000000 --- a/src/store/modules/session.js +++ /dev/null @@ -1,20 +0,0 @@ -const state = () => ({ - bearerToken: '' -}) -const mutations = { - UPDATE_BEARER_TOKEN(state, payload) { - state.bearerToken = payload - } -} -const actions = { - setBearerToken(context, payload){ - context.commit('UPDATE_BEARER_TOKEN', payload) - }, -} - -export default { - namespaced: true, - state, - actions, - mutations -} \ No newline at end of file diff --git a/src/store/modules/session.ts b/src/store/modules/session.ts new file mode 100644 index 0000000..47b85a2 --- /dev/null +++ b/src/store/modules/session.ts @@ -0,0 +1,16 @@ +export const SessionModule = { + namespaced: true, + state: () => ({ + bearerToken: '' + }), + mutations: { + UPDATE_BEARER_TOKEN(state: any, payload: string) { + state.bearerToken = payload + }, + }, + actions: { + setBearerToken(context: any, payload: string){ + context.commit('UPDATE_BEARER_TOKEN', payload) + }, + } +} \ No newline at end of file diff --git a/src/store/modules/settings.js b/src/store/modules/settings.js deleted file mode 100644 index 75e50c9..0000000 --- a/src/store/modules/settings.js +++ /dev/null @@ -1,50 +0,0 @@ -const state = () => ({ - currency: '', - currencySign: '', - taxRate: 0, - TNBCRate: 0 -}) -const mutations = { - UPDATE_CURRENCY(state, payload){ - state.currency = payload - }, - UPDATE_CURRENCY_SIGN(state, payload){ - state.currencySign = payload - }, - UPDATE_TAX_RATE(state, payload){ - state.taxRate = payload - }, - UPDATE_TNBC_RATE(state, payload){ - state.TNBCRate = payload - } -} -const actions = { - setCurrency(context, payload){ - context.commit('UPDATE_CURRENCY', payload.currency) - context.commit('UPDATE_CURRENCY_SIGN', payload.currencySign) - }, - setTaxRate(context, payload){ - context.commit('UPDATE_TAX_RATE', payload) - }, - setTNBCRate(context, payload){ - context.commit('UPDATE_TNBC_RATE', payload) - }, -} -const getters = { - currency: (state) => { - return `${state.currencySign}${state.currency}` - }, - cartCurrency: (state) => (payment_method) => { - if (payment_method !== 'tnbc'){ - return state.currency - } else return payment_method.toUpperCase() - } -} - -export default { - namespaced: true, - state, - actions, - getters, - mutations -} \ No newline at end of file diff --git a/src/store/modules/settings.ts b/src/store/modules/settings.ts new file mode 100644 index 0000000..eb0745b --- /dev/null +++ b/src/store/modules/settings.ts @@ -0,0 +1,46 @@ +export const SettingsModule = { + namespaced: false, + state: () => ({ + currency: '', + currencySign: '', + taxRate: 0, + tnbcRate: 0, + usdRate: 0 + }), + mutations: { + UPDATE_CURRENCY(state: any, payload: any){ + state.currency = payload + }, + UPDATE_CURRENCY_SIGN(state: any, payload: any){ + state.currencySign = payload + }, + UPDATE_TAX_RATE(state: any, payload: any){ + state.taxRate = payload + }, + UPDATE_TNBC_RATE(state: any, payload: any){ + state.tnbcRate = payload + }, + UPDATE_USD_RATE(state: any, payload: any){ + state.usdRate = payload + } + }, + actions: { + setConfiguration(context: any, payload: any){ + context.commit('UPDATE_CURRENCY', payload.currency) + context.commit('UPDATE_CURRENCY_SIGN', payload.currency_symble) + context.commit('UPDATE_TAX_RATE', payload.tax_rate) + context.commit('UPDATE_TNBC_RATE', payload.tnbc_rate) + context.commit('UPDATE_USD_RATE', payload.usd_rate) + } + }, + getters: { + currency: (state: any): string => { + return `${state.currencySign}${state.currency}` + }, + cartCurrency: (state: any) => (payment_method: string): string => { + if (payment_method !== 'tnbc'){ + return state.currency + } else return payment_method.toUpperCase() + }, + } +} \ No newline at end of file diff --git a/src/store/modules/user.js b/src/store/modules/user.js deleted file mode 100644 index 65a57c7..0000000 --- a/src/store/modules/user.js +++ /dev/null @@ -1,63 +0,0 @@ -const state = () => ({ - isAuthenticated: false, - userEmail: '', - userId: null, - roleId: null, - isAdmin: false, - isEmailVerified: false, - permissions: undefined -}) -const mutations = { - UPDATE_AUTHENTICATION(state, payload) { - state.isAuthenticated = payload - }, - UPDATE_USER_EMAIL(state, payload) { - state.userEmail = payload - }, - UPDATE_USER_ID(state, payload) { - state.userId = payload - }, - SET_IS_ADMIN(state) { - state.isAdmin = true - }, - UPDATE_ROLE_ID(state, payload) { - state.roleId = payload - }, - UPDATE_PERMISSIONS(state, payload) { - state.permissions = payload - }, - UPDATE_EMAIL_VERIFICATION(state, payload) { - state.isEmailVerified = payload - }, -} - -const actions = { - setAuthentication(context, payload) { - context.commit('UPDATE_AUTHENTICATION', payload) - }, - setUserEmail(context, payload) { - context.commit('UPDATE_USER_EMAIL', payload) - }, - setUserId(context, payload) { - context.commit('UPDATE_USER_ID', payload) - }, - setRoleId(context, payload) { - context.commit('UPDATE_ROLE_ID', payload) - }, - setIsAdmin(context) { - context.commit('SET_IS_ADMIN') - }, - setPermissions(context, payload) { - context.commit('UPDATE_PERMISSIONS', payload) - }, - setEmailVerification(context, payload) { - context.commit('UPDATE_EMAIL_VERIFICATION', payload) - }, -} - -export default { - namespaced: true, - state, - actions, - mutations -} \ No newline at end of file diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts new file mode 100644 index 0000000..fc31ee0 --- /dev/null +++ b/src/store/modules/user.ts @@ -0,0 +1,67 @@ +export const UserModule = { + namespaced: true, + state: () => ({ + isAuthenticated: false, + userEmail: '', + userId: null, + roleId: null, + isAdmin: false, + isEmailVerified: false, + permissions: undefined as any + }), + mutations: { + UPDATE_AUTHENTICATION(state: any, payload: any) { + state.isAuthenticated = payload + }, + UPDATE_USER_EMAIL(state: any, payload: any) { + state.userEmail = payload + }, + UPDATE_USER_ID(state: any, payload: any) { + state.userId = payload + }, + SET_IS_ADMIN(state: any) { + state.isAdmin = true + }, + UPDATE_ROLE_ID(state: any, payload: any) { + state.roleId = payload + }, + UPDATE_PERMISSIONS(state: any, payload: any) { + state.permissions = payload + }, + UPDATE_EMAIL_VERIFICATION(state: any, payload: any) { + state.isEmailVerified = payload + } + }, + actions: { + setAuthentication(context: any, payload: any) { + context.commit('UPDATE_AUTHENTICATION', payload) + }, + setUserEmail(context: any, payload: any) { + context.commit('UPDATE_USER_EMAIL', payload) + }, + setUserId(context: any, payload: any) { + context.commit('UPDATE_USER_ID', payload) + }, + setRoleId(context: any, payload: any) { + context.commit('UPDATE_ROLE_ID', payload) + }, + setIsAdmin(context: any) { + context.commit('SET_IS_ADMIN') + }, + setPermissions(context: any, payload: any) { + context.commit('UPDATE_PERMISSIONS', payload) + }, + setEmailVerification(context: any, payload: any) { + context.commit('UPDATE_EMAIL_VERIFICATION', payload) + } + }, + getters: { + userCan: (state: any) => (action: string, type: string): boolean => { + if (state.permissions[type][action]) { + return state.permissions[type][action] + } else { + return false + } + } + } +} \ No newline at end of file diff --git a/src/types/pos/Cart.ts b/src/types/pos/Cart.ts index 98cad5e..572f8b6 100644 --- a/src/types/pos/Cart.ts +++ b/src/types/pos/Cart.ts @@ -1,3 +1,11 @@ +export interface CartItems { + item_id: number, + item_name: string, + unit: string, + unit_price: number, + qty: number +} + export interface Cart { cashier: string, payment_method: string, @@ -10,16 +18,5 @@ export interface Cart { cart_id: number, user_id: number, customer_id: number | null, - cartItems: [] -} - -export interface CartItems { - id: number, - cart_id: number, - item_id: number, - item_name: string, - unit: string, - unit_price: number, - qty: number, - total: number -} \ No newline at end of file + cartItems: CartItems[] +} \ No newline at end of file diff --git a/src/views/admin/Configuration.vue b/src/views/admin/Configuration.vue index 0890f1e..885f1eb 100644 --- a/src/views/admin/Configuration.vue +++ b/src/views/admin/Configuration.vue @@ -197,14 +197,11 @@ import { defineComponent } from 'vue' import { currencies } from 'currencies.json' import Multiselect from '@vueform/multiselect' - // components import CancelIcon from '@/components/icons/CancelIcon.vue' - // types and services import { Configuration } from '@/types/Configuration' import ConfigurationService from '@/services/ConfigurationService' - export default defineComponent({ name: 'Configuration', components: { CancelIcon, Multiselect }, @@ -248,23 +245,15 @@ export default defineComponent({ fd.append('app_logo', this.newAppLogo) fd.append('store_logo', this.newStoreLogo) fd.append('_method', 'PUT') - - this.$store.dispatch('settings/setTaxRate', this.configuration.tax_rate) - this.$store.dispatch('settings/setTNBCRate', this.configuration.tnbc_rate) - this.$store.dispatch('settings/setCurrency', { - currency: this.configuration.currency, - currencySign: this.configuration.currency_symble - }) - this.$store.dispatch('settings/setTNBCRate', this.configuration.tnbc_rate) - let token = this.$store.state.session.bearerToken await ConfigurationService.update(fd, token) - .then((json) => { - console.log('json', json) + .then((response) => { + let res = response.data this.$toast.open({ message: `Your configuration has been updated.`, type: "success" }) + this.$store.dispatch('setConfiguration', res) }) .catch(({ response }) => { this.$toast.open({ diff --git a/src/views/admin/pos/PointOfSale.vue b/src/views/admin/pos/PointOfSale.vue index 2d271df..f473990 100644 --- a/src/views/admin/pos/PointOfSale.vue +++ b/src/views/admin/pos/PointOfSale.vue @@ -1,10 +1,10 @@