Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/delivery #82

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
52 changes: 37 additions & 15 deletions apps/delivery/app/(stack)/auth/login/index.tsx
Original file line number Diff line number Diff line change
@@ -1,56 +1,78 @@
import { Button, ButtonText } from "@/components/ui/button";
import { useFormInput } from "@/features/shared/ui/FormInput";
import { Button, ButtonSpinner, ButtonText } from "@/components/ui/button";
import { Text } from "@/components/ui/text";
import { VStack } from "@/components/ui/vstack";
import useGlobalToast from "@/features/shared/hooks/useGlobalToast";
import { FormInput } from "@/features/shared/ui/FormInput";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useGlobalToast 훅이 궁금해서 찾아보니까
파일이 없는 것 같아요

커밋 누락일까요?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아 ㅋㅋㅋ 맞아요 커밋 누락이네여
추가했습니다 감사합니다 ㅎㅎ

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

매의눈... 멋집니다

import { useUserStore } from "@/features/user/store/user.store";
import { supabase } from "@/supabase/utils/supabase";
import { zodResolver } from "@hookform/resolvers/zod";
import { useRouter } from "expo-router";
import { useForm } from "react-hook-form";
import { Text, View } from "react-native";
import { z } from "zod";

const schema = z.object({
email: z.string().email("이메일 형식으로 입력해주세요").default(""),
password: z.string().min(1, "필수 값 입니다.").default(""),
password: z.string().min(6, "6자 이상으로 입력하세요").default(""),
});

type schemaType = z.infer<typeof schema>;
export default function Signin() {
const {
control,
handleSubmit,
formState: { errors },
formState: { errors, isSubmitting },
} = useForm<schemaType>({ resolver: zodResolver(schema) });

const { showToast } = useGlobalToast();
const router = useRouter();
const { setUser } = useUserStore();
const { FormInput } = useFormInput({ control, errors });

const router = useRouter();
const formInputProps = { control, errors };

return (
<View className={"flex gap-[12px]"}>
<Text className={"title-3 mx-auto"}>로그인</Text>
<VStack space={"md"}>
<Text size={"xl"} className={"mx-auto"}>
로그인
</Text>

<FormInput label={"이메일을 입력하세요"} name={"email"} />
<FormInput label={"페스워드 입력하세요"} name={"password"} />
<FormInput
name={"email"}
label={"이메일을 입력하세요"}
{...formInputProps}
/>
<FormInput
name={"password"}
label={"페스워드를 입력하세요"}
{...formInputProps}
/>

<Button
disabled={isSubmitting}
onPress={handleSubmit(async ({ email, password }) => {
const res = //
await supabase.auth.signInWithPassword({ email, password });

const user = res.data.user;
if (!user) return alert("유저가 존재하지 않습니다");

if (!user)
return showToast({
title: "유저가 존재하지 않습니다",
action: "error",
});

const { data } = await supabase.from("user").select("name").single();
if (!data?.name) return alert("에러발생");
if (!data?.name)
return showToast({ title: "에러 발생", action: "error" });

setUser({ email, id: user.id, name: data.name });

showToast({ title: "로그인 되었습니다" });
router.push("/(tabs)/mypage");
})}
>
<ButtonText>로그인</ButtonText>
<ButtonText className={"text-white"}>로그인</ButtonText>
{isSubmitting && <ButtonSpinner />}
</Button>
</View>
</VStack>
);
}
53 changes: 37 additions & 16 deletions apps/delivery/app/(stack)/auth/signup/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { Button, ButtonText } from "@/components/ui/button";
import { useFormInput } from "@/features/shared/ui/FormInput";
import { Button, ButtonSpinner, ButtonText } from "@/components/ui/button";
import { Text } from "@/components/ui/text";
import { VStack } from "@/components/ui/vstack";
import useGlobalToast from "@/features/shared/hooks/useGlobalToast";
import { FormInput } from "@/features/shared/ui/FormInput";
import { supabase } from "@/supabase/utils/supabase";
import { zodResolver } from "@hookform/resolvers/zod";
import { useRouter } from "expo-router";
import { useForm } from "react-hook-form";
import { Text, View } from "react-native";
import { z } from "zod";

const schema = z.object({
email: z.string().email("이메일 형식으로 입력해주세요").default(""),
password: z.string().min(1, "필수 값 입니다.").default(""),
password: z.string().min(6, "6자 이상으로 입력하세요").default(""),
name: z.string().min(1, "필수 값 입니다.").default(""),
});

