feat: troubleshooting page
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 7s

This commit is contained in:
Methapon2001 2025-04-25 15:15:37 +07:00
parent 8c9e9abc18
commit 21699b14c5
8 changed files with 97 additions and 24 deletions

View file

@ -5,10 +5,11 @@ import { getToken } from 'src/services/keycloak';
import { Manual } from './types';
import { baseUrl } from '../utils';
const ENDPOINT = 'manual';
const MANUAL_ENDPOINT = 'manual';
const TROUBLESHOOTING_ENDPOINT = 'troubleshooting';
export async function getManual() {
const res = await api.get<Manual[]>(`/${ENDPOINT}`);
const res = await api.get<Manual[]>(`/${MANUAL_ENDPOINT}`);
if (res.status < 400) {
return res.data;
}
@ -20,7 +21,28 @@ export async function getManualByPage(opt: {
pageName: string;
}) {
const res = await fetch(
`${baseUrl}/${ENDPOINT}/${opt.category}/page/${opt.pageName}`,
`${baseUrl}/${MANUAL_ENDPOINT}/${opt.category}/page/${opt.pageName}`,
);
if (res.status < 400) {
return res;
}
return null;
}
export async function getTroubleshooting() {
const res = await api.get<Manual[]>(`/${TROUBLESHOOTING_ENDPOINT}`);
if (res.status < 400) {
return res.data;
}
return null;
}
export async function getTroubleshootingByPage(opt: {
category: string;
pageName: string;
}) {
const res = await fetch(
`${baseUrl}/${TROUBLESHOOTING_ENDPOINT}/${opt.category}/page/${opt.pageName}`,
);
if (res.status < 400) {
return res;
@ -30,11 +52,15 @@ export async function getManualByPage(opt: {
export const useManualStore = defineStore('manual-store', () => {
const dataManual = ref<Manual[]>([]);
const dataTroubleshooting = ref<Manual[]>([]);
return {
getManual,
getManualByPage,
getTroubleshooting,
getTroubleshootingByPage,
dataManual,
dataTroubleshooting,
};
});