add averias

This commit is contained in:
John Galt 2024-11-10 20:32:26 +01:00
parent 42f5e89241
commit 48c7b0fe56
6 changed files with 41 additions and 41 deletions

View File

@ -1,7 +1,7 @@
<script setup> <script setup>
import MainSideNav from '@/components/SideBar/MainSideNav.vue'; import MainSideNav from '@/components/SideBar/MainSideNav.vue';
import Header from '@/components/Header/Header.vue'; import Header from '@/components/Header/Header.vue';
import Employees from './Employee/Employees/Employees.vue' // import Employees from './Employee/Employees/Employees.vue'
import { RouterView,useRouter } from 'vue-router'; import { RouterView,useRouter } from 'vue-router';
import Authenticate from '@/Store/Authenticate'; import Authenticate from '@/Store/Authenticate';

View File

@ -1,11 +1,11 @@
<script setup> <script setup>
import BreadCrumb from "../../../components/BreadCrumb/BreadCrumb.vue"; import BreadCrumb from "../../../../components/BreadCrumb/BreadCrumb.vue";
import EmployeeService from "../../../Services/Employee/EmployeeService"; import EmployeeService from "../../../../Services/Employee/EmployeeService";
import { useToast } from "vue-toastification"; import { useToast } from "vue-toastification";
import { useRouter } from "vue-router"; import { useRouter } from "vue-router";
import { ref } from "vue"; import { ref } from "vue";
import { Form, Field } from "vee-validate"; import { Form, Field } from "vee-validate";
import EmpYup from "../../../Validation/EmpYup/EmpYup"; import EmpYup from "../../../../Validation/EmpYup/EmpYup";
const router = useRouter(); const router = useRouter();
const loading = ref(false); const loading = ref(false);

View File

