@mundogamernetwork/shared-ui 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +283 -0
- package/components/PressKit/AssetGallery.vue +349 -0
- package/components/PressKit/Awards.vue +100 -0
- package/components/PressKit/Credits.vue +78 -0
- package/components/PressKit/FactSheet.vue +204 -0
- package/components/PressKit/Hero.vue +143 -0
- package/components/PressKit/Quotes.vue +80 -0
- package/components/PressKit/VideoPlayer.vue +134 -0
- package/components/checkout/MgCartItemList.vue +214 -0
- package/components/checkout/MgCartSummary.vue +204 -0
- package/components/checkout/MgCheckoutSidebar.vue +230 -0
- package/components/checkout/MgGuestEmailForm.vue +97 -0
- package/components/checkout/MgPaymentMethodSelector.vue +162 -0
- package/components/checkout/MgPixQRCode.vue +222 -0
- package/components/indie-wall/IndieWallLeaderboard.vue +208 -0
- package/components/indie-wall/MuralCanvas.vue +481 -0
- package/components/indie-wall/StepBlock.vue +314 -0
- package/components/indie-wall/StepCustomize.vue +530 -0
- package/components/indie-wall/StepGoal.vue +169 -0
- package/components/indie-wall/StepPackage.vue +145 -0
- package/components/indie-wall/StepPay.vue +209 -0
- package/components/indie-wall/SupportStepper.vue +372 -0
- package/components/invoices/MgInvoiceDownload.vue +50 -0
- package/components/pricing/MgBillingToggle.vue +74 -0
- package/components/pricing/MgPricingCard.vue +245 -0
- package/components/ui/Header/MgMessageCard.vue +147 -0
- package/components/ui/Header/MgMessageModal.vue +414 -0
- package/components/ui/Header/MgNotificationCard.vue +200 -0
- package/components/ui/Header/MgNotificationsModal.vue +125 -0
- package/components/ui/MgAnnouncementBanner.vue +147 -0
- package/components/ui/MgBanners.vue +23 -0
- package/components/ui/MgHeaderComponent.vue +283 -0
- package/components/ui/MgHeaderUIConfig.vue +225 -0
- package/components/ui/MgHeaderUIUser.vue +301 -0
- package/components/ui/MgLoginModal.vue +156 -0
- package/components/ui/MgPromotionBanner.vue +185 -0
- package/composables/useLogout.ts +42 -0
- package/composables/useMgCheckout.ts +287 -0
- package/composables/useMgUserNotifications.ts +122 -0
- package/composables/usePaymentMethods.ts +75 -0
- package/composables/useSubscription.ts +163 -0
- package/middleware/auth.global.ts +40 -0
- package/nuxt.config.ts +31 -0
- package/package.json +40 -0
- package/pages/[slug]/index.vue +112 -0
- package/pages/about.vue +133 -0
- package/pages/blog.vue +430 -0
- package/pages/careers.vue +329 -0
- package/pages/contact.vue +339 -0
- package/pages/faq.vue +317 -0
- package/pages/health-check.vue +20 -0
- package/pages/icons.vue +58 -0
- package/pages/magazine/[slug].vue +209 -0
- package/pages/magazine/index.vue +267 -0
- package/pages/media-kit/[slug].vue +625 -0
- package/pages/mural/[slug].vue +1058 -0
- package/pages/partners.vue +290 -0
- package/pages/press.vue +237 -0
- package/pages/presskit/[slug].vue +191 -0
- package/pages/roadmap.vue +355 -0
- package/pages/status.vue +199 -0
- package/pages/team.vue +266 -0
- package/pages/wall/[slug].vue +11 -0
- package/plugins/auth.client.ts +17 -0
- package/plugins/echo.client.ts +132 -0
- package/services/authService.ts +95 -0
- package/services/chatService.ts +53 -0
- package/services/contactService.ts +35 -0
- package/services/documentService.ts +16 -0
- package/services/httpService.ts +95 -0
- package/services/indieWallService.ts +174 -0
- package/services/institutionalService.ts +248 -0
- package/services/mediaKitService.ts +51 -0
- package/services/notificationsService.ts +20 -0
- package/services/pressKitService.ts +55 -0
- package/stores/announcement.ts +129 -0
- package/stores/auth.ts +86 -0
- package/stores/chat.ts +150 -0
- package/stores/contact.ts +28 -0
- package/stores/document.ts +27 -0
- package/stores/index.ts +34 -0
- package/stores/institutional.ts +231 -0
- package/stores/login.ts +27 -0
- package/stores/notifications.ts +133 -0
- package/stores/promotion.ts +154 -0
- package/types/index.ts +135 -0
- package/utils/serialize.ts +29 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { defineStore } from "pinia";
|
|
2
|
+
|
|
3
|
+
export interface AnnouncementBanner {
|
|
4
|
+
id: number;
|
|
5
|
+
preset_id: number | null;
|
|
6
|
+
preset: { id: number; key: string; text: string } | null;
|
|
7
|
+
/** Resolved message: preset text or custom translatable message */
|
|
8
|
+
message: string;
|
|
9
|
+
link_url: string | null;
|
|
10
|
+
link_text: string | null;
|
|
11
|
+
type: "info" | "warning" | "success" | "danger";
|
|
12
|
+
bg_color: string | null;
|
|
13
|
+
text_color: string | null;
|
|
14
|
+
platform_ids: number[];
|
|
15
|
+
language_id: number | null;
|
|
16
|
+
country_id: number | null;
|
|
17
|
+
is_global: boolean;
|
|
18
|
+
is_active: boolean;
|
|
19
|
+
starts_at: string | null;
|
|
20
|
+
ends_at: string | null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const DISMISSED_PREFIX = "mg_announcement_dismissed_";
|
|
24
|
+
const CACHE_KEY = "mg_announcement_banner_cache";
|
|
25
|
+
const CACHE_TTL_MS = 15 * 60 * 1000; // 15 minutes
|
|
26
|
+
|
|
27
|
+
interface CacheEntry {
|
|
28
|
+
banner: AnnouncementBanner | null;
|
|
29
|
+
cachedAt: number;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function readCache(platformId: number, locale: string): AnnouncementBanner | null | undefined {
|
|
33
|
+
try {
|
|
34
|
+
const raw = localStorage.getItem(`${CACHE_KEY}_${platformId}_${locale}`);
|
|
35
|
+
if (!raw) return undefined;
|
|
36
|
+
const entry: CacheEntry = JSON.parse(raw);
|
|
37
|
+
if (Date.now() - entry.cachedAt > CACHE_TTL_MS) return undefined;
|
|
38
|
+
return entry.banner; // null = cached "no active banner"
|
|
39
|
+
} catch {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function writeCache(platformId: number, locale: string, banner: AnnouncementBanner | null) {
|
|
45
|
+
try {
|
|
46
|
+
const entry: CacheEntry = { banner, cachedAt: Date.now() };
|
|
47
|
+
localStorage.setItem(`${CACHE_KEY}_${platformId}_${locale}`, JSON.stringify(entry));
|
|
48
|
+
} catch {
|
|
49
|
+
// localStorage unavailable or full — silently skip
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export const useAnnouncementStore = defineStore("announcement-store", {
|
|
54
|
+
state: () => ({
|
|
55
|
+
banner: null as AnnouncementBanner | null,
|
|
56
|
+
dismissed: false,
|
|
57
|
+
loaded: false,
|
|
58
|
+
}),
|
|
59
|
+
|
|
60
|
+
actions: {
|
|
61
|
+
async fetchBanner() {
|
|
62
|
+
if (this.loaded) return;
|
|
63
|
+
|
|
64
|
+
const runtimeConfig = useRuntimeConfig();
|
|
65
|
+
const networkBaseUrl =
|
|
66
|
+
runtimeConfig.public.mgSharedUi?.networkBaseUrl ||
|
|
67
|
+
import.meta.env.VITE_BASE_URL_NETWORK;
|
|
68
|
+
const platformId = Number(
|
|
69
|
+
runtimeConfig.public.mgSharedUi?.systemId || import.meta.env.VITE_SYSTEM_ID,
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
if (!networkBaseUrl || !platformId) {
|
|
73
|
+
this.loaded = true;
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const { locale } = useI18n();
|
|
78
|
+
const localeVal = locale.value || "en";
|
|
79
|
+
|
|
80
|
+
// ── Try cache first ────────────────────────────────────────────────
|
|
81
|
+
const cached = readCache(platformId, localeVal);
|
|
82
|
+
if (cached !== undefined) {
|
|
83
|
+
this.banner = cached;
|
|
84
|
+
if (cached) {
|
|
85
|
+
this.dismissed = !!localStorage.getItem(`${DISMISSED_PREFIX}${cached.id}`);
|
|
86
|
+
}
|
|
87
|
+
this.loaded = true;
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// ── Cache miss — fetch from API ────────────────────────────────────
|
|
92
|
+
try {
|
|
93
|
+
const params = new URLSearchParams({ platform_id: String(platformId) });
|
|
94
|
+
params.set("locale", localeVal);
|
|
95
|
+
|
|
96
|
+
const url = `${networkBaseUrl}/announcement-banners/active?${params.toString()}`;
|
|
97
|
+
const data: any = await $fetch(url, { credentials: "include" });
|
|
98
|
+
|
|
99
|
+
const banner: AnnouncementBanner | null = data?.data ?? null;
|
|
100
|
+
this.banner = banner;
|
|
101
|
+
|
|
102
|
+
if (banner) {
|
|
103
|
+
this.dismissed = !!localStorage.getItem(`${DISMISSED_PREFIX}${banner.id}`);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
writeCache(platformId, localeVal, banner);
|
|
107
|
+
} catch {
|
|
108
|
+
// Silently fail — banner is non-critical; do not cache on error
|
|
109
|
+
} finally {
|
|
110
|
+
this.loaded = true;
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
|
|
114
|
+
dismiss() {
|
|
115
|
+
if (this.banner) {
|
|
116
|
+
localStorage.setItem(`${DISMISSED_PREFIX}${this.banner.id}`, "1");
|
|
117
|
+
}
|
|
118
|
+
this.dismissed = true;
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
|
|
122
|
+
getters: {
|
|
123
|
+
isVisible: (state) => !!state.banner && !state.dismissed,
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
if (import.meta.hot) {
|
|
128
|
+
import.meta.hot.accept(acceptHMRUpdate(useAnnouncementStore, import.meta.hot));
|
|
129
|
+
}
|
package/stores/auth.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { defineStore } from "pinia";
|
|
2
|
+
import { default as AuthService } from "../services/authService";
|
|
3
|
+
import type { MgUser } from "../types";
|
|
4
|
+
|
|
5
|
+
// Kept outside state so it never gets serialized to localStorage
|
|
6
|
+
let _fetchPromise: Promise<void> | null = null;
|
|
7
|
+
|
|
8
|
+
export const useAuthStore = defineStore({
|
|
9
|
+
id: "auth-store",
|
|
10
|
+
state: () => {
|
|
11
|
+
return {
|
|
12
|
+
user: {} as MgUser | any,
|
|
13
|
+
signedIn: false,
|
|
14
|
+
initialized: false,
|
|
15
|
+
loading: false,
|
|
16
|
+
};
|
|
17
|
+
},
|
|
18
|
+
actions: {
|
|
19
|
+
// `force` skips the 30s cooldown. `fresh` adds ?fresh=1 to the
|
|
20
|
+
// auth/user request so the API also busts its cache — needed right
|
|
21
|
+
// after a subscription/payment confirmation so the user immediately
|
|
22
|
+
// sees their new plan instead of the stale Free.
|
|
23
|
+
async getUser(force: boolean | { force?: boolean; fresh?: boolean } = false, fresh = false) {
|
|
24
|
+
// Backward-compat: original signature was getUser(force?: boolean).
|
|
25
|
+
// Allow getUser({ force: true, fresh: true }) too.
|
|
26
|
+
let forceFlag = false;
|
|
27
|
+
let freshFlag = false;
|
|
28
|
+
if (typeof force === "object" && force !== null) {
|
|
29
|
+
forceFlag = !!force.force;
|
|
30
|
+
freshFlag = !!force.fresh;
|
|
31
|
+
} else {
|
|
32
|
+
forceFlag = !!force;
|
|
33
|
+
freshFlag = !!fresh;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (!forceFlag && this.signedIn && this.initialized && this.user?.uuid) return;
|
|
37
|
+
// Deduplicate concurrent calls
|
|
38
|
+
if (_fetchPromise) return _fetchPromise;
|
|
39
|
+
|
|
40
|
+
_fetchPromise = (async () => {
|
|
41
|
+
this.loading = true;
|
|
42
|
+
try {
|
|
43
|
+
const data = await AuthService.getUser({ fresh: freshFlag });
|
|
44
|
+
if (data) {
|
|
45
|
+
this.user = { ...this.user, ...data };
|
|
46
|
+
this.signedIn = true;
|
|
47
|
+
} else {
|
|
48
|
+
this.user = {};
|
|
49
|
+
this.signedIn = false;
|
|
50
|
+
}
|
|
51
|
+
} catch {
|
|
52
|
+
this.user = {};
|
|
53
|
+
this.signedIn = false;
|
|
54
|
+
} finally {
|
|
55
|
+
this.loading = false;
|
|
56
|
+
this.initialized = true;
|
|
57
|
+
_fetchPromise = null;
|
|
58
|
+
}
|
|
59
|
+
})();
|
|
60
|
+
|
|
61
|
+
return _fetchPromise;
|
|
62
|
+
},
|
|
63
|
+
clearUser() {
|
|
64
|
+
this.user = {};
|
|
65
|
+
this.signedIn = false;
|
|
66
|
+
this.initialized = false;
|
|
67
|
+
this.loading = false;
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
getters: {
|
|
71
|
+
userId: (state) => (state.user ? state.user.id : null),
|
|
72
|
+
isSignedIn: (state) => state.signedIn,
|
|
73
|
+
},
|
|
74
|
+
persist: {
|
|
75
|
+
storage: persistedState.localStorage,
|
|
76
|
+
pick: ["user", "signedIn"],
|
|
77
|
+
afterHydrate: ({ store }) => {
|
|
78
|
+
store.initialized = false;
|
|
79
|
+
store.loading = false;
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
if (import.meta.hot) {
|
|
85
|
+
import.meta.hot.accept(acceptHMRUpdate(useAuthStore, import.meta.hot));
|
|
86
|
+
}
|
package/stores/chat.ts
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { defineStore } from "pinia";
|
|
2
|
+
import { ref } from "vue";
|
|
3
|
+
import { getChat } from "../services/chatService";
|
|
4
|
+
import type { MgChat } from "../types";
|
|
5
|
+
|
|
6
|
+
export const useChatStore = defineStore("chat-store", () => {
|
|
7
|
+
const hasNewMessage = ref(false);
|
|
8
|
+
const currentMessageData = ref<any | null>(null);
|
|
9
|
+
const refetchChat = ref(false);
|
|
10
|
+
const chatMessagesWidget = ref<any[]>([]);
|
|
11
|
+
const pollingIntervals: Record<string, number> = {};
|
|
12
|
+
|
|
13
|
+
const callNewMessage = (messageData: any) => {
|
|
14
|
+
Promise.resolve().then(() => {
|
|
15
|
+
hasNewMessage.value = true;
|
|
16
|
+
currentMessageData.value = messageData;
|
|
17
|
+
|
|
18
|
+
const index = chatMessagesWidget.value.findIndex((chat) => chat.data.id === messageData.chat_id);
|
|
19
|
+
if (index !== -1) {
|
|
20
|
+
if (!chatMessagesWidget.value[index].data.chat_messages) {
|
|
21
|
+
chatMessagesWidget.value[index].data.chat_messages = [];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const messageExists = chatMessagesWidget.value[index].data.chat_messages.some(
|
|
25
|
+
(msg: any) => msg.id === messageData.message_object.id,
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
if (!messageExists) {
|
|
29
|
+
chatMessagesWidget.value[index].data.chat_messages.push(messageData.message_object);
|
|
30
|
+
chatMessagesWidget.value = [...chatMessagesWidget.value];
|
|
31
|
+
nextTick(() => {
|
|
32
|
+
refetchChat.value = true;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const startPollingForMessages = (chatId: string | number, interval = 3000) => {
|
|
40
|
+
const pollingId = `polling-${chatId}`;
|
|
41
|
+
|
|
42
|
+
if (pollingIntervals[pollingId]) {
|
|
43
|
+
clearInterval(pollingIntervals[pollingId]);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
pollingIntervals[pollingId] = window.setInterval(async () => {
|
|
47
|
+
try {
|
|
48
|
+
const isWebSocketConnected = window.Echo?.connector?.pusher?.connection?.state === "connected";
|
|
49
|
+
|
|
50
|
+
if (isWebSocketConnected) {
|
|
51
|
+
clearInterval(pollingIntervals[pollingId]);
|
|
52
|
+
delete pollingIntervals[pollingId];
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
await handleChatMessages(chatId);
|
|
57
|
+
} catch {
|
|
58
|
+
// polling failure — will retry on next interval
|
|
59
|
+
}
|
|
60
|
+
}, interval);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const readedNewMessage = () => {
|
|
64
|
+
hasNewMessage.value = false;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const getRefetchChat = () => {
|
|
68
|
+
refetchChat.value = true;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const resetRefetchChat = () => {
|
|
72
|
+
refetchChat.value = false;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const addLoadingChat = (chatId: string | number, users: any[] = []) => {
|
|
76
|
+
const index = chatMessagesWidget.value.findIndex((c: any) => c?.data?.id === chatId);
|
|
77
|
+
if (index === -1) {
|
|
78
|
+
chatMessagesWidget.value.push({ data: { id: chatId, chat_messages: null, users } } as any);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const setChatMessagesWidget = (data: any, refresh: boolean = false) => {
|
|
83
|
+
const index = chatMessagesWidget.value.findIndex((chat) => chat.data.id === data.data.id);
|
|
84
|
+
if (index === -1) {
|
|
85
|
+
chatMessagesWidget.value.push(data);
|
|
86
|
+
} else if (refresh) {
|
|
87
|
+
chatMessagesWidget.value[index] = data;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const handleChatMessages = async (chatId: string | number) => {
|
|
92
|
+
try {
|
|
93
|
+
const response = await getChat({ chat_id: chatId });
|
|
94
|
+
setChatMessagesWidget(response.data, true);
|
|
95
|
+
|
|
96
|
+
const isWebSocketConnected = window.Echo?.connector?.pusher?.connection?.state === "connected";
|
|
97
|
+
if (!isWebSocketConnected) {
|
|
98
|
+
startPollingForMessages(chatId);
|
|
99
|
+
}
|
|
100
|
+
} catch {
|
|
101
|
+
// polling failure — will retry
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const stopAllPolling = () => {
|
|
106
|
+
Object.values(pollingIntervals).forEach(clearInterval);
|
|
107
|
+
Object.keys(pollingIntervals).forEach((key) => delete pollingIntervals[key]);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const removeChatFromWidgetList = (chatId: string | number) => {
|
|
111
|
+
chatMessagesWidget.value = chatMessagesWidget.value.filter((chat) => chat.data.id !== chatId);
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const newChat = (data: any) => {
|
|
115
|
+
setChatMessagesWidget(data);
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const substituteUserChat = (chatId: string | number, userId: string | number) => {
|
|
119
|
+
chatMessagesWidget.value = chatMessagesWidget.value.map((chat) => {
|
|
120
|
+
if (chat.data.id === userId) {
|
|
121
|
+
return { ...chat, data: { ...chat.data, id: chatId } };
|
|
122
|
+
}
|
|
123
|
+
return chat;
|
|
124
|
+
});
|
|
125
|
+
handleChatMessages(chatId);
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
return {
|
|
129
|
+
hasNewMessage,
|
|
130
|
+
currentMessageData,
|
|
131
|
+
callNewMessage,
|
|
132
|
+
readedNewMessage,
|
|
133
|
+
refetchChat,
|
|
134
|
+
resetRefetchChat,
|
|
135
|
+
getRefetchChat,
|
|
136
|
+
addLoadingChat,
|
|
137
|
+
setChatMessagesWidget,
|
|
138
|
+
chatMessagesWidget,
|
|
139
|
+
handleChatMessages,
|
|
140
|
+
removeChatFromWidgetList,
|
|
141
|
+
newChat,
|
|
142
|
+
substituteUserChat,
|
|
143
|
+
startPollingForMessages,
|
|
144
|
+
stopAllPolling,
|
|
145
|
+
};
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
if (import.meta.hot) {
|
|
149
|
+
import.meta.hot.accept(acceptHMRUpdate(useChatStore, import.meta.hot));
|
|
150
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { fetchContactCountry, fetchSubject } from "../services/contactService";
|
|
2
|
+
import { defineStore } from "pinia";
|
|
3
|
+
|
|
4
|
+
export const useContactStore = defineStore({
|
|
5
|
+
id: "contact-store",
|
|
6
|
+
state: () => ({
|
|
7
|
+
country: { data: {} as any, status: "init" },
|
|
8
|
+
subject: { data: {} as any, status: "init" },
|
|
9
|
+
}),
|
|
10
|
+
actions: {
|
|
11
|
+
async fetchCountry(params: any) {
|
|
12
|
+
this.country.status = "pending";
|
|
13
|
+
const { data } = await fetchContactCountry(params);
|
|
14
|
+
this.country.data = data;
|
|
15
|
+
this.country.status = "success";
|
|
16
|
+
},
|
|
17
|
+
async fetchSubject(params: any) {
|
|
18
|
+
this.subject.status = "pending";
|
|
19
|
+
const { data } = await fetchSubject(params);
|
|
20
|
+
this.subject.data = data;
|
|
21
|
+
this.subject.status = "success";
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
if (import.meta.hot) {
|
|
27
|
+
import.meta.hot.accept(acceptHMRUpdate(useContactStore, import.meta.hot));
|
|
28
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { fetchDocuments } from "../services/documentService";
|
|
2
|
+
import { defineStore } from "pinia";
|
|
3
|
+
|
|
4
|
+
export const useDocumentStore = defineStore({
|
|
5
|
+
id: "document-store",
|
|
6
|
+
state: () => ({
|
|
7
|
+
document: {
|
|
8
|
+
data: {} as any,
|
|
9
|
+
status: "init",
|
|
10
|
+
},
|
|
11
|
+
}),
|
|
12
|
+
actions: {
|
|
13
|
+
async fetchDocument(params: any) {
|
|
14
|
+
this.document.status = "pending";
|
|
15
|
+
const { data } = await fetchDocuments(params);
|
|
16
|
+
this.document.data = data;
|
|
17
|
+
this.document.status = "success";
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
getters: {
|
|
21
|
+
getDocument: (state) => state.document,
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
if (import.meta.hot) {
|
|
26
|
+
import.meta.hot.accept(acceptHMRUpdate(useDocumentStore, import.meta.hot));
|
|
27
|
+
}
|
package/stores/index.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { defineStore } from "pinia";
|
|
2
|
+
|
|
3
|
+
export const useIndexStore = defineStore({
|
|
4
|
+
id: "index-store",
|
|
5
|
+
state: () => {
|
|
6
|
+
return {
|
|
7
|
+
showUserModal: false,
|
|
8
|
+
modalUserText: "",
|
|
9
|
+
isSidebarOpened: false,
|
|
10
|
+
};
|
|
11
|
+
},
|
|
12
|
+
actions: {
|
|
13
|
+
toggleSidebar() {
|
|
14
|
+
this.isSidebarOpened = !this.isSidebarOpened;
|
|
15
|
+
},
|
|
16
|
+
async toggleUserModal(text: any) {
|
|
17
|
+
this.showUserModal = !this.showUserModal;
|
|
18
|
+
this.modalUserText = text;
|
|
19
|
+
},
|
|
20
|
+
resetModal() {
|
|
21
|
+
this.showUserModal = false;
|
|
22
|
+
this.modalUserText = "";
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
getters: {
|
|
26
|
+
sidebarState: (state) => state.isSidebarOpened,
|
|
27
|
+
getUserModalState: (state) => state.showUserModal,
|
|
28
|
+
getUserModalText: (state) => state.modalUserText,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
if (import.meta.hot) {
|
|
33
|
+
import.meta.hot.accept(acceptHMRUpdate(useIndexStore, import.meta.hot));
|
|
34
|
+
}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import {
|
|
2
|
+
fetchPress, fetchCareer, fetchStatus, fetchGeneralStatus, fetchRoadmap,
|
|
3
|
+
fetchDepartment, fetchCountry, fetchTeam, fetchOperationalArea,
|
|
4
|
+
fetchPartner, fetchBlog, fetchBlogCategory, fetchBlogTag,
|
|
5
|
+
fetchFaq, fetchMagazine, fetchLanguage,
|
|
6
|
+
} from "../services/institutionalService";
|
|
7
|
+
import { defineStore } from "pinia";
|
|
8
|
+
|
|
9
|
+
export const useInstitutionalStore = defineStore({
|
|
10
|
+
id: "institutional-store",
|
|
11
|
+
state: () => ({
|
|
12
|
+
press: { data: {} as any, status: "init" },
|
|
13
|
+
career: { data: {} as any, status: "init" },
|
|
14
|
+
status: { data: {} as any, status: "init" },
|
|
15
|
+
generalStatus: { data: {} as any, status: "init" },
|
|
16
|
+
roadmap: { data: {} as any, status: "init" },
|
|
17
|
+
country: { data: {} as any, status: "init" },
|
|
18
|
+
department: { data: {} as any, status: "init" },
|
|
19
|
+
team: { data: {} as any, status: "init" },
|
|
20
|
+
operationalArea: { data: {} as any, status: "init" },
|
|
21
|
+
blog: { data: {} as any, status: "init" },
|
|
22
|
+
popularBlog: { data: {} as any, status: "init" },
|
|
23
|
+
blogCategory: { data: {} as any, status: "init" },
|
|
24
|
+
blogTag: { data: {} as any, status: "init" },
|
|
25
|
+
faq: { data: {} as any, status: "init" },
|
|
26
|
+
partner: { data: {} as any, status: "init" },
|
|
27
|
+
magazine: { data: {} as any, status: "init" },
|
|
28
|
+
language: { data: {} as any, status: "init" },
|
|
29
|
+
showPartnersModal: false,
|
|
30
|
+
partners: "",
|
|
31
|
+
isFaqOpened: [] as boolean[],
|
|
32
|
+
}),
|
|
33
|
+
actions: {
|
|
34
|
+
async fetchPress(params: any) {
|
|
35
|
+
this.press.status = "pending";
|
|
36
|
+
const locale = useNuxtApp().$i18n.locale;
|
|
37
|
+
const { data } = await fetchPress(locale.value, params);
|
|
38
|
+
this.press.data = data;
|
|
39
|
+
this.press.status = "success";
|
|
40
|
+
},
|
|
41
|
+
async fetchLatestPress(params: any) {
|
|
42
|
+
this.press.status = "pending";
|
|
43
|
+
const locale = useNuxtApp().$i18n.locale;
|
|
44
|
+
const { data } = await fetchPress(locale.value, params);
|
|
45
|
+
const responseMeta = data.meta;
|
|
46
|
+
const tempLatestPress = [...data.data];
|
|
47
|
+
this.press.data = tempLatestPress;
|
|
48
|
+
this.press.data.meta = responseMeta;
|
|
49
|
+
this.press.status = "success";
|
|
50
|
+
},
|
|
51
|
+
async fetchMoreLatestPress(params: any) {
|
|
52
|
+
this.press.status = "pending";
|
|
53
|
+
const locale = useNuxtApp().$i18n.locale;
|
|
54
|
+
const { data } = await fetchPress(locale.value, params);
|
|
55
|
+
this.press.data = [...this.press.data, ...data.data];
|
|
56
|
+
this.press.status = "success";
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
async fetchCareer(params: any) {
|
|
60
|
+
this.career.status = "pending";
|
|
61
|
+
this.career.data = [];
|
|
62
|
+
const locale = useNuxtApp().$i18n.locale;
|
|
63
|
+
const { data } = await fetchCareer(locale.value, params);
|
|
64
|
+
const responseMeta = data.meta;
|
|
65
|
+
const tempCareer = [...data.data];
|
|
66
|
+
this.career.data = tempCareer;
|
|
67
|
+
this.career.data.meta = responseMeta;
|
|
68
|
+
this.career.status = "success";
|
|
69
|
+
},
|
|
70
|
+
async fetchMoreCareer(params: any) {
|
|
71
|
+
this.career.status = "pending";
|
|
72
|
+
const locale = useNuxtApp().$i18n.locale;
|
|
73
|
+
const { data } = await fetchCareer(locale.value, params);
|
|
74
|
+
this.career.data = [...this.career.data, ...data.data];
|
|
75
|
+
this.career.status = "success";
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
async fetchStatus(params: any) {
|
|
79
|
+
this.status.status = "pending";
|
|
80
|
+
const locale = useNuxtApp().$i18n.locale;
|
|
81
|
+
const { data } = await fetchStatus(locale.value, params);
|
|
82
|
+
this.status.data = data;
|
|
83
|
+
this.status.status = "success";
|
|
84
|
+
},
|
|
85
|
+
async fetchGeneralStatus(params: any) {
|
|
86
|
+
this.generalStatus.status = "pending";
|
|
87
|
+
const locale = useNuxtApp().$i18n.locale;
|
|
88
|
+
const { data } = await fetchGeneralStatus(locale.value, params);
|
|
89
|
+
this.generalStatus.data = data;
|
|
90
|
+
this.generalStatus.status = "success";
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
async fetchRoadmap(params: any) {
|
|
94
|
+
this.roadmap.status = "pending";
|
|
95
|
+
const locale = useNuxtApp().$i18n.locale;
|
|
96
|
+
const { data } = await fetchRoadmap(locale.value, params);
|
|
97
|
+
this.roadmap.data = data;
|
|
98
|
+
this.roadmap.status = "success";
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
async fetchCountry(params: any) {
|
|
102
|
+
this.country.status = "pending";
|
|
103
|
+
const { data } = await fetchCountry(params);
|
|
104
|
+
this.country.data = data;
|
|
105
|
+
this.country.status = "success";
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
async fetchDepartment(params: any) {
|
|
109
|
+
this.department.status = "pending";
|
|
110
|
+
const { data } = await fetchDepartment(params);
|
|
111
|
+
this.department.data = data;
|
|
112
|
+
this.department.status = "success";
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
async fetchTeam(params: any) {
|
|
116
|
+
this.team.status = "pending";
|
|
117
|
+
const locale = useNuxtApp().$i18n.locale;
|
|
118
|
+
const { data } = await fetchTeam(locale.value, params);
|
|
119
|
+
this.team.data = data;
|
|
120
|
+
this.team.status = "success";
|
|
121
|
+
},
|
|
122
|
+
async fetchOperationalArea(params: any) {
|
|
123
|
+
this.operationalArea.status = "pending";
|
|
124
|
+
const { data } = await fetchOperationalArea(params);
|
|
125
|
+
this.operationalArea.data = data;
|
|
126
|
+
this.operationalArea.status = "success";
|
|
127
|
+
},
|
|
128
|
+
|
|
129
|
+
async fetchPartner(params: any) {
|
|
130
|
+
this.partner.status = "pending";
|
|
131
|
+
const lang: string = useCookie("i18n_redirected").value || "en";
|
|
132
|
+
const { data } = await fetchPartner(lang, params);
|
|
133
|
+
this.partner.data = data;
|
|
134
|
+
this.partner.status = "success";
|
|
135
|
+
},
|
|
136
|
+
|
|
137
|
+
async fetchBlog(params: any) {
|
|
138
|
+
this.blog.status = "pending";
|
|
139
|
+
this.blog.data = [];
|
|
140
|
+
const locale = useNuxtApp().$i18n.locale;
|
|
141
|
+
const { data } = await fetchBlog(locale.value, params);
|
|
142
|
+
const responseMeta = data.meta;
|
|
143
|
+
const tempBlog = [...data.data];
|
|
144
|
+
this.blog.data = tempBlog;
|
|
145
|
+
this.blog.data.meta = responseMeta;
|
|
146
|
+
this.blog.status = "success";
|
|
147
|
+
},
|
|
148
|
+
async fetchMoreBlog(params: any) {
|
|
149
|
+
this.blog.status = "pending";
|
|
150
|
+
const locale = useNuxtApp().$i18n.locale;
|
|
151
|
+
const { data } = await fetchBlog(locale.value, params);
|
|
152
|
+
this.blog.data = [...this.blog.data, ...data.data];
|
|
153
|
+
this.blog.status = "success";
|
|
154
|
+
},
|
|
155
|
+
async fetchPopularBlog(params: any) {
|
|
156
|
+
this.popularBlog.status = "pending";
|
|
157
|
+
const locale = useNuxtApp().$i18n.locale;
|
|
158
|
+
const { data } = await fetchBlog(locale.value, params);
|
|
159
|
+
this.popularBlog.data = data;
|
|
160
|
+
this.popularBlog.status = "success";
|
|
161
|
+
},
|
|
162
|
+
|
|
163
|
+
async fetchBlogCategory(params: any) {
|
|
164
|
+
this.blogCategory.status = "pending";
|
|
165
|
+
const { data } = await fetchBlogCategory(params);
|
|
166
|
+
this.blogCategory.data = data;
|
|
167
|
+
this.blogCategory.status = "success";
|
|
168
|
+
},
|
|
169
|
+
async fetchBlogTag(params: any) {
|
|
170
|
+
this.blogTag.status = "pending";
|
|
171
|
+
const { data } = await fetchBlogTag(params);
|
|
172
|
+
this.blogTag.data = data;
|
|
173
|
+
this.blogTag.status = "success";
|
|
174
|
+
},
|
|
175
|
+
|
|
176
|
+
async fetchFaq(params: any) {
|
|
177
|
+
this.faq.status = "pending";
|
|
178
|
+
const locale = useNuxtApp().$i18n.locale;
|
|
179
|
+
const { data } = await fetchFaq(locale.value, params);
|
|
180
|
+
this.faq.data = data;
|
|
181
|
+
this.faq.status = "success";
|
|
182
|
+
this.isFaqOpened = [];
|
|
183
|
+
},
|
|
184
|
+
|
|
185
|
+
async fetchMagazine(params: any) {
|
|
186
|
+
this.magazine.status = "pending";
|
|
187
|
+
const { data } = await fetchMagazine(params);
|
|
188
|
+
this.magazine.data = data;
|
|
189
|
+
this.magazine.status = "success";
|
|
190
|
+
},
|
|
191
|
+
async fetchLatestMagazine(params: any) {
|
|
192
|
+
this.magazine.status = "pending";
|
|
193
|
+
const { data } = await fetchMagazine(params);
|
|
194
|
+
const responseMeta = data.meta;
|
|
195
|
+
const tempLatestMagazine = [...data.data];
|
|
196
|
+
this.magazine.data = tempLatestMagazine;
|
|
197
|
+
this.magazine.data.meta = responseMeta;
|
|
198
|
+
this.magazine.status = "success";
|
|
199
|
+
},
|
|
200
|
+
async fetchMoreLatestMagazine(params: any) {
|
|
201
|
+
this.magazine.status = "pending";
|
|
202
|
+
const { data } = await fetchMagazine(params);
|
|
203
|
+
this.magazine.data = [...this.magazine.data, ...data.data];
|
|
204
|
+
this.magazine.status = "success";
|
|
205
|
+
},
|
|
206
|
+
async fetchLanguage(params: any) {
|
|
207
|
+
this.language.status = "pending";
|
|
208
|
+
const { data } = await fetchLanguage(params);
|
|
209
|
+
this.language.data = data.data;
|
|
210
|
+
this.language.status = "success";
|
|
211
|
+
},
|
|
212
|
+
|
|
213
|
+
togglePartnersModal() {
|
|
214
|
+
this.showPartnersModal = !this.showPartnersModal;
|
|
215
|
+
},
|
|
216
|
+
togglePartners(val: string) {
|
|
217
|
+
this.partners = val;
|
|
218
|
+
},
|
|
219
|
+
toggleObject(val: any) {
|
|
220
|
+
this.showPartnersModal = !this.showPartnersModal;
|
|
221
|
+
this.partners = val.partners;
|
|
222
|
+
},
|
|
223
|
+
toggleFaq(index: number) {
|
|
224
|
+
this.isFaqOpened[index] = !this.isFaqOpened[index];
|
|
225
|
+
},
|
|
226
|
+
},
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
if (import.meta.hot) {
|
|
230
|
+
import.meta.hot.accept(acceptHMRUpdate(useInstitutionalStore, import.meta.hot));
|
|
231
|
+
}
|