Refactor: Split settings API into modules
This commit is contained in:
@@ -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;
|
||||
}
|
||||
@@ -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);
|
||||
};
|
||||
Reference in New Issue
Block a user