From a85bd4c2319777ae37fd4e1deea6d5b6d55fc3bc Mon Sep 17 00:00:00 2001 From: JH Date: Sat, 29 Mar 2025 11:05:22 +0100 Subject: [PATCH 1/6] api updated --- src/api/axios.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/api/axios.ts b/src/api/axios.ts index a81efdc..b9ccdec 100644 --- a/src/api/axios.ts +++ b/src/api/axios.ts @@ -1,5 +1,6 @@ import Axios from 'axios'; export const axios = Axios.create({ - baseURL: `http://10.93.0.120:8000/api/`, + // baseURL: `http://10.93.0.120:8000/api/`, + baseURL: `https://backend-4.w2025.deployed.space/api/`, }); From 47e076573407a8a19ca4e8821a8700d6be259b16 Mon Sep 17 00:00:00 2001 From: JH Date: Sat, 29 Mar 2025 12:20:26 +0100 Subject: [PATCH 2/6] routing to challenge.tsx --- src/hooks/useChallenge.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/hooks/useChallenge.ts diff --git a/src/hooks/useChallenge.ts b/src/hooks/useChallenge.ts new file mode 100644 index 0000000..1db6241 --- /dev/null +++ b/src/hooks/useChallenge.ts @@ -0,0 +1,16 @@ +import { useMutation } from '@tanstack/react-query'; +import { useRouter } from 'expo-router'; + +export function useChallenge() { + const router = useRouter(); + + return useMutation({ + mutationFn: async (data) => { + // Tu dodaj logikę mutacji, np. wywołanie API + return Promise.resolve(data); + }, + onSuccess: () => { + router.push('/challenge'); + }, + }); +} From 0dc8690dc18910ff65e0d0a940a6cdb2e0dc089c Mon Sep 17 00:00:00 2001 From: JH Date: Sat, 29 Mar 2025 12:21:14 +0100 Subject: [PATCH 3/6] routing to challenge.tsx --- app/index.tsx | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/app/index.tsx b/app/index.tsx index 0627304..7bb927b 100644 --- a/app/index.tsx +++ b/app/index.tsx @@ -1,21 +1,25 @@ +import { useState } from 'react'; import { StyleSheet, View } from 'react-native'; import { useTranslation } from 'react-i18next'; import { BackgroundContainer, Button, Popup, Typography } from '@/components'; +import { useCreateFlashCardSet, useChallenge } from '@/hooks'; + import LogoIcon from '../assets/svgs/logo.svg'; -import { useState } from 'react'; -import { useCreateFlashCardSet} from '@/hooks'; + +// import {useRouter} from "expo-router"; export default function Index() { const { t } = useTranslation(); // const router = useRouter(); const [popupVisible, setPopupVisible] = useState(false); - const { mutate } = useCreateFlashCardSet(); + const { mutate: createSet } = useCreateFlashCardSet(); + const { mutate: createChallenge } = useChallenge(); const handleCreateFlashCards = () => { - setPopupVisible(true) - } + setPopupVisible(true); + }; const handleSave = (name: string) => { if (!name.trim()) { @@ -23,23 +27,26 @@ export default function Index() { return; } - mutate(name); + createSet(name); }; + const handleChallenge = () => { + createChallenge(); + }; return ( - setPopupVisible(false)} - onSave={handleSave} - /> + setPopupVisible(false)} onSave={handleSave} /> {t('home.createFlashcards')} + + {t('home.challengeYourself')} + + ); @@ -53,8 +60,8 @@ const styles = StyleSheet.create({ paddingVertical: 100, }, content: { - rowGap: 10, - marginBottom: 10, + rowGap: 10, + marginBottom: 10, justifyContent: 'center', alignItems: 'center', }, From 300e9e3d09b41f22a734feed7a6b901c5a02188e Mon Sep 17 00:00:00 2001 From: JH Date: Sat, 29 Mar 2025 14:55:01 +0100 Subject: [PATCH 4/6] useChallenge hook implemented --- src/hooks/index.tsx | 6 +++--- src/hooks/useChallenge.ts | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/hooks/index.tsx b/src/hooks/index.tsx index 4f2f75f..bbe58ff 100644 --- a/src/hooks/index.tsx +++ b/src/hooks/index.tsx @@ -1,5 +1,5 @@ export { useCreateFlashCardSet } from './useCreateFlashCardSet'; -export { useDeleteFlashCardSet } from './useDeleteFlashCardSet'; +// export { useDeleteFlashCardSet } from './useDeleteFlashCardSet'; export { useEditFlashCard } from './useEditFlashCard'; -export { useMarkAsKnown } from './useMarkAsKnown'; -export { useMarkAsUnknown } from './useMarkAsUnknown'; +export { useChallenge } from './useChallenge'; +export { useQuestions } from './useQuestions'; diff --git a/src/hooks/useChallenge.ts b/src/hooks/useChallenge.ts index 1db6241..ead997a 100644 --- a/src/hooks/useChallenge.ts +++ b/src/hooks/useChallenge.ts @@ -1,12 +1,17 @@ import { useMutation } from '@tanstack/react-query'; import { useRouter } from 'expo-router'; +// import {fetchFlashCardSets} from "@/api/challenges"; + export function useChallenge() { const router = useRouter(); return useMutation({ mutationFn: async (data) => { - // Tu dodaj logikę mutacji, np. wywołanie API + // const cardSets = fetchFlashCardSets() + // + // console.log(cardSets) + return Promise.resolve(data); }, onSuccess: () => { From b939e3c6b1f5d458cc3a657da7e168d7809733ec Mon Sep 17 00:00:00 2001 From: JH Date: Sat, 29 Mar 2025 15:23:59 +0100 Subject: [PATCH 5/6] components added --- src/components/index.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/index.tsx b/src/components/index.tsx index 0676a14..a2d5f3d 100644 --- a/src/components/index.tsx +++ b/src/components/index.tsx @@ -1,6 +1,6 @@ export { Button } from './Button'; export { Typography } from './Typography'; export { BackgroundContainer } from './BackgroundContainer'; -export {Popup} from './Popup'; -export { FlashCardInput} from './FlashCardInput'; -export {FlipCard} from './FlipCard'; \ No newline at end of file +export { Popup } from './Popup'; +export { FlashCardInput } from './FlashCardInput'; +// export {FlipCard} from './FlipCard'; From daf0869ef9bd10d7cc2cb4bf72008b9268e8b834 Mon Sep 17 00:00:00 2001 From: JH Date: Sat, 29 Mar 2025 15:24:55 +0100 Subject: [PATCH 6/6] challenges added --- app/challenge.tsx | 50 ++++++++++++++++++++++++++++++++++----- app/questions.tsx | 32 +++++++++++++++++++++++++ src/hooks/useQuestions.ts | 17 +++++++++++++ 3 files changed, 93 insertions(+), 6 deletions(-) create mode 100644 app/questions.tsx create mode 100644 src/hooks/useQuestions.ts diff --git a/app/challenge.tsx b/app/challenge.tsx index 8193f6a..82f6992 100644 --- a/app/challenge.tsx +++ b/app/challenge.tsx @@ -1,25 +1,63 @@ -import { StyleSheet } from 'react-native'; +import { StyleSheet, View } from 'react-native'; +import { ScrollView } from 'react-native'; import { useQuery } from '@tanstack/react-query'; +import { useRouter } from 'expo-router'; +import { useTranslation } from 'react-i18next'; import { fetchFlashCardSets } from '@/api/challenges'; import { queryKeys } from '@/api/queryKyes'; -import { BackgroundContainer, Typography } from '@/components'; -import { useCreateFlashCardSet } from '@/hooks'; +import { BackgroundContainer, Button, Typography } from '@/components'; +import { useQuestions } from '@/hooks'; const Challenge = () => { - const { mutate } = useCreateFlashCardSet(); + const { t } = useTranslation(); + + // const {mutate} = useCreateFlashCardSet(); + const { data } = useQuery({ queryKey: queryKeys.sets(), queryFn: fetchFlashCardSets }); + const router = useRouter(); + + console.log(data); return ( - - Uzupełnij ten widok :) + + + + + + {t('challenge.createNewFlashcards')} + + + + + ); }; +const RenderSets = ({ data = [] }) => { + console.log(data); + + const { mutate: createQuestions } = useQuestions(); + + const handleQuestions = () => { + createQuestions(); + }; + + return ( + + {data.map((cardSet) => ( + + + + ))} + + ); +}; + export default Challenge; const styles = StyleSheet.create({ diff --git a/app/questions.tsx b/app/questions.tsx new file mode 100644 index 0000000..2e90561 --- /dev/null +++ b/app/questions.tsx @@ -0,0 +1,32 @@ +import { StyleSheet, View } from 'react-native'; + +import { BackgroundContainer, Typography } from '@/components'; + +const Questions = () => { + return ( + + + + questions test + + + + ); +}; + +export default Questions; + +const styles = StyleSheet.create({ + innerContainer: { + flex: 1, + justifyContent: 'space-between', + alignItems: 'center', + paddingVertical: 100, + }, + logo: { + gap: 10, + justifyContent: 'center', + alignItems: 'center', + }, + flashCardsButtons: { gap: 5, width: '90%' }, +}); diff --git a/src/hooks/useQuestions.ts b/src/hooks/useQuestions.ts new file mode 100644 index 0000000..3d37bbd --- /dev/null +++ b/src/hooks/useQuestions.ts @@ -0,0 +1,17 @@ +import { useMutation } from '@tanstack/react-query'; +import { useRouter } from 'expo-router'; + +// import {fetchFlashCardSets} from "@/api/challenges"; + +export function useQuestions() { + const router = useRouter(); + + return useMutation({ + mutationFn: async (data) => { + return Promise.resolve(data); + }, + onSuccess: () => { + router.push('/questions'); + }, + }); +}