tambah menu sideBarMenu , middleware definepagemeta

This commit is contained in:
2025-07-10 15:06:05 +07:00
parent c37759cc8f
commit a8068553be
40 changed files with 3234 additions and 702 deletions

No files matched your search

+59
View File
@@ -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;
});
}
}
});