From fef579b2b794be6f4b8e963fe4ed2c4c8f734aec Mon Sep 17 00:00:00 2001
From: JustZvan <justzvan@justzvan.xyz>
Date: Wed, 8 Apr 2026 19:48:30 +0200
Subject: feat: 1.2

---
 app/(tabs)/settings.tsx | 55 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)

(limited to 'app/(tabs)/settings.tsx')

diff --git a/app/(tabs)/settings.tsx b/app/(tabs)/settings.tsx
index b4493b4..c19da37 100644
--- a/app/(tabs)/settings.tsx
+++ b/app/(tabs)/settings.tsx
@@ -5,6 +5,7 @@ import {
   Device,
   getDevices,
   getUserProfile,
+  requestKidLinkCode,
   renameDevice,
   UserProfile,
   verifyEmail,
@@ -38,6 +39,12 @@ export default function SettingsScreen() {
     success: boolean;
     message: string;
   }>({ visible: false, success: false, message: "" });
+  const [kidLinkCodeResult, setKidLinkCodeResult] = useState<{
+    visible: boolean;
+    success: boolean;
+    title: string;
+    message: string;
+  }>({ visible: false, success: false, title: "", message: "" });
 
   const showNotWired = () => setAlertVisible(true);
 
@@ -86,6 +93,32 @@ export default function SettingsScreen() {
     setVerifyEmailVisible(false);
   };
 
+  const handleGenerateKidLinkCode = async () => {
+    const result = await requestKidLinkCode();
+
+    if (result.success && result.code) {
+      const expiresMinutes = Math.max(
+        1,
+        Math.ceil((result.expiresInSeconds ?? 300) / 60),
+      );
+
+      setKidLinkCodeResult({
+        visible: true,
+        success: true,
+        title: t("kidLinkCodeTitle"),
+        message: `${result.code}\n${t("kidLinkCodeExpiresIn")} ${expiresMinutes} min`,
+      });
+      return;
+    }
+
+    setKidLinkCodeResult({
+      visible: true,
+      success: false,
+      title: t("error"),
+      message: result.error || t("failedToGenerateKidLinkCode"),
+    });
+  };
+
   return (
     <Screen>
       <AlertDialog
@@ -122,6 +155,15 @@ export default function SettingsScreen() {
         }
       />
 
+      <AlertDialog
+        visible={kidLinkCodeResult.visible}
+        title={kidLinkCodeResult.title}
+        message={kidLinkCodeResult.message}
+        onClose={() =>
+          setKidLinkCodeResult({ ...kidLinkCodeResult, visible: false })
+        }
+      />
+
       <Card>
         <Row
           left={
@@ -198,6 +240,19 @@ export default function SettingsScreen() {
       <Card>
         <H2>{t("account")}</H2>
         <Divider />
+        <ActionRow
+          title={t("generateKidLinkCode")}
+          subtitle={t("generateKidLinkCodeSubtitle")}
+          onPress={handleGenerateKidLinkCode}
+          right={
+            <Ionicons
+              name="key-outline"
+              size={18}
+              color={colors.onSurfaceVariant}
+            />
+          }
+        />
+        <Divider />
         {profile && !profile.emailVerified && (
           <>
             <ActionRow
-- 
cgit v1.2.3

