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/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', }, 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/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/`, }); 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'; 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 new file mode 100644 index 0000000..ead997a --- /dev/null +++ b/src/hooks/useChallenge.ts @@ -0,0 +1,21 @@ +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) => { + // const cardSets = fetchFlashCardSets() + // + // console.log(cardSets) + + return Promise.resolve(data); + }, + onSuccess: () => { + router.push('/challenge'); + }, + }); +} 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'); + }, + }); +}