diff --git a/src/api/socket.ts b/src/api/socket.ts
new file mode 100644
index 000000000..b0186667e
--- /dev/null
+++ b/src/api/socket.ts
@@ -0,0 +1,7 @@
+import env from "./index";
+
+const socket = `${env.API_URI}/org-socket`;
+
+export default {
+ socket,
+};
diff --git a/src/app.config.ts b/src/app.config.ts
index 9dd8f3ead..5aa834a1f 100644
--- a/src/app.config.ts
+++ b/src/app.config.ts
@@ -70,6 +70,9 @@ import development from "./api/15_development/api.development";
/** ออกคำสั่งใหม่ */
import command from "./api/18_command/api.command";
+/** socket */
+import socket from "./api/socket";
+
import file from "./api/file/api.file";
// environment variables
@@ -140,6 +143,9 @@ const API = {
/*file*/
...file,
+
+ /*socket*/
+ ...socket,
};
const path = import.meta.env.VITE_MANUAL_URL ?? "";
diff --git a/src/stores/socket.ts b/src/stores/socket.ts
new file mode 100644
index 000000000..bf77d30f1
--- /dev/null
+++ b/src/stores/socket.ts
@@ -0,0 +1,48 @@
+import { defineStore } from "pinia";
+import { Notify } from "quasar";
+
+import { io, Socket } from "socket.io-client";
+
+import config from "@/app.config";
+import { getToken } from "@/plugins/auth";
+
+interface sockeBackup {
+ message: string;
+ success?: boolean;
+}
+
+export const useSocketStore = defineStore("socket", () => {
+ let socket: Socket;
+
+ async function init() {
+ socket = io(new URL(config.API.socket).origin, {
+ auth: { token: await getToken() },
+ path: "/api/v1/org-socket",
+ });
+ socket.on("send-command-notification", (payload) => {
+ let body: sockeBackup = JSON.parse(payload);
+ notifyStatus(body.message, body.success);
+ });
+ }
+
+ function notifyStatus(message: string, success?: boolean) {
+ Notify.create({
+ group: false,
+ type: success === undefined || success ? "positive" : "negative",
+ message: `${message}`,
+ position: "top",
+ timeout: 0,
+ actions: [
+ {
+ icon: "close",
+ color: "white",
+ round: true,
+ },
+ ],
+ });
+ }
+
+ init();
+
+ return {};
+});