Some changes
This commit is contained in:
@@ -88,8 +88,8 @@ function setConfirmationModal(event : Event) {
|
|||||||
v-bind:dark = "isDarkTheme"/>
|
v-bind:dark = "isDarkTheme"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<button class="button is-info mt-5">Submit</button>
|
<button class="button is-info mt-5">Zapisz</button>
|
||||||
<button class="button is-info mt-5 ml-3" @click="setConfirmationModal">Potwierdź</button>
|
<button class="button is-success mt-5 ml-3" @click="setConfirmationModal">Potwierdź</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-for="category in categories" :key="category.Kod">
|
<div v-for="category in categories" :key="category.Kod">
|
||||||
@@ -105,6 +105,7 @@ function setConfirmationModal(event : Event) {
|
|||||||
type="text"
|
type="text"
|
||||||
placeholder="Kwota"
|
placeholder="Kwota"
|
||||||
v-model="product.Twr_Cena"
|
v-model="product.Twr_Cena"
|
||||||
|
v-bind:class="{ 'is-success has-background-light': product.Quantity != undefined && product.Quantity as unknown as string != '' }"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -115,20 +116,21 @@ function setConfirmationModal(event : Event) {
|
|||||||
type="text"
|
type="text"
|
||||||
placeholder="Kwota"
|
placeholder="Kwota"
|
||||||
v-model="product.Twr_CenaZ"
|
v-model="product.Twr_CenaZ"
|
||||||
|
v-bind:class="{ 'is-success has-background-light': product.Quantity != undefined && product.Quantity as unknown as string != '' }"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<div class="field has-addons">
|
<div class="field has-addons">
|
||||||
<p class="control">
|
<p class="control">
|
||||||
<span class="select is-small">
|
<span class="select is-small" v-bind:class="{ 'is-success has-background-light': product.Quantity != undefined }">
|
||||||
<select v-model="product.ChosenOption" readonly>
|
<select v-model="product.ChosenOption" readonly>
|
||||||
<option v-for="option in product.Options" :key="option">{{ option }}</option>
|
<option v-for="option in product.Options" :key="option">{{ option }}</option>
|
||||||
</select>
|
</select>
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
<p class="control is-expanded">
|
<p class="control is-expanded">
|
||||||
<input class="input is-small" type="text" placeholder="Ilość" v-model="product.Quantity">
|
<input class="input is-small" type="text" placeholder="Ilość" v-model="product.Quantity" v-bind:class="{ 'is-success': product.Quantity != undefined }">
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -139,10 +141,10 @@ function setConfirmationModal(event : Event) {
|
|||||||
</div>
|
</div>
|
||||||
<div class="columns mt-1 is-variable is-mobile">
|
<div class="columns mt-1 is-variable is-mobile">
|
||||||
<div class = "column is-6">
|
<div class = "column is-6">
|
||||||
<button class="button is-info is-fullwidth is-large">Submit</button>
|
<button class="button is-info is-fullwidth is-large">Zapisz</button>
|
||||||
</div>
|
</div>
|
||||||
<div class = "is-large column is-6 ml-3">
|
<div class = "is-large column is-6 ml-3">
|
||||||
<button class="button is-info is-fullwidth is-large" @click="showConfirmationModal = true">Potwierdź</button>
|
<button class="button is-success is-fullwidth is-large" @click="showConfirmationModal = true">Potwierdź</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { useOrdersStore } from '@/stores/orders.store'
|
|||||||
import { useContractorsStore } from '@/stores/contractors.store'
|
import { useContractorsStore } from '@/stores/contractors.store'
|
||||||
import { useCategoriesStore } from '@/stores/categories.store'
|
import { useCategoriesStore } from '@/stores/categories.store'
|
||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
|
import { useUserStore } from '@/stores/user.store'
|
||||||
|
|
||||||
const activator = ref(false);
|
const activator = ref(false);
|
||||||
|
|
||||||
@@ -13,6 +14,9 @@ const siteControlStore = useSiteControlStore();
|
|||||||
const ordersStore = useOrdersStore();
|
const ordersStore = useOrdersStore();
|
||||||
const contractorsStore = useContractorsStore();
|
const contractorsStore = useContractorsStore();
|
||||||
const categoriesStore = useCategoriesStore();
|
const categoriesStore = useCategoriesStore();
|
||||||
|
const userStore = useUserStore();
|
||||||
|
|
||||||
|
const { username } = storeToRefs(userStore);
|
||||||
|
|
||||||
|
|
||||||
function makeBurger() {
|
function makeBurger() {
|
||||||
@@ -83,9 +87,12 @@ function newOrder() {
|
|||||||
<button class="button is-info" @click="newOrder">
|
<button class="button is-info" @click="newOrder">
|
||||||
Nowe Zamówienie
|
Nowe Zamówienie
|
||||||
</button>
|
</button>
|
||||||
<button class="button is-light" @click="routeLogin">
|
<button class="button is-light" @click="routeLogin" v-if="username == undefined">
|
||||||
Log in
|
Log in
|
||||||
</button>
|
</button>
|
||||||
|
<button class="button is-light is-static" @click="routeLogin" v-if="username != undefined">
|
||||||
|
{{ username }}
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ const searchOrderDate = ref<Date>();
|
|||||||
const isOutOfBuffer = ref<boolean>(false);
|
const isOutOfBuffer = ref<boolean>(false);
|
||||||
const isInBufor = ref<boolean>(false);
|
const isInBufor = ref<boolean>(false);
|
||||||
const { orders } = storeToRefs(ordersStore);
|
const { orders } = storeToRefs(ordersStore);
|
||||||
|
const areOrdersLoading = ref<boolean>(false);
|
||||||
|
|
||||||
watch(isInBufor, (val) => {
|
watch(isInBufor, (val) => {
|
||||||
if(val && val == isOutOfBuffer.value) {
|
if(val && val == isOutOfBuffer.value) {
|
||||||
@@ -34,11 +35,13 @@ function viewOrder(uuid : string) {
|
|||||||
|
|
||||||
async function fetchOrders(event : Event) {
|
async function fetchOrders(event : Event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
areOrdersLoading.value = true;
|
||||||
if(isInBufor.value) {
|
if(isInBufor.value) {
|
||||||
orders.value = await ordersStore.fetchOrdersInBuffer();
|
orders.value = await ordersStore.fetchOrdersInBuffer();
|
||||||
} else if (isOutOfBuffer.value) {
|
} else if (isOutOfBuffer.value) {
|
||||||
orders.value = await ordersStore.fetchOrdersOutOfBuffer();
|
orders.value = await ordersStore.fetchOrdersOutOfBuffer();
|
||||||
}
|
}
|
||||||
|
areOrdersLoading.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
@@ -70,7 +73,7 @@ async function fetchOrders(event : Event) {
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<button class="button is-primary is-small is-expanded" @click="fetchOrders">Pobierz zamówienia</button>
|
<button class="button is-primary is-small is-expanded" @click="fetchOrders" :class="{ 'is-loading': areOrdersLoading }">Pobierz zamówienia</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<div class="box">
|
<div class="box">
|
||||||
|
|||||||
13
src/main.ts
13
src/main.ts
@@ -10,13 +10,14 @@ import ConfirmedForm from '@/components/ConfirmedForm.vue'
|
|||||||
import LoadingComponent from '@/components/LoadingComponent.vue'
|
import LoadingComponent from '@/components/LoadingComponent.vue'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import LoginModal from '@/components/LoginModal.vue'
|
import LoginModal from '@/components/LoginModal.vue'
|
||||||
import { createPinia } from 'pinia'
|
import { createPinia, storeToRefs } from 'pinia'
|
||||||
import VueCookies from 'vue3-cookies'
|
import VueCookies from 'vue3-cookies'
|
||||||
import { router } from '@/router/router'
|
import { router } from '@/router/router'
|
||||||
import { useSiteControlStore } from '@/stores/siteControl.store'
|
import { useSiteControlStore } from '@/stores/siteControl.store'
|
||||||
import { useCategoriesStore } from '@/stores/categories.store'
|
import { useCategoriesStore } from '@/stores/categories.store'
|
||||||
import { useOrdersStore } from '@/stores/orders.store'
|
import { useOrdersStore } from '@/stores/orders.store'
|
||||||
import { useContractorsStore } from '@/stores/contractors.store'
|
import { useContractorsStore } from '@/stores/contractors.store'
|
||||||
|
import { useUserStore } from '@/stores/user.store'
|
||||||
|
|
||||||
const app = createApp(App);
|
const app = createApp(App);
|
||||||
const pinia = createPinia();
|
const pinia = createPinia();
|
||||||
@@ -34,6 +35,16 @@ export const axiosInstance = axios.create({
|
|||||||
withCredentials: true
|
withCredentials: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
axiosInstance.interceptors.response.use( (response) => {
|
||||||
|
return response;
|
||||||
|
}, (error) => {
|
||||||
|
if (error.response.status == 401) {
|
||||||
|
const userStore = useUserStore();
|
||||||
|
storeToRefs(userStore).username.value = undefined;
|
||||||
|
router.push('/login');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
app.component('VueDatePicker', VueDatePicker);
|
app.component('VueDatePicker', VueDatePicker);
|
||||||
app.component('ConfirmationModal', ConfirmationModal);
|
app.component('ConfirmationModal', ConfirmationModal);
|
||||||
app.component('LoginModal', LoginModal);
|
app.component('LoginModal', LoginModal);
|
||||||
|
|||||||
9
src/stores/user.store.ts
Normal file
9
src/stores/user.store.ts
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import { defineStore } from 'pinia'
|
||||||
|
import { ref } from 'vue'
|
||||||
|
|
||||||
|
|
||||||
|
export const useUserStore = defineStore('user', () => {
|
||||||
|
const username = ref<string>();
|
||||||
|
|
||||||
|
return {username};
|
||||||
|
})
|
||||||
@@ -3,6 +3,8 @@ import { Form, Field } from 'vee-validate';
|
|||||||
import * as Yup from 'yup';
|
import * as Yup from 'yup';
|
||||||
import { axiosInstance } from '@/main'
|
import { axiosInstance } from '@/main'
|
||||||
import { router } from '@/router/router'
|
import { router } from '@/router/router'
|
||||||
|
import { useUserStore } from '@/stores/user.store'
|
||||||
|
import { storeToRefs } from 'pinia'
|
||||||
|
|
||||||
const schema = Yup.object().shape({
|
const schema = Yup.object().shape({
|
||||||
username: Yup.string().required('Nazwa użytkownika jest wymagana'),
|
username: Yup.string().required('Nazwa użytkownika jest wymagana'),
|
||||||
@@ -25,6 +27,8 @@ async function onSubmit(values : any, { setErrors } : any) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
if(body != undefined && body.status == 200) {
|
if(body != undefined && body.status == 200) {
|
||||||
|
const userStore = useUserStore();
|
||||||
|
localStorage.setItem("username", username);
|
||||||
await router.push('/');
|
await router.push('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,22 +24,28 @@ import { storeToRefs } from 'pinia'
|
|||||||
import { useCategoriesStore } from '@/stores/categories.store'
|
import { useCategoriesStore } from '@/stores/categories.store'
|
||||||
import { useOrdersStore } from '@/stores/orders.store'
|
import { useOrdersStore } from '@/stores/orders.store'
|
||||||
import { useSiteControlStore } from '@/stores/siteControl.store'
|
import { useSiteControlStore } from '@/stores/siteControl.store'
|
||||||
|
import { useUserStore } from '@/stores/user.store'
|
||||||
|
|
||||||
const contractorsStore = useContractorsStore();
|
const contractorsStore = useContractorsStore();
|
||||||
const categoriesStore = useCategoriesStore();
|
const categoriesStore = useCategoriesStore();
|
||||||
const ordersStore = useOrdersStore();
|
const ordersStore = useOrdersStore();
|
||||||
const siteControlStore = useSiteControlStore();
|
const siteControlStore = useSiteControlStore();
|
||||||
|
const userStore = useUserStore();
|
||||||
const contractors = storeToRefs(contractorsStore).contractors;
|
const contractors = storeToRefs(contractorsStore).contractors;
|
||||||
const contractor = storeToRefs(contractorsStore).contractor;
|
const contractor = storeToRefs(contractorsStore).contractor;
|
||||||
const categories = storeToRefs(categoriesStore).categories;
|
const categories = storeToRefs(categoriesStore).categories;
|
||||||
|
|
||||||
const { uuid, order } = storeToRefs(ordersStore);
|
const { uuid, order } = storeToRefs(ordersStore);
|
||||||
|
const { username } = storeToRefs(userStore);
|
||||||
const { isForm, isOrders, showConfirmationModal, isLoading } = storeToRefs(siteControlStore);
|
const { isForm, isOrders, showConfirmationModal, isLoading } = storeToRefs(siteControlStore);
|
||||||
|
|
||||||
|
|
||||||
async function fetchData() {
|
async function fetchData() {
|
||||||
await categoriesStore.fetchCategories();
|
await categoriesStore.fetchCategories();
|
||||||
await contractorsStore.fetchContractors();
|
await contractorsStore.fetchContractors();
|
||||||
|
const usernameString = localStorage.getItem("username");
|
||||||
|
if(usernameString != null) {
|
||||||
|
username.value = usernameString;
|
||||||
|
}
|
||||||
isLoading.value = false;
|
isLoading.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user