tambah menu sideBarMenu , middleware definepagemeta
This commit is contained in:
No files matched your search
@@ -0,0 +1,51 @@
|
||||
import { defineStore } from 'pinia';
|
||||
// project imports
|
||||
import axios from '@/utils/axios';
|
||||
import type { blogpostType } from '@/types/apps/BlogTypes';
|
||||
|
||||
interface blogTypeDe {
|
||||
blogposts: blogpostType[];
|
||||
recentPosts: blogpostType[];
|
||||
blogSearch: string;
|
||||
sortBy: string;
|
||||
selectedPost: blogpostType[] | any;
|
||||
}
|
||||
|
||||
export const useBlogStore = defineStore({
|
||||
id: 'blog',
|
||||
|
||||
state: (): blogTypeDe => ({
|
||||
blogposts: [],
|
||||
recentPosts: [],
|
||||
blogSearch: '',
|
||||
sortBy: 'newest',
|
||||
selectedPost: []
|
||||
}),
|
||||
getters: {
|
||||
// Get Post from Getters
|
||||
getPosts(state) {
|
||||
return state.blogposts;
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
// Fetch Blog from action
|
||||
async fetchPosts() {
|
||||
try {
|
||||
const data = await axios.get('/api/data/blog/BlogPosts');
|
||||
this.blogposts = data.data;
|
||||
} catch (error) {
|
||||
alert(error);
|
||||
console.log(error);
|
||||
}
|
||||
},
|
||||
async fetchPost(title: string) {
|
||||
try {
|
||||
const response = await axios.post('/api/data/blog/post', { title });
|
||||
this.selectedPost = response.data.post;
|
||||
} catch (error) {
|
||||
alert(error);
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,59 @@
|
||||
import { defineStore } from 'pinia';
|
||||
// project imports
|
||||
import axios from '@/utils/axios';
|
||||
import { uniqueId } from 'lodash';
|
||||
import { sub } from 'date-fns';
|
||||
|
||||
interface chatType {
|
||||
chats: any;
|
||||
chatContent: any;
|
||||
}
|
||||
|
||||
export const useChatStore = defineStore({
|
||||
id: 'chat',
|
||||
state: (): chatType => ({
|
||||
chats: [],
|
||||
chatContent: 1
|
||||
}),
|
||||
getters: {
|
||||
// Get Chats from Getters
|
||||
// getChats(state) {
|
||||
// return state.chats;
|
||||
// }
|
||||
},
|
||||
actions: {
|
||||
// Fetch Chat from action
|
||||
async fetchChats() {
|
||||
try {
|
||||
const data = await axios.get('/api/data/chat/ChatData');
|
||||
this.chats = data.data;
|
||||
} catch (error) {
|
||||
alert(error);
|
||||
console.log(error);
|
||||
}
|
||||
},
|
||||
//select chat
|
||||
SelectChat(itemID: number) {
|
||||
this.chatContent = itemID;
|
||||
},
|
||||
sendMsg(itemID: number, item: string) {
|
||||
const newMessage = {
|
||||
id: itemID,
|
||||
msg: item,
|
||||
type: 'text',
|
||||
attachments: [],
|
||||
createdAt: sub(new Date(), { seconds: 1 }),
|
||||
senderId: itemID
|
||||
};
|
||||
|
||||
this.chats = this.chats.filter((chat: any) => {
|
||||
return chat.id === itemID
|
||||
? {
|
||||
...chat,
|
||||
...chat.chatHistory.push(newMessage)
|
||||
}
|
||||
: chat;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,23 @@
|
||||
import { defineStore } from 'pinia';
|
||||
// project imports
|
||||
import axios from '@/utils/axios';
|
||||
|
||||
export const useContactStore = defineStore({
|
||||
id: 'Contact',
|
||||
state: () => ({
|
||||
contacts: []
|
||||
}),
|
||||
getters: {},
|
||||
actions: {
|
||||
// Fetch followers from action
|
||||
async fetchContacts() {
|
||||
try {
|
||||
const response = await axios.get('/api/contacts');
|
||||
this.contacts = response.data.contacts;
|
||||
} catch (error) {
|
||||
alert(error);
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,122 @@
|
||||
import { defineStore } from 'pinia';
|
||||
// project imports
|
||||
import axios from '@/utils/axios';
|
||||
// types
|
||||
import type { ProductStateProps } from '@/types/apps/EcommerceType';
|
||||
import { filter, map, sum } from 'lodash';
|
||||
|
||||
export const useEcomStore = defineStore({
|
||||
id: 'eCommerceone',
|
||||
state: (): ProductStateProps => ({
|
||||
products: [],
|
||||
cart: [],
|
||||
gender: '',
|
||||
category: [],
|
||||
price: '',
|
||||
subTotal: 0,
|
||||
discount: 5,
|
||||
total: 0,
|
||||
addresses: [],
|
||||
color: 'All',
|
||||
}),
|
||||
getters: {},
|
||||
actions: {
|
||||
// Fetch Customers from action
|
||||
async fetchProducts() {
|
||||
try {
|
||||
const data = await axios.get('/api/products/list');
|
||||
this.products = data.data;
|
||||
} catch (error) {
|
||||
alert(error);
|
||||
console.log(error);
|
||||
}
|
||||
},
|
||||
// Fetch Customers from addresses
|
||||
async fetchAddress() {
|
||||
try {
|
||||
const data = await axios.get('/api/address/list');
|
||||
this.addresses = data.data;
|
||||
} catch (error) {
|
||||
alert(error);
|
||||
console.log(error);
|
||||
}
|
||||
},
|
||||
//select gender
|
||||
SelectGender(items: any) {
|
||||
this.gender = items;
|
||||
},
|
||||
sortByColor(itemcolor: string) {
|
||||
this.color = itemcolor;
|
||||
},
|
||||
//select category
|
||||
SelectCategory(items: any) {
|
||||
this.category = items;
|
||||
},
|
||||
//select Price
|
||||
SelectPrice(items: any) {
|
||||
this.price = items;
|
||||
},
|
||||
//AddToCart
|
||||
AddToCart(item: any) {
|
||||
const product = item;
|
||||
this.cart = [...this.cart, product];
|
||||
},
|
||||
//qty
|
||||
incrementQty(item: any) {
|
||||
const productId = item;
|
||||
const updateCart = map(this.cart, (product: any) => {
|
||||
if (product.id === productId) {
|
||||
return {
|
||||
...product,
|
||||
qty: product.qty + 1
|
||||
};
|
||||
}
|
||||
return product;
|
||||
});
|
||||
this.cart = updateCart;
|
||||
this.subTotal = sum(this.cart.map((product: any) => product.salePrice * product.qty));
|
||||
this.discount = Math.round(this.subTotal * (5 / 100));
|
||||
this.total = this.subTotal - this.discount;
|
||||
},
|
||||
//qty
|
||||
decrementQty(item: any) {
|
||||
const productId = item;
|
||||
const updateCart = map(this.cart, (product: any) => {
|
||||
if (product.id === productId) {
|
||||
return {
|
||||
...product,
|
||||
qty: product.qty - 1
|
||||
};
|
||||
}
|
||||
return product;
|
||||
});
|
||||
this.cart = updateCart;
|
||||
this.subTotal = sum(this.cart.map((product: any) => product.salePrice * product.qty));
|
||||
this.subTotal = sum(this.cart.map((product: any) => product.salePrice * product.qty));
|
||||
this.discount = Math.round(this.subTotal * (5 / 100));
|
||||
this.total = this.subTotal - this.discount;
|
||||
},
|
||||
// delete Cart
|
||||
deleteCart(item: any) {
|
||||
const updateCart = filter(this.cart, (p) => p.id !== item);
|
||||
this.cart = updateCart;
|
||||
},
|
||||
//subtotal
|
||||
getsubTotal() {
|
||||
this.subTotal = sum(this.cart.map((product: any) => product.salePrice * product.qty));
|
||||
},
|
||||
//total
|
||||
getTotal() {
|
||||
this.total = this.subTotal - this.discount;
|
||||
},
|
||||
//discount
|
||||
getDiscount() {
|
||||
this.discount = Math.round(this.subTotal * (5 / 100));
|
||||
},
|
||||
|
||||
//Reset Filter
|
||||
filterReset(){}
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,49 @@
|
||||
import { defineStore } from "pinia";
|
||||
import axios from "@/utils/axios";
|
||||
import { uniqueId } from "lodash";
|
||||
import { sub } from "date-fns";
|
||||
|
||||
interface EmailType {
|
||||
emails: any[];
|
||||
selectedEmail: any | null; // Add this line to hold the selected email
|
||||
}
|
||||
|
||||
export const useEmailStore = defineStore({
|
||||
id: "email",
|
||||
state: (): EmailType => ({
|
||||
emails: [],
|
||||
selectedEmail: null, // Initialize as null
|
||||
}),
|
||||
actions: {
|
||||
toggleStarred(emailId: number) {
|
||||
const email = this.emails.find((e) => e.id === emailId);
|
||||
if (email) {
|
||||
email.starred = !email.starred;
|
||||
}
|
||||
},
|
||||
toggleImportant(emailId: number) {
|
||||
const email = this.emails.find((e) => e.id === emailId);
|
||||
if (email) {
|
||||
email.important = !email.important;
|
||||
}
|
||||
},
|
||||
async fetchEmails() {
|
||||
try {
|
||||
const data = await axios.get("/api/data/email/EmailData");
|
||||
this.emails = data.data;
|
||||
} catch (error) {
|
||||
alert(error);
|
||||
console.log(error);
|
||||
}
|
||||
},
|
||||
selectEmail(email: any) {
|
||||
// Update the method to accept an email object
|
||||
this.selectedEmail = email; // Store the selected email
|
||||
},
|
||||
deleteEmail(id: number) {
|
||||
this.emails = this.emails.filter((email) => email.id !== id);
|
||||
this.selectedEmail = null; // Clear selected email after deletion
|
||||
},
|
||||
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,69 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import axios from '@/utils/axios';
|
||||
import type { InvoiceType } from '@/types/apps/InvoiceTypes';
|
||||
|
||||
interface InvoiceState {
|
||||
invoice: InvoiceType[];
|
||||
invoiceContent: number;
|
||||
invoiceSearch: string;
|
||||
}
|
||||
|
||||
export const useInvoicestore = defineStore({
|
||||
id: 'invoices',
|
||||
state: (): InvoiceState => ({
|
||||
invoice: [],
|
||||
invoiceContent: 1,
|
||||
invoiceSearch: '',
|
||||
}),
|
||||
getters: {
|
||||
grandTotal: (state) => (invoice: InvoiceType) => {
|
||||
const subtotal = (invoice.orders ?? []).reduce((sum, order) => {
|
||||
return sum + (order.unitPrice ?? 0) * (order.units ?? 0);
|
||||
}, 0);
|
||||
const vatRate = 0.1;
|
||||
const vat = subtotal * vatRate;
|
||||
return subtotal + vat;
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async fetchinvoice() {
|
||||
try {
|
||||
const response = await axios.get('/api/data/invoices/invoiceData');
|
||||
this.invoice = response.data; // Ensure data is structured correctly
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
alert('Failed to fetch invoices');
|
||||
}
|
||||
},
|
||||
async addInvoice(invoice: InvoiceType) {
|
||||
try {
|
||||
const response = await axios.post('/api/data/invoices/invoiceData', invoice);
|
||||
this.invoice.push(response.data);
|
||||
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Error adding invoice:', error);
|
||||
}
|
||||
},
|
||||
async updateInvoice(updatedInvoice: InvoiceType) {
|
||||
try {
|
||||
const response = await axios.put(`/api/data/invoices/invoiceData/${updatedInvoice.id}`, updatedInvoice);
|
||||
console.log('Response from update:', response); // This will show the updated data
|
||||
|
||||
const index = this.invoice.findIndex(inv => inv.id === updatedInvoice.id);
|
||||
if (index !== -1) {
|
||||
this.invoice[index] = response.data; // Update the local store
|
||||
}
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Error updating invoice:', error);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
deleteinvoice(itemID: number) {
|
||||
this.invoice = this.invoice.filter((invoice) => invoice.id !== itemID);
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,82 @@
|
||||
import { defineStore } from 'pinia';
|
||||
// project imports
|
||||
import axios from '@/utils/axios';
|
||||
import { map } from 'lodash';
|
||||
import { uniqueId } from 'lodash';
|
||||
import { sub } from 'date-fns';
|
||||
import type { Ref } from 'vue';
|
||||
|
||||
|
||||
interface TaskType {
|
||||
id?: string | any;
|
||||
title?: string;
|
||||
subtitle?: string;
|
||||
datef?: Date | any;
|
||||
cardbg?: string;
|
||||
deleted?: boolean;
|
||||
taskimg?: string;
|
||||
date?: Date | any;
|
||||
category?: string;
|
||||
categorybg?: string;
|
||||
tasks?: TaskType[];
|
||||
}
|
||||
|
||||
interface taskType {
|
||||
tasks: TaskType[];
|
||||
taskContent: string;
|
||||
}
|
||||
|
||||
export const useTaskStore = defineStore({
|
||||
id: 'tasks',
|
||||
state: (): taskType => ({
|
||||
tasks: [],
|
||||
taskContent: '1'
|
||||
}),
|
||||
actions: {
|
||||
// Fetch tasks
|
||||
async fetchTasks() {
|
||||
try {
|
||||
const data = await axios.get('/api/data/task/TaskData');
|
||||
this.tasks = data.data;
|
||||
} catch (error) {
|
||||
alert(error);
|
||||
console.log(error);
|
||||
}
|
||||
},
|
||||
|
||||
//select chat
|
||||
SelectTask(itemID: string) {
|
||||
this.taskContent = itemID;
|
||||
},
|
||||
|
||||
deleteTask(itemID: string) {
|
||||
const taskObj = this.tasks.map((task) => {
|
||||
const tasks = task.tasks?.filter((t) => t.id !== itemID);
|
||||
return {
|
||||
...task,
|
||||
tasks
|
||||
};
|
||||
});
|
||||
this.tasks = taskObj;
|
||||
},
|
||||
addTask(columnId:string, title:string, subtitle:string, category:string, categorybg:string) {
|
||||
const newTask = {
|
||||
id: uniqueId('#task_'),
|
||||
title: title,
|
||||
subtitle: subtitle,
|
||||
category:category,
|
||||
date: sub(new Date(), { seconds: 1 }),
|
||||
categorybg:categorybg
|
||||
};
|
||||
this.tasks = map(this.tasks, (task: any) => {
|
||||
if (task.id === columnId) {
|
||||
return {
|
||||
...task,
|
||||
...task.tasks.push(newTask)
|
||||
};
|
||||
}
|
||||
return task;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,60 @@
|
||||
import { defineStore } from 'pinia';
|
||||
// project imports
|
||||
import axios from '@/utils/axios';
|
||||
import { map } from 'lodash';
|
||||
|
||||
interface NotesType {
|
||||
id?: number | any;
|
||||
color?: string;
|
||||
title?: string;
|
||||
datef?: Date | any;
|
||||
deleted?: boolean;
|
||||
}
|
||||
|
||||
interface noteType {
|
||||
notes: NotesType[];
|
||||
notesContent: number;
|
||||
noteSearch: string;
|
||||
}
|
||||
|
||||
export const useNoteStore = defineStore({
|
||||
id: 'notes',
|
||||
state: (): noteType => ({
|
||||
notes: [],
|
||||
notesContent: 1,
|
||||
noteSearch: ''
|
||||
}),
|
||||
actions: {
|
||||
// Fetch notes
|
||||
async fetchNotes() {
|
||||
try {
|
||||
const data = await axios.get('/api/data/notes/NotesData');
|
||||
this.notes = data.data;
|
||||
} catch (error) {
|
||||
alert(error);
|
||||
console.log(error);
|
||||
}
|
||||
},
|
||||
|
||||
//select chat
|
||||
SelectNote(itemID: number) {
|
||||
this.notesContent = itemID;
|
||||
},
|
||||
|
||||
deleteNote(itemID: number) {
|
||||
const index = this.notes.findIndex((p) => p.id == itemID);
|
||||
this.notes.splice(index, 1);
|
||||
},
|
||||
updateNote(itemID: number, itemColor: any) {
|
||||
this.notes = map(this.notes, (note: any) => {
|
||||
if (note.id === itemID) {
|
||||
return {
|
||||
...note,
|
||||
color: itemColor
|
||||
};
|
||||
}
|
||||
return note;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,62 @@
|
||||
import { defineStore } from 'pinia';
|
||||
// project imports
|
||||
import axios from '@/utils/axios';
|
||||
import { map } from 'lodash';
|
||||
|
||||
interface TicketType {
|
||||
Id?: number | any;
|
||||
ticketTitle?: string;
|
||||
ticketDescription?: string;
|
||||
Status?: string;
|
||||
Label?:string;
|
||||
thumb?:string;
|
||||
AgentName?:string;
|
||||
Date?: string | Date;
|
||||
}
|
||||
|
||||
interface ticketType {
|
||||
ticket: TicketType[];
|
||||
ticketContent: number;
|
||||
ticketearch: string;
|
||||
}
|
||||
|
||||
export const useTicketstore = defineStore({
|
||||
id: 'tickets',
|
||||
state: (): ticketType => ({
|
||||
ticket: [],
|
||||
ticketContent: 1,
|
||||
ticketearch: ''
|
||||
}),
|
||||
actions: {
|
||||
// Fetch ticket
|
||||
async fetchTicket() {
|
||||
try {
|
||||
const data = await axios.get('/api/data/tickets/TicketData');
|
||||
this.ticket = data.data;
|
||||
console.log(data);
|
||||
} catch (error) {
|
||||
alert(error);
|
||||
console.log(error);
|
||||
}
|
||||
},
|
||||
|
||||
//select chat
|
||||
SelectTicket(itemID: number) {
|
||||
this.ticketContent = itemID;
|
||||
},
|
||||
|
||||
|
||||
deleteTicket(itemID: number) {
|
||||
const index = this.ticket.findIndex((p) => p.Id == itemID);
|
||||
if (index !== -1) {
|
||||
this.ticket = [...this.ticket.slice(0, index), ...this.ticket.slice(index + 1)];
|
||||
}
|
||||
},
|
||||
// Add new ticket
|
||||
addTicket(newTicket: TicketType) {
|
||||
// You might want to assign an Id based on the current length or other logic
|
||||
newTicket.Id = this.ticket.length > 0 ? Math.max(...this.ticket.map(t => t.Id)) + 1 : 1; // Auto-increment Id
|
||||
this.ticket.push(newTicket);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,23 @@
|
||||
import { defineStore } from 'pinia';
|
||||
// project imports
|
||||
import axios from '@/utils/axios';
|
||||
|
||||
export const useFollowersStore = defineStore({
|
||||
id: 'followers',
|
||||
state: () => ({
|
||||
followers: []
|
||||
}),
|
||||
getters: {},
|
||||
actions: {
|
||||
// Fetch followers from action
|
||||
async fetchFollowers() {
|
||||
try {
|
||||
const response = await axios.get('/api/followers/list');
|
||||
this.followers = response.data.followers;
|
||||
} catch (error) {
|
||||
alert(error);
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,23 @@
|
||||
import { defineStore } from 'pinia';
|
||||
// project imports
|
||||
import axios from '@/utils/axios';
|
||||
|
||||
export const useFrinedsStore = defineStore({
|
||||
id: 'Frineds',
|
||||
state: () => ({
|
||||
friends: []
|
||||
}),
|
||||
getters: {},
|
||||
actions: {
|
||||
// Fetch followers from action
|
||||
async fetchFrineds() {
|
||||
try {
|
||||
const response = await axios.get('/api/friends/list');
|
||||
this.friends = response.data.friends;
|
||||
} catch (error) {
|
||||
alert(error);
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,23 @@
|
||||
import { defineStore } from 'pinia';
|
||||
// project imports
|
||||
import axios from '@/utils/axios';
|
||||
|
||||
export const useGalleryStore = defineStore({
|
||||
id: 'Gallery',
|
||||
state: () => ({
|
||||
gallery: []
|
||||
}),
|
||||
getters: {},
|
||||
actions: {
|
||||
// Fetch followers from action
|
||||
async fetchGallery() {
|
||||
try {
|
||||
const response = await axios.get('/api/gallery/list');
|
||||
this.gallery = response.data.gallery;
|
||||
} catch (error) {
|
||||
alert(error);
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,23 @@
|
||||
import { defineStore } from 'pinia';
|
||||
// project imports
|
||||
import axios from '@/utils/axios';
|
||||
|
||||
export const usePhotosStore = defineStore({
|
||||
id: 'Photos',
|
||||
state: () => ({
|
||||
photos: []
|
||||
}),
|
||||
getters: {},
|
||||
actions: {
|
||||
// Fetch followers from action
|
||||
async fetchPhotos() {
|
||||
try {
|
||||
const response = await axios.get('/api/photos');
|
||||
this.photos = response.data.photos;
|
||||
} catch (error) {
|
||||
alert(error);
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,54 @@
|
||||
import { defineStore } from 'pinia';
|
||||
// project imports
|
||||
import axios from '@/utils/axios';
|
||||
import type { Reply } from '@/types/apps/PostType';
|
||||
|
||||
export const usePostsStore = defineStore({
|
||||
id: 'post',
|
||||
state: () => ({
|
||||
posts: []
|
||||
}),
|
||||
getters: {},
|
||||
actions: {
|
||||
// Fetch Posts from action
|
||||
async fetchPosts() {
|
||||
try {
|
||||
const response = await axios.get('/api/posts/list');
|
||||
this.posts = response.data;
|
||||
} catch (error) {
|
||||
alert(error);
|
||||
console.log(error);
|
||||
}
|
||||
},
|
||||
// like post
|
||||
async likePost(postId: string) {
|
||||
try {
|
||||
const response = await axios.post('/api/posts/list/like', { postId });
|
||||
this.posts = response.data.posts;
|
||||
} catch (error) {
|
||||
alert(error);
|
||||
console.log(error);
|
||||
}
|
||||
},
|
||||
// add Comment
|
||||
async addComment(postId: string, comment: Reply) {
|
||||
try {
|
||||
const response = await axios.post('/api/comments/add', { postId, comment });
|
||||
this.posts = response.data.posts;
|
||||
} catch (error) {
|
||||
alert(error);
|
||||
console.log(error);
|
||||
}
|
||||
},
|
||||
// add Comment
|
||||
async addReply(postId: string, commentId: string, reply: Reply) {
|
||||
try {
|
||||
const response = await axios.post('/api/replies/add', { postId, commentId, reply });
|
||||
this.posts = response.data.posts;
|
||||
} catch (error) {
|
||||
alert(error);
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user