Refactor: Split settings API into modules

This commit is contained in:
Tola Leng
2025-06-17 21:50:34 +08:00
parent 6d1b8387ca
commit 1daaf067d9
2 changed files with 49 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
export interface SettingsApiRequest {
action: string;
data?: any;
}
export interface SettingsApiResponse {
status: number;
json: {
success: boolean;
data?: any;
message?: string;
};
}
export interface SmtpSettings {
enabled?: boolean;
host?: string;
port?: number;
username?: string;
password?: string;
authMethod?: string;
tls?: boolean;
localName?: string;
}
+24
View File
@@ -0,0 +1,24 @@
import { pb, getCurrentEndpoint } from '@/lib/pocketbase';
export const getAuthHeaders = (): Record<string, string> => {
const authToken = pb.authStore.token;
const headers: Record<string, string> = {
'Content-Type': 'application/json',
};
if (authToken) {
headers['Authorization'] = `Bearer ${authToken}`;
}
return headers;
};
export const getBaseUrl = (): string => {
return getCurrentEndpoint();
};
export const validateEmail = (email: string): boolean => {
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
return emailRegex.test(email);
};