summaryrefslogtreecommitdiff
path: root/api/settings.ts
diff options
context:
space:
mode:
authorJustZvan <justzvan@justzvan.xyz>2026-02-06 13:22:33 +0100
committerJustZvan <justzvan@justzvan.xyz>2026-02-06 13:22:33 +0100
commit7eb8ccae48b0cc18a9dcaa9c3626a02df8e6d919 (patch)
tree57b7dd06ac9aa7053c671d916f7183e3b4fa9410 /api/settings.ts
feat: initial commit!
Diffstat (limited to 'api/settings.ts')
-rw-r--r--api/settings.ts42
1 files changed, 42 insertions, 0 deletions
diff --git a/api/settings.ts b/api/settings.ts
new file mode 100644
index 0000000..2823afa
--- /dev/null
+++ b/api/settings.ts
@@ -0,0 +1,42 @@
+import { apiClient } from "./client";
+
+interface VerifyEmailResponse {
+ success: boolean;
+ reason?: string;
+}
+
+export async function verifyEmail(
+ code: string,
+): Promise<{ success: boolean; error?: string }> {
+ try {
+ const response: VerifyEmailResponse = await apiClient.post(
+ "/parent/verifyemail",
+ { code },
+ );
+ return { success: response.success };
+ } catch (e) {
+ console.error("Failed to verify email", e);
+ return {
+ success: false,
+ error: e instanceof Error ? e.message : "Failed to verify email",
+ };
+ }
+}
+
+export interface UserProfile {
+ email: string;
+ emailVerified: boolean;
+}
+
+export async function getUserProfile(): Promise<UserProfile | null> {
+ try {
+ const response = await apiClient.get<{
+ success: boolean;
+ profile: UserProfile;
+ }>("/parent/profile");
+ return response.profile;
+ } catch (e) {
+ console.error("Failed to fetch user profile", e);
+ return null;
+ }
+}