@ -1,9 +1,9 @@
<script setup> <script setup>
import BreadCrumb from '../../../components/BreadCrumb/BreadCrumb.vue' import BreadCrumb from '../../../../components/BreadCrumb/BreadCrumb.vue'
import EmployeeItem from './EmployeeItem/EmployeeItem.vue'; import AveriaItem from '../Averias/AveriasItem/AveriaItem.vue';
import Paginator from '../../../components/Paginator/Paginator.vue' import Paginator from '../../../../components/Paginator/Paginator.vue'
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
import EmployeeService from '@/Services/Employee/EmployeeService'; import AveriaService from '@/Services/Averia/AveriaService';
import { computed, onBeforeMount, onMounted, ref } from 'vue'; import { computed, onBeforeMount, onMounted, ref } from 'vue';
import { useToast } from 'vue-toastification'; import { useToast } from 'vue-toastification';
@ -17,7 +17,7 @@ const searchQuery = ref('')
const fetchData = async () => { const fetchData = async () => {
try { try {
loading.value = true loading.value = true
const response = await EmployeeService.getAllEmp() const response = await AveriaService.getAllEmp()
if (response.data.page) { if (response.data.page) {
empCount.value = response.data.totalItems empCount.value = response.data.totalItems
empList.value = response.data.items empList.value = response.data.items
@ -33,7 +33,7 @@ const fetchData = async () => {
const handleEmpDelete = async (empId) => { const handleEmpDelete = async (empId) => {
try { try {
loading.value = true loading.value = true
const response = await EmployeeService.deleteEmp(empId) const response = await AveriaService.deleteEmp(empId)
toast.success('Deleted') toast.success('Deleted')
} catch (error) { } catch (error) {
if (error.response.data.code === 400) { if (error.response.data.code === 400) {
@ -67,7 +67,7 @@ onMounted(() => {
<template> <template>
<main class="main-content-wrapper pt-14"> <main class="main-content-wrapper pt-14">
<div class="container"> <div class="container">
<BreadCrumb :iconName="'fa-user-nurse'" :title="'Employees'" /> <BreadCrumb :iconName="'fa-user-nurse'" :title="'Averias'" />
<div class="row"> <div class="row">
<div class="col-xl-12 col-12 mb-5"> <div class="col-xl-12 col-12 mb-5">
<div class="card h-100 card"> <div class="card h-100 card">
@ -79,12 +79,12 @@ onMounted(() => {
placeholder="Search Seller" aria-label="Search" /> placeholder="Search Seller" aria-label="Search" />
</div> </div>
<div class="d-flex justify-content-start align-items-center" role="search"> <div class="d-flex justify-content-start align-items-center" role="search">
<h4>Employee List</h4> <h4>Averia List</h4>
</div> </div>
</div> </div>
<div class="col-md-6 text-end"> <div class="col-md-6 text-end">
<button @click="router.push('/app/addEmployee')" class='btn btn-dark'>Add <button @click="router.push('/app/addAveria')" class='btn btn-dark'>Add
Employee</button> Averia</button>
</div> </div>
</div> </div>
</div> </div>
@ -96,7 +96,7 @@ onMounted(() => {
<table class="table table-centered table-hover text-nowrap table-borderless mb-0"> <table class="table table-centered table-hover text-nowrap table-borderless mb-0">
<thead class="bg-light"> <thead class="bg-light">
<tr> <tr>
<th>Employee Id</th> <th>Averia Id</th>
<th>Name</th> <th>Name</th>
<th>Email</th> <th>Email</th>
<th>Store Code</th> <th>Store Code</th>
@ -104,7 +104,7 @@ onMounted(() => {
<th></th> <th></th>
</tr> </tr>
</thead> </thead>
<EmployeeItem @deleteEmployee="handleEmpDelete" :empList="empList" /> <AveriaItem @deleteAveria="handleEmpDelete" :empList="empList" />
</table> </table>
</div> </div>
<Paginator :total="+empCount" /> <Paginator :total="+empCount" />

View File

@ -7,10 +7,10 @@ const props = defineProps({
} }
}) })
const emit = defineEmits([ const emit = defineEmits([
'deleteEmployee' 'deleteAveria'
]) ])
const deleteEmp = (id) => { const deleteEmp = (id) => {
emit('deleteEmployee',id) emit('deleteAveria',id)
} }
const router = useRouter() const router = useRouter()
</script> </script>
@ -24,7 +24,7 @@ const router = useRouter()
<td>{{ emp.storecode }}</td> <td>{{ emp.storecode }}</td>
<td>{{ emp.country }}</td> <td>{{ emp.country }}</td>
<td> <td>
<i class="fa-solid fa-pencil text-warning fs-5 mx-10" @click="router.push(`/app/editEmployee/${emp.id}`)" <i class="fa-solid fa-pencil text-warning fs-5 mx-10" @click="router.push(`/app/editAveria/${emp.id}`)"
style="cursor: pointer;" /> style="cursor: pointer;" />
<i @click="deleteEmp(emp.id)" class="fa-solid fa-trash text-danger fs-5" style="cursor: pointer;" /> <i @click="deleteEmp(emp.id)" class="fa-solid fa-trash text-danger fs-5" style="cursor: pointer;" />
</td> </td>

View File

@ -1,7 +1,7 @@
<script setup> <script setup>
import BreadCrumb from '../../../components/BreadCrumb/BreadCrumb.vue'; import BreadCrumb from '../../../../components/BreadCrumb/BreadCrumb.vue';
import { useRoute, useRouter } from 'vue-router'; import { useRoute, useRouter } from 'vue-router';
import EmployeeService from '@/Services/Employee/EmployeeService'; import AveriaService from '@/Services/Averia/AveriaService';
import { useToast } from 'vue-toastification'; import { useToast } from 'vue-toastification';
import { onMounted, ref } from 'vue'; import { onMounted, ref } from 'vue';
import { Form, Field } from 'vee-validate'; import { Form, Field } from 'vee-validate';
@ -22,7 +22,7 @@ const empInit = ref({
const fetchEmpById = async (id) => { const fetchEmpById = async (id) => {
try { try {
loading.value = true loading.value = true
const response = await EmployeeService.getEmpById(id) const response = await AveriaService.getEmpById(id)
if (response.data.id) { if (response.data.id) {
empInit.value.email = response.data.email empInit.value.email = response.data.email
empInit.value.name = response.data.name empInit.value.name = response.data.name
@ -46,11 +46,11 @@ const editEmp = async () => {
storecode: empInit.value.storecode, storecode: empInit.value.storecode,
country: empInit.value.country, country: empInit.value.country,
}; };
const response = await EmployeeService.updateEmp(data,id) const response = await AveriaService.updateEmp(data,id)
if (response.data.id) { if (response.data.id) {
loading.value=false loading.value=false
toast.success("Succesfully Updated"); toast.success("Succesfully Updated");
router.push("/app/employees"); router.push("/app/Averias");
} }
} catch (error) { } catch (error) {
if (error.response.data.code === 400) { if (error.response.data.code === 400) {
@ -74,7 +74,7 @@ onMounted(() => {
<template> <template>
<main className="main-content-wrapper pb-6 px-0 px-md-4 pt-14"> <main className="main-content-wrapper pb-6 px-0 px-md-4 pt-14">
<div className="container"> <div className="container">
<BreadCrumb :title="'Edit Employee'" :iconName="'fa-user-nurse'" /> <BreadCrumb :title="'Edit Averia'" :iconName="'fa-user-nurse'" />
<div className="row"> <div className="row">
<div className="col-md-8 offset-md-2 col-12 mb-5"> <div className="col-md-8 offset-md-2 col-12 mb-5">
<h4 v-if="loading" class="text-center my-4 mb-10" >Fetching Data ....</h4> <h4 v-if="loading" class="text-center my-4 mb-10" >Fetching Data ....</h4>
@ -106,7 +106,7 @@ onMounted(() => {
</div> </div>
<div class="col-12 text-end"> <div class="col-12 text-end">
<button :disabled="loading" type="submit" class="btn btn-primary"> <button :disabled="loading" type="submit" class="btn btn-primary">
Edit Employee Edit Averia
</button> </button>
</div> </div>
</div> </div>

View File

@ -10,9 +10,9 @@ import AddEmployee from '../Pages/AppStack/Employee/AddEmp/AddEmp.vue'
import EditEmployee from '../Pages/AppStack/Employee/EditEmp/EditEmpl.vue' import EditEmployee from '../Pages/AppStack/Employee/EditEmp/EditEmpl.vue'
// import Averias from '@/Pages/AppStack/Averias/Averias.vue' import Averias from '@/Pages/AppStack/Averia/Averias/Averias.vue'
// import AddAveria from '../Pages/AppStack/AddAveria/AddAveria.vue' import AddAveria from '../Pages/AppStack/Averia/AddAveria/AddAveria.vue'
// import EditAveria from '../Pages/AppStack/EditAveria/EditAveria.vue' import EditAveria from '../Pages/AppStack/Averia/EditAveria/EditAveria.vue'
@ -57,20 +57,20 @@ const router = createRouter({
component:EditEmployee component:EditEmployee
}, },
// { {
// path: 'averias', path: 'averias',
// component: Averias component: Averias
// }, },
// { {
// path: 'addAveria', path: 'addAveria',
// component:AddAveria component:AddAveria
// }, },
// { {
// path: 'editAveria/:id', path: 'editAveria/:id',
// component:EditAveria component:EditAveria
// }, },
{ {
path: 'dashboard', path: 'dashboard',
component: '' component: ''