Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"expo": {
"name": "BaseAut",
"slug": "baseaut",
"version": "1.1.1",
"version": "1.1.2",
"orientation": "portrait",
"icon": "./assets/images/icon.png",
"scheme": "baseaut",
Expand Down
14 changes: 11 additions & 3 deletions app/settings.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { Header } from "@/components/header";
import { PageHeader } from "@/components/page-header";
import { LOCALE_OPTIONS } from "@/features/settings/constants/translations";
// IDIOMA DESATIVADO — para reativar, descomente esta linha.
// import { LOCALE_OPTIONS } from "@/features/settings/constants/translations";
import { FeedbackModal } from "@/features/settings/components/feedback-modal";
import { useI18n } from "@/features/settings/contexts/i18n-context";
import { ThemeMode, useTheme, useThemeColors } from "@/features/settings/contexts/theme-context";
import { useRouter } from "expo-router";
import { Check, GraduationCap, Languages, MessageSquareText, Monitor, Moon, Sun } from "lucide-react-native";
// TUTORIAL/IDIOMA DESATIVADOS — ao reativar, volte a importar GraduationCap e Languages.
import { Check, MessageSquareText, Monitor, Moon, Sun } from "lucide-react-native";
import React, { useState } from "react";
import { Pressable, ScrollView, Text, View } from "react-native";

Expand Down Expand Up @@ -48,7 +50,8 @@ export default function SettingsRoute() {
const router = useRouter();
const colors = useThemeColors();
const { mode, setMode } = useTheme();
const { t, preference, setPreference } = useI18n();
// IDIOMA DESATIVADO — ao reativar, volte a extrair preference e setPreference.
const { t } = useI18n();
const [feedbackVisible, setFeedbackVisible] = useState(false);

const themeOptions: { value: ThemeMode; label: string; icon: React.ReactNode }[] = [
Expand Down Expand Up @@ -99,6 +102,8 @@ export default function SettingsRoute() {
</Pressable>
</View>

{/* IDIOMA DESATIVADO — o app fica só em português por ora.
Para reativar, descomente este bloco.
<View className="mt-8 gap-4">
<Text className="text-header-3 text-content">{t("settings.language")}</Text>
<Text className="text-default-2 text-muted">
Expand All @@ -116,7 +121,9 @@ export default function SettingsRoute() {
))}
</View>
</View>
*/}

{/* TUTORIAL DESATIVADO — para reativar, descomente este bloco.
<View className="mt-8 gap-4">
<Text className="text-header-3 text-content">{t("settings.tutorial")}</Text>

Expand All @@ -130,6 +137,7 @@ export default function SettingsRoute() {
</View>
</Pressable>
</View>
*/}
</ScrollView>

<FeedbackModal
Expand Down
11 changes: 8 additions & 3 deletions components/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import { useI18n } from "@/features/settings/contexts/i18n-context";
import { useThemeColors } from "@/features/settings/contexts/theme-context";
import { SpotlightTarget } from "@/features/tutorial/components/spotlight-target";
import { TUTORIAL_EXIT_SPOTLIGHT_KEY } from "@/features/tutorial/components/tutorial-tap-guard";
import { useTutorial } from "@/features/tutorial/contexts/tutorial-context";
// TUTORIAL DESATIVADO — para reativar, descomente esta linha.
// import { useTutorial } from "@/features/tutorial/contexts/tutorial-context";
import { useUserRole } from "@/lib/use-user-role";
import { usePathname, useRouter } from "expo-router";
import { ArrowLeft, GraduationCap, HelpCircle, Save, Settings, User, Users, X } from "lucide-react-native";
// TUTORIAL DESATIVADO — ao reativar, volte a importar HelpCircle.
import { ArrowLeft, GraduationCap, Save, Settings, User, Users, X } from "lucide-react-native";
import React from "react";
import { Pressable, Text, View } from "react-native";
import { SafeAreaView } from 'react-native-safe-area-context';
Expand Down Expand Up @@ -65,7 +67,8 @@ export function Header({
const role = useUserRole();
const colors = useThemeColors();
const { t } = useI18n();
const { allCompleted: tutorialAllCompleted } = useTutorial();
// TUTORIAL DESATIVADO — para reativar, descomente esta linha.
// const { allCompleted: tutorialAllCompleted } = useTutorial();

const showBack = ["back", "finish", "finishEngagement", "form", "tutorial"].includes(variant);
const showDefaultActions = variant === "default";
Expand Down Expand Up @@ -150,11 +153,13 @@ export function Header({
</Pressable>
)}

{/* TUTORIAL DESATIVADO — para reativar, descomente este bloco.
{!tutorialAllCompleted && (
<Pressable onPress={() => router.push("/tutorial" as never)} className="p-1 active:opacity-70" style={{ marginLeft: 20 }}>
<HelpCircle color={colors.muted} size={24} />
</Pressable>
)}
*/}

<Pressable onPress={() => router.push("/account")} className="p-1 active:opacity-70" style={{ marginLeft: 20 }}>
<User color={colors.muted} size={24} />
Expand Down
3 changes: 3 additions & 0 deletions features/settings/constants/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,7 @@ export type TranslationKey =
| "students.form.supportOption1"
| "students.form.supportOption2"
| "students.form.supportOption3"
| "students.form.supportOptionUndefined"
| "students.form.healthConditions"
| "students.form.healthConditionsPlaceholder"
| "students.form.observations"
Expand Down Expand Up @@ -1734,6 +1735,7 @@ export const translations: Record<Locale, Record<TranslationKey, string>> = {
"students.form.supportOption1": "Transtorno do Espectro Autista Nível 1",
"students.form.supportOption2": "Transtorno do Espectro Autista Nível 2",
"students.form.supportOption3": "Transtorno do Espectro Autista Nível 3",
"students.form.supportOptionUndefined": "Indefinido",
"students.form.healthConditions": "Outras condições de saúde",
"students.form.healthConditionsPlaceholder": "Outras condições de saúde (opcional)",
"students.form.observations": "Observações",
Expand Down Expand Up @@ -2852,6 +2854,7 @@ export const translations: Record<Locale, Record<TranslationKey, string>> = {
"students.form.supportOption1": "Autism Spectrum Disorder Level 1",
"students.form.supportOption2": "Autism Spectrum Disorder Level 2",
"students.form.supportOption3": "Autism Spectrum Disorder Level 3",
"students.form.supportOptionUndefined": "Undefined",
"students.form.healthConditions": "Other health conditions",
"students.form.healthConditionsPlaceholder": "Other health conditions (optional)",
"students.form.observations": "Notes",
Expand Down
6 changes: 5 additions & 1 deletion features/settings/contexts/i18n-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ export function I18nProvider({ children }: { children: React.ReactNode }) {
AsyncStorage.setItem(STORAGE_KEY, next);
}, []);

const locale: Locale = preference === "system" ? getDeviceLocale() : preference;
// IDIOMA TRAVADO EM PORTUGUÊS — a escolha de idioma saiu de Configurações, e
// sem esta trava um aparelho com outro idioma cairia no inglês pela
// preferência "system". Para reativar, troque pela linha comentada abaixo.
const locale: Locale = "pt";
// const locale: Locale = preference === "system" ? getDeviceLocale() : preference;

const t = useCallback(
(key: TranslationKey) =>
Expand Down
1 change: 1 addition & 0 deletions features/students/components/new-student.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export function NewStudent({
t("students.form.supportOption1"),
t("students.form.supportOption2"),
t("students.form.supportOption3"),
t("students.form.supportOptionUndefined"),
];

useEffect(() => {
Expand Down
57 changes: 43 additions & 14 deletions features/students/hooks/use-students.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { supabase } from "@/lib/supabase";
import { calculateAge } from "@/lib/date-utils";
import type { TranslationKey } from "@/features/settings/constants/translations";
import { useI18n } from "@/features/settings/contexts/i18n-context";
import { resolveEquipeId } from "@/lib/resolve-equipe-id";
import { uploadImage } from "@/lib/upload-image";
Expand All @@ -24,6 +25,45 @@ export type Student = {
pendencyAlert: boolean;
};

/** Support level values stored in the `nivel_suporte_tea` enum. */
type NivelSuporteDb = "nivel_1" | "nivel_2" | "nivel_3" | "indefinido";

/**
* Converts the stored support level into the label shown in the UI.
*
* @remarks
* "indefinido" exists for children whose level is not known yet (report still
* pending), so the form no longer has to record a level nobody confirmed.
*/
function supportLevelFromDb(
raw: string | null | undefined,
t: (key: TranslationKey) => string,
): string {
if (raw === "nivel_1") return "Nível 1";
if (raw === "nivel_2") return "Nível 2";
if (raw === "nivel_3") return "Nível 3";
return t("students.form.supportOptionUndefined");
}

/**
* Converts the label picked in the form back into the stored enum value.
*
* @remarks
* The undefined option is matched against its own translated label, so it works
* in every language; the numbered levels are matched by their digit, which the
* label carries in every language.
*/
function supportLevelToDb(
label: string,
t: (key: TranslationKey) => string,
): NivelSuporteDb {
if (label === t("students.form.supportOptionUndefined")) return "indefinido";
if (label.includes("2")) return "nivel_2";
if (label.includes("3")) return "nivel_3";
if (label.includes("1")) return "nivel_1";
return "indefinido";
}

/** Seed students for the tutorial's mock mode (kept entirely in memory). */
const MOCK_STUDENTS: Student[] = [
{
Expand Down Expand Up @@ -125,11 +165,7 @@ const loadStudents = useCallback(async (showLoader = true) => {
weight: Number(aluno.peso) || 0,
height: Number(aluno.altura) || 0,
waist: Number(aluno.cintura) || 0,
supportLevel:
aluno.nivel_suporte === "nivel_1" ? "Nível 1"
: aluno.nivel_suporte === "nivel_2"
? "Nível 2"
: "Nível 3",
supportLevel: supportLevelFromDb(aluno.nivel_suporte, t),
healthConditions: aluno.diagnostico_detalhado || "",
observations: aluno.observacoes_clinicas || "",
avatarUrl: aluno.avatar_url,
Expand Down Expand Up @@ -188,10 +224,7 @@ const loadStudents = useCallback(async (showLoader = true) => {
: (await uploadImage("avatares", photoUri, "alunos")) ?? null;
}

let nivelSuporteDb = "nivel_1";
const supportLower = data.supportLevel.toLowerCase();
if (supportLower.includes("2")) nivelSuporteDb = "nivel_2";
if (supportLower.includes("3")) nivelSuporteDb = "nivel_3";
const nivelSuporteDb = supportLevelToDb(data.supportLevel, t);

let formattedDate = data.birthDate;
if (formattedDate.includes("/")) {
Expand Down Expand Up @@ -271,11 +304,7 @@ const loadStudents = useCallback(async (showLoader = true) => {
}

if (data.supportLevel !== undefined) {
let nivelSuporteDb = "nivel_1";
const supportLower = data.supportLevel.toLowerCase();
if (supportLower.includes("2")) nivelSuporteDb = "nivel_2";
if (supportLower.includes("3")) nivelSuporteDb = "nivel_3";
payload.nivel_suporte = nivelSuporteDb;
payload.nivel_suporte = supportLevelToDb(data.supportLevel, t);
}

if (data.birthDate !== undefined) {
Expand Down
12 changes: 12 additions & 0 deletions supabase/migrations/20260730120000_nivel_suporte_indefinido.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-- =======================================================================
-- Migration: nível de suporte "Indefinido"
-- =======================================================================
-- O nível de suporte do TEA nem sempre é conhecido no momento do cadastro
-- (laudo ainda não emitido, criança em avaliação). Até aqui o formulário
-- obrigava escolher entre os níveis 1, 2 e 3, o que levava a registrar um
-- nível que ninguém confirmou.
--
-- Passa a existir o valor 'indefinido' no enum. Os registros existentes não
-- são tocados: quem já tem um nível declarado permanece como está.

ALTER TYPE nivel_suporte_tea ADD VALUE IF NOT EXISTS 'indefinido';
Loading