Expand All @@ -18,36 +20,55 @@ export default function Signup() {
const {
control,
handleSubmit,
formState: { errors },
formState: { errors, isSubmitting },
} = useForm<schemaType>({ resolver: zodResolver(schema) });

const { FormInput } = useFormInput({ control, errors });
const { showToast } = useGlobalToast();
const router = useRouter();

return (
<View className={"flex gap-[12px]"}>
<Text className={"title-3 mx-auto"}>화원가입</Text>

<FormInput label={"이메일을 입력하세요"} name={"email"} />
const formInputProps = { control, errors };

<FormInput label={"페스워드 입력하세요"} name={"password"} />
return (
<VStack space={"md"}>
<Text size={"xl"} className={"mx-auto"}>
화원가입
</Text>

<FormInput label={"이름을 입력하세요"} name={"name"} />
<FormInput
name={"email"}
label={"이메일을 입력하세요"}
{...formInputProps}
/>
<FormInput
name={"password"}
label={"페스워드 입력하세요"}
{...formInputProps}
/>
<FormInput
name={"name"}
label={"이름을 입력하세요"}
{...formInputProps}
/>

<Button
disabled={isSubmitting}
onPress={handleSubmit(async ({ email, name, password }) => {
const res = await supabase.auth.signUp({
email,
password,
options: { data: { name } },
});
if (res.error) return alert("에러발생");
if (res.error)
return showToast({ title: "에러발생", action: "error" });

showToast({ title: "회원가입 되었습니다" });

router.push("/(stack)/auth/login");
})}
>
<ButtonText>가입하기</ButtonText>
<ButtonText className={"text-white"}>가입하기</ButtonText>
{isSubmitting && <ButtonSpinner />}
</Button>
</View>
</VStack>
);
}
2 changes: 0 additions & 2 deletions apps/delivery/app/(tabs)/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Input, InputField, InputSlot } from "@/components/ui/input";
import DarkModeToggle from "@/components/web-layout/DarkModeToggle";
import { useColorToken } from "@/features/shared/hooks/useThemeColor";
import { Ionicons } from "@expo/vector-icons";
import { cn } from "@infinite-loop-factory/common";
Expand Down Expand Up @@ -66,7 +65,6 @@ export default function HomeScreen() {
<Ionicons name={"calculator"} size={24} color={typography} />
<Ionicons name={"search"} size={24} color={typography} />
<Ionicons name={"cart-outline"} size={24} color={typography} />
<DarkModeToggle />
</View>
</View>

Expand Down
68 changes: 37 additions & 31 deletions apps/delivery/app/(tabs)/mypage.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Box } from "@/components/ui/box";
import { Button, ButtonText } from "@/components/ui/button";
import { HStack } from "@/components/ui/hstack";
import { Text } from "@/components/ui/text";
import { useColorToken } from "@/features/shared/hooks/useThemeColor";
import { useUserStore } from "@/features/user/store/user.store";
import { Ionicons } from "@expo/vector-icons";
import { useRouter } from "expo-router";
import { Text } from "react-native";
import { View } from "react-native";
import { SafeAreaView } from "react-native-safe-area-context";

export default function MyPage() {
Expand All @@ -19,70 +20,75 @@ export default function MyPage() {
return (
<SafeAreaView className={"flex-1 "}>
{/*header*/}
<View className={"flex flex-row items-center justify-between p-[16px]"}>
<View>
<Text className={"title-3 !font-extrabold"}>마이배민</Text>
</View>
<Box className={"flex flex-row items-center justify-between p-[16px]"}>
<Box>
<Text size={"xl"}>마이배민</Text>
</Box>

<View className="flex flex-row items-center gap-5">
<Box className="flex flex-row items-center gap-5">
<Ionicons name={"notifications"} size={24} color={typography} />
<Ionicons name={"settings"} size={24} color={typography} />
</View>
</View>
</Box>
</Box>

{/* body */}
<View className={"flex px-[16px]"}>
<View className={"flex flex-row gap-[16px]"}>
<Box className={"flex px-[16px]"}>
<Box className={"flex flex-row gap-[16px]"}>
{/*image */}
<View
<Box
className={"min-h-[53px] min-w-[53px] rounded-full bg-primary"}
/>

{/* 상태 */}
<View className={"flex gap-[4px]"}>
<View>
<Box className={"flex gap-[4px]"}>
<Box>
{user ? (
<View className={"flex flex-row gap-[8px]"}>
<HStack className={"items-center"} space={"md"}>
<Text className={"body-2"}>{user?.name}</Text>
<Button onPress={logout} size={"2xs"}>
<Button
className={"text-white"}
onPress={logout}
size={"2xs"}
>
<ButtonText>로그아웃</ButtonText>
</Button>
</View>
</HStack>
) : (
<View className={"flex flex-row gap-[4px]"}>
<Box className={"flex flex-row gap-[4px]"}>
<Button
onPress={() => router.push("/auth/login")}
size={"2xs"}
>
<ButtonText>로그인</ButtonText>
<ButtonText className={"text-white"}>로그인</ButtonText>
</Button>
<Button
onPress={() => router.push("/auth/signup")}
size={"2xs"}
>
<ButtonText>회원가입</ButtonText>
<ButtonText className={"text-white"}>회원가입</ButtonText>
</Button>
</View>
</Box>
)}
</View>
<View className={"flex flex-row gap-[8px]"}>
</Box>
<Box className={"flex flex-row gap-[8px]"}>
<Text className={"label-6"}>리뷰관리</Text>
<Text className={"label-6"}>|</Text>
<Text className={"label-6"}>주소관리</Text>
</View>
</View>
</View>
</Box>
</Box>
</Box>

<View className={"min-h-[16px]"} />
<Box className={"min-h-[16px]"} />

{/* AD 영역*/}
<View className={"rounded-xl border border-outline-300 p-[12px]"}>
<Box className={"rounded-xl border border-outline-300 p-[12px]"}>
<Text className={"body-5 !font-extrabold"}>
샤르르 소리까지 나는{" "}
<Text className={"text-yellow-500"}>달달한</Text> 나의 배민 취향
<Text className={"text-yellow-500"}>달달한</Text>{" "}
<Text>나의 배민 취향</Text>
</Text>
</View>
</View>
</Box>
</Box>
</SafeAreaView>
);
}
Loading
Loading