MCPcopy Create free account
hub / github.com/OneBitCodeBlog/onebitlife / Home

Function Home

src/Pages/Home/index.jsx:16–177  ·  view source on GitHub ↗
({ route })

Source from the content-addressed store, hash-verified

14import db from "../../Database";
15
16export default function Home({ route }) {
17 const navigation = useNavigation();
18 const [mindHabit, setMindHabit] = useState();
19 const [moneyHabit, setMoneyHabit] = useState();
20 const [bodyHabit, setBodyHabit] = useState();
21 const [funHabit, setFunHabit] = useState();
22
23 const [robotDaysLife, setRobotDaysLife] = useState();
24 const [checks, setChecks] = useState();
25 const [gameOver, setGameOver] = useState(false);
26 const today = new Date();
27
28 function handleNavExplanation() {
29 navigation.navigate("AppExplanation");
30 }
31 function handleGameOver() {
32 navigation.navigate("Start");
33 db.transaction((tx) => {
34 tx.executeSql("DROP TABLE habits;");
35 tx.executeSql("DROP TABLE change_navigation;");
36 });
37 }
38
39 const excludeArea = route.params?.excludeArea;
40
41 useEffect(() => {
42 HabitsService.findByArea("Mente").then((mind) => {
43 setMindHabit(mind[0]);
44 });
45 HabitsService.findByArea("Financeiro").then((money) => {
46 setMoneyHabit(money[0]);
47 });
48 HabitsService.findByArea("Corpo").then((body) => {
49 setBodyHabit(body[0]);
50 });
51 HabitsService.findByArea("Humor").then((fun) => {
52 setFunHabit(fun[0]);
53 });
54
55 if (excludeArea) {
56 if (excludeArea == "Mente") {
57 setMindHabit(null);
58 }
59 if (excludeArea == "Financeiro") {
60 setMoneyHabit(null);
61 }
62 if (excludeArea == "Corpo") {
63 setBodyHabit(null);
64 }
65 if (excludeArea == "Humor") {
66 setFunHabit(null);
67 }
68 }
69
70 ChangeNavigationService.checkShowHome(1)
71 .then((showHome) => {
72 const month = `${today.getMonth() + 1}`.padStart(2, "0");
73 const day = `${today.getDate()}`.padStart(2, "0");

Callers

nothing calls this directly

Calls 1

handleNavExplanationFunction · 0.85

Tested by

no test coverage detected