add permission role

This commit is contained in:
Yusron alamsyah
2026-04-10 14:40:11 +07:00
parent 4325bae76f
commit 734a78bd37
19 changed files with 1067 additions and 17 deletions
+3 -1
View File
@@ -1,6 +1,8 @@
import axios from 'axios'
import { useAuth } from '~/composables/useAuth';
const config = useRuntimeConfig()
const { sessionData } = useAuth();
const api = axios.create({
baseURL: config.public.baseUrl
@@ -33,7 +35,7 @@ const refreshAccessToken = async (): Promise<string | null> => {
method: 'POST',
body: JSON.stringify({
refresh_token: refreshToken,
provider: 'keycloak',
provider: sessionData.value?.user?.auth_provider || 'keycloak'
}),
})
+31
View File
@@ -0,0 +1,31 @@
type DateInput = Date | string | number | null | undefined;
const pad2 = (value: number) => String(value).padStart(2, '0');
const toDate = (input: DateInput): Date | null => {
if (input == null) return null;
if (input instanceof Date) {
return Number.isNaN(input.getTime()) ? null : input;
}
const date = new Date(input);
return Number.isNaN(date.getTime()) ? null : date;
};
/**
* Format datetime to `d-m-Y H:i` (e.g. `07-04-2026 14:05`).
* Uses local time.
*/
export const formatDateTime = (input: DateInput, fallback = '-') => {
const date = toDate(input);
if (!date) return fallback;
const day = pad2(date.getDate());
const month = pad2(date.getMonth() + 1);
const year = String(date.getFullYear());
const hours = pad2(date.getHours());
const minutes = pad2(date.getMinutes());
return `${day}-${month}-${year} ${hours}:${minutes}`;
};