diff --git a/.env b/.env new file mode 100644 index 0000000..54b749c --- /dev/null +++ b/.env @@ -0,0 +1 @@ +EXPO_PUBLIC_API_URL: "http://127.0.0.1:8000/api" \ No newline at end of file diff --git a/.gitignore b/.gitignore index 05647d5..fdb373c 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,11 @@ yarn-error.* # typescript *.tsbuildinfo + +# @generated expo-cli sync-2b81b286409207a5da26e14c78851eb30d8ccbdb +# The following patterns were generated by expo-cli + +expo-env.d.ts +# @end expo-cli + +.gz \ No newline at end of file diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..dcdb142 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,23 @@ +{ + "arrowParens": "always", + "bracketSpacing": true, + "endOfLine": "lf", + "htmlWhitespaceSensitivity": "css", + "insertPragma": false, + "singleAttributePerLine": false, + "bracketSameLine": false, + "jsxBracketSameLine": false, + "jsxSingleQuote": false, + "printWidth": 80, + "proseWrap": "preserve", + "quoteProps": "as-needed", + "requirePragma": false, + "semi": true, + "singleQuote": false, + "tabWidth": 2, + "trailingComma": "es5", + "useTabs": true, + "embeddedLanguageFormatting": "auto", + "vueIndentScriptAndStyle": false, + "parser": "typescript" +} \ No newline at end of file diff --git a/.yarn/install-state.gz b/.yarn/install-state.gz index 58027fd..7155dbd 100644 Binary files a/.yarn/install-state.gz and b/.yarn/install-state.gz differ diff --git a/app/(for-not-verified)/_layout.tsx b/app/(for-not-verified)/_layout.tsx index 7bb4249..8f6edf0 100644 --- a/app/(for-not-verified)/_layout.tsx +++ b/app/(for-not-verified)/_layout.tsx @@ -5,9 +5,9 @@ import { Redirect, Slot } from "expo-router"; * Use it on protected screens */ export default function ProtectedLayout() { - const [access] = useAuth((state) => [state.access]); + const [access] = useAuth((state) => [state.access]); - if (access) return ; + if (access) return ; - return ; + return ; } diff --git a/app/(for-not-verified)/login.tsx b/app/(for-not-verified)/login.tsx index 32e892f..706964d 100644 --- a/app/(for-not-verified)/login.tsx +++ b/app/(for-not-verified)/login.tsx @@ -1,10 +1,10 @@ import { - ActivityIndicator, - StyleSheet, - TouchableOpacity, - View, - Text, + ActivityIndicator, + StyleSheet, + TouchableOpacity, + View, } from "react-native"; +import { Text, useTheme } from "react-native-paper"; import { router } from "expo-router"; import { useForm } from "react-hook-form"; import ControlledInput from "../../components/ControlledInput"; @@ -13,80 +13,90 @@ import { CredentialsData } from "../../stores/auth/types"; import { z } from "zod"; import { zodResolver } from "@hookform/resolvers/zod"; import CenteredLayout from "../../components/CenteredLayout/CenteredLayout"; +import { Button } from "react-native-paper"; const defaultValues = { username: "", password: "" }; const loginSchema = z.object({ - username: z.string().min(1, "Pole jest wymagane"), - password: z.string().min(1, "Pole jest wymagane"), + username: z.string().min(1, "Pole jest wymagane"), + password: z.string().min(1, "Pole jest wymagane"), }); export default function TabOneScreen() { - const { control, handleSubmit, setError } = useForm({ - defaultValues, - resolver: zodResolver(loginSchema), - }); - const [login, loading] = useAuth((state) => [state.login, state.loading]); - const onSubmit = async (credentials: CredentialsData) => { - try { - await login(credentials); - } catch (err) { - console.error(err); - } - }; + const theme = useTheme(); + const { control, handleSubmit, setError } = useForm({ + defaultValues, + resolver: zodResolver(loginSchema), + }); + const [login, loading] = useAuth((state) => [state.login, state.loading]); + const onSubmit = async (credentials: CredentialsData) => { + try { + await login(credentials); + router.replace("/home"); + } catch (err) { + console.error(err); + } + }; - return ( - - - - - router.push("/register")}> - - Don't have an account? - - {" Sign up"} - - - - - Enter - - {loading ? : null} - - - ); + return ( + + + + + + {loading ? : null} + router.push("/register")}> + + Nie posiadasz konta? + + + {"Zarejestruj się"} + + + + + ); } const styles = StyleSheet.create({ - button: { - backgroundColor: "#15CA78", - color: "#fff", - paddingHorizontal: 12, - paddingVertical: 8, - borderRadius: 16, - elevation: 4, - // boxShadow: "0px 4px 4px 0px rgba(0, 0, 0, 0.15)" - }, - buttonText: { - color: "#fff", - }, - separator: { - marginVertical: 30, - height: 1, - width: "80%", - }, + button: { + backgroundColor: "#15CA78", + color: "#fff", + paddingHorizontal: 12, + paddingVertical: 8, + borderRadius: 16, + elevation: 4, + // boxShadow: "0px 4px 4px 0px rgba(0, 0, 0, 0.15)" + }, + buttonText: { + color: "#fff", + }, + separator: { + marginVertical: 30, + height: 1, + width: "80%", + }, }); diff --git a/app/(for-not-verified)/register.tsx b/app/(for-not-verified)/register.tsx index 23a4699..7c66660 100644 --- a/app/(for-not-verified)/register.tsx +++ b/app/(for-not-verified)/register.tsx @@ -1,9 +1,9 @@ import { - ActivityIndicator, - StyleSheet, - TouchableOpacity, - View, - Text, + ActivityIndicator, + StyleSheet, + TouchableOpacity, + View, + ScrollView, } from "react-native"; import { router } from "expo-router"; @@ -13,96 +13,149 @@ import { useAuth } from "../../stores/auth/auth"; import { z } from "zod"; import { zodResolver } from "@hookform/resolvers/zod"; import CenteredLayout from "../../components/CenteredLayout/CenteredLayout"; +import { Button, Text, useTheme } from "react-native-paper"; -const defaultValues = { username: "", password: "", rePassword: "" }; +const defaultValues = { + username: "", + password: "", + rePassword: "", + phone_number: "", + email: "", + first_name: "", + last_name: "", +}; const registerSchema = z - .object({ - username: z.string().min(1, "Pole jest wymagane"), - password: z.string().min(1, "Pole jest wymagane"), - rePassword: z.string().min(1, "Pole jest wymagane"), - }) - .refine(({ password, rePassword }) => password === rePassword, { - path: ["password"], - message: "Passwords don't match", - }); + .object({ + username: z.string().min(1, "Pole jest wymagane"), + password: z.string().min(1, "Pole jest wymagane"), + rePassword: z.string().min(1, "Pole jest wymagane"), + phone_number: z.string().min(1, "Pole jest wymagane"), + email: z.string().min(1, "Pole jest wymagane"), + first_name: z.string().min(1, "Pole jest wymagane"), + last_name: z.string().min(1, "Pole jest wymagane"), + }) + .refine(({ password, rePassword }) => password === rePassword, { + path: ["password"], + message: "Passwords don't match", + }); export default function TabOneScreen() { - const { control, handleSubmit } = useForm({ - defaultValues, - resolver: zodResolver(registerSchema), - }); - const [register, loading] = useAuth((state) => [ - state.register, - state.loading, - ]); + const theme = useTheme(); + const { control, handleSubmit } = useForm({ + defaultValues, + resolver: zodResolver(registerSchema), + }); + const [register, loading] = useAuth((state) => [ + state.register, + state.loading, + ]); - const onSubmit = async (credentials: typeof defaultValues) => { - try { - await register(credentials); - router.replace("/edit-user"); - } catch (err) { - console.error(JSON.stringify(err)); - } - }; + const onSubmit = async (credentials: typeof defaultValues) => { + const { rePassword, ...rest } = credentials; + try { + await register(rest); + router.replace("/home"); + } catch (err) { + console.error(JSON.stringify(err)); + } + }; - return ( - - - - - - router.push("/login")} - > - - I have an account! - - {" Sign in"} - - - - - Done! - - {loading ? : null} - - - ); + return ( + + + + + + + + + + + + {loading ? : null} + router.push("/login")}> + + Posiadasz konto? + + + {"Zaloguj się"} + + + + + + ); } const styles = StyleSheet.create({ - button: { - backgroundColor: "#15CA78", - color: "#fff", - paddingHorizontal: 12, - paddingVertical: 8, - borderRadius: 16, - elevation: 4, - // boxShadow: "0px 4px 4px 0px rgba(0, 0, 0, 0.15)" - }, - buttonText: { - color: "#fff", - }, + button: { + backgroundColor: "#15CA78", + color: "#fff", + paddingHorizontal: 12, + paddingVertical: 8, + borderRadius: 16, + elevation: 4, + // boxShadow: "0px 4px 4px 0px rgba(0, 0, 0, 0.15)" + }, + buttonText: { + color: "#fff", + }, }); diff --git a/app/(protected)/_layout.tsx b/app/(protected)/_layout.tsx index 2994b4a..7c02bc6 100644 --- a/app/(protected)/_layout.tsx +++ b/app/(protected)/_layout.tsx @@ -7,21 +7,28 @@ import { StyleSheet, View } from "react-native"; * Use it on protected screens */ export default function ProtectedLayout() { - const [access] = useAuth((state) => [state.access]); + const [access] = useAuth((state) => [state.access]); - if (!access) return ; + if (!access) return ; - return ( - - - - ); + return ( + + + + ); } const styles = StyleSheet.create({ - container: { - flex: 1, - alignItems: "center", - justifyContent: "center", - }, + container: { + flex: 1, + alignItems: "center", + justifyContent: "center", + }, }); diff --git a/app/(protected)/creator/creator.tsx b/app/(protected)/creator/creator.tsx new file mode 100644 index 0000000..5d0f70d --- /dev/null +++ b/app/(protected)/creator/creator.tsx @@ -0,0 +1,116 @@ +import ControlledInput from "@/components/ControlledInput"; +import { ScrollView, View, StyleSheet } from "react-native"; +import { z } from "zod"; +import { Text, IconButton } from "react-native-paper"; +import { useForm } from "react-hook-form"; +import { zodResolver } from "@hookform/resolvers/zod"; +// import { DatePickerInput } from "react-native-paper-dates"; + +const defaultValues = { + title: "", + description: "", + short_description: "", + start_timestamp: 0, + end_timestamp: 0, + location: "Kraków", + price: 0, +}; +const registerSchema = z.object({ + title: z.string().min(1, "Pole jest wymagane"), + description: z.string().min(1, "Pole jest wymagane"), + short_description: z.string().min(1, "Pole jest wymagane"), + start_timestamp: z.number().min(1, "Pole jest wymagane"), + end_timestamp: z.number().min(1, "Pole jest wymagane"), + location: z.string().min(1, "Pole jest wymagane"), + price: z.number().min(1, "Pole jest wymagane"), +}); +export default function eventCreator() { + const returnPress = () => { + console.log("Powrót"); + }; + const { control, handleSubmit } = useForm({ + defaultValues, + resolver: zodResolver(registerSchema), + }); + return ( + + + + Mój Profil + + + + + + + + + + + + + + + + + + + + + + + + + + + + ); +} +const styles = StyleSheet.create({ + title: { + textAlign: "right", + }, + myButton: { + display: "flex", + }, + titleView: { + padding: 20, + }, + mainView: { flex: 1 }, + button: { + backgroundColor: "#15CA78", + color: "#fff", + paddingHorizontal: 12, + paddingVertical: 8, + borderRadius: 16, + elevation: 4, + // boxShadow: "0px 4px 4px 0px rgba(0, 0, 0, 0.15)" + }, +}); diff --git a/app/(protected)/creator/myButton.tsx b/app/(protected)/creator/myButton.tsx new file mode 100644 index 0000000..1e50e5c --- /dev/null +++ b/app/(protected)/creator/myButton.tsx @@ -0,0 +1,43 @@ +import { router } from "expo-router"; +import { View, StyleSheet } from "react-native"; +import { IconButton, Text } from "react-native-paper"; +export default function MyButton() { + const pressHandler = () => { + router.push("/creator/creator"); + }; + return ( + + + + Dodaj post + + + ); +} + +const styles = StyleSheet.create({ + create: { + backgroundColor: "#004A33", + }, + background: { + backgroundColor: "#00A271", + width: "100%", + padding: 40, + borderTopLeftRadius: 20, + borderTopRightRadius: 20, + marginTop: 20, + display: "flex", + justifyContent: "center", + flexDirection: "row", + alignContent: "center", + }, +}); diff --git a/app/(protected)/home.tsx b/app/(protected)/home.tsx new file mode 100644 index 0000000..57d84aa --- /dev/null +++ b/app/(protected)/home.tsx @@ -0,0 +1,96 @@ +import { FlatList, ScrollView, StyleSheet, View } from "react-native"; +import { IconButton, Text, useTheme } from "react-native-paper"; +import { useEffect, useState } from "react"; +import Post, { postInterface } from "./post"; +import api from "@/stores/api"; +import MyButton from "./creator/myButton"; + +const renderItem = ({ item }: { item: postInterface }) => { + return ( + + ); +}; + +export default function TabOneScreen() { + const [data, setData] = useState>([]); + + useEffect(() => { + async function asyncCall() { + try { + const fetchedData = await api.getPosts(); + setData(fetchedData); // Update state with the fetched data + } catch (err) { + console.error(err); + } + } + asyncCall(); + }, []); + + const pressHandler = () => { + console.log("Dzieki dziala"); + }; + return ( + + + + Mój Profil + + + + item.id} + extraData={data} + /> + + + + + ); +} + +const styles = StyleSheet.create({ + title: { + textAlign: "right", + }, + titleView: { + padding: 20, + }, + mainView: { flex: 1 }, + button: { + backgroundColor: "#15CA78", + color: "#fff", + paddingHorizontal: 12, + paddingVertical: 8, + borderRadius: 16, + elevation: 4, + // boxShadow: "0px 4px 4px 0px rgba(0, 0, 0, 0.15)" + }, + buttonText: { + color: "#fff", + }, + separator: { + marginVertical: 30, + height: 1, + width: "80%", + }, +}); diff --git a/app/(protected)/index.tsx b/app/(protected)/index.tsx deleted file mode 100644 index 3a9de8d..0000000 --- a/app/(protected)/index.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { View } from "react-native"; - -export default function HomePage() { - return XD; -} diff --git a/app/(protected)/post.tsx b/app/(protected)/post.tsx new file mode 100644 index 0000000..467ee9b --- /dev/null +++ b/app/(protected)/post.tsx @@ -0,0 +1,38 @@ +import { Card, Text, Button } from "react-native-paper"; + +export type postInterface = { + id: string; + title: string; + short_description: string; + description: string; + issuer_id: number; + created_at: number; + start_timestamp: number; + end_timestamp: number; + location: string; + price: number; + visible: boolean; +}; +export default function Post({ + id, + title, + short_description, + description, + issuer_id, + created_at, + start_timestamp, + end_timestamp, + location, + price, + visible, +}: postInterface) { + return ( + + + + + + + + ); +} diff --git a/app/+html.tsx b/app/+html.tsx index cb31090..40ee654 100644 --- a/app/+html.tsx +++ b/app/+html.tsx @@ -1,30 +1,33 @@ -import { ScrollViewStyleReset } from 'expo-router/html'; +import { ScrollViewStyleReset } from "expo-router/html"; // This file is web-only and used to configure the root HTML for every // web page during static rendering. // The contents of this function only run in Node.js environments and // do not have access to the DOM or browser APIs. export default function Root({ children }: { children: React.ReactNode }) { - return ( - - - - - + return ( + + + + + - {/* + {/* Disable body scrolling on web. This makes ScrollView components work closer to how they do on native. However, body scrolling is often nice to have for mobile web. If you want to enable it, remove this line. */} - + - {/* Using raw CSS styles as an escape-hatch to ensure the background color never flickers in dark-mode. */} -