Skip to content

Commit

Permalink
Merge pull request #36 from JangAyeon/feat/visit
Browse files Browse the repository at this point in the history
Feat/visit: 섬 방문 URL에 사용자 이메일 및 이름 드러나지 않게 함
  • Loading branch information
JangAyeon authored Feb 26, 2024
2 parents 75ce19d + 392aa05 commit db9fdd1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion apis/authApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const getDsIdValid = (dsId: FormDataEntryValue) =>
.single()

const getUserEmailExist = (email: FormDataEntryValue) =>
supabase.from("userinfo").select("*").eq("email", email).single()
supabase.from("userinfo").select("email, name").eq("email", email).single()
const authApi = {
signup,
login,
Expand Down
8 changes: 7 additions & 1 deletion components/forms/VisitForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,25 @@ import Squiggly from "@/public/assets/green/squiggly.svg"

const VisitForm = () => {
const [friendEmail, onChangeFriendEmail, setFriendEmail] = useInput("")
const [friendName, onChangeFriendName, setFriendName] = useInput("")
const { state, text, isOpen, setStateModal, closeModal, setIsOpen } =
useStateModal()
const [isEmailExist, setEmailExist] = useState(false)
const router = useRouter()

const visitFriend = () => {
router.push(`/island?id=${friendEmail}`)
// 브라우저 url에 사용자 Email, name 노출 안되게
router.push(`/island?id=${friendEmail}&name=${friendName}`, "/island")
}

const checkValidEmail = async (e: FormEvent<HTMLFormElement>) => {
e.preventDefault()
const { data, error } = await authApi.getUserEmailExist(friendEmail)
if (data) {
const { email, name } = data
setFriendName(name)
setFriendEmail(email)
console.log(data)
setEmailExist(true)
} else {
setStateModal({
Expand Down
10 changes: 8 additions & 2 deletions components/molecules/LandControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ import islandApi from "@/apis/island"

import { setIslandIsEdit } from "@/utils/island"

const LandControl = ({ isOwner }: { isOwner: boolean }) => {
const LandControl = ({
isOwner,
name = "",
}: {
isOwner: boolean
name: string
}) => {
const { islandType, islandItemLoc, islandIsEdit } = useIsland()
const { userName, userEmail } = useUserProfile()
const { state, text, isOpen, setStateModal, closeModal, setIsOpen } =
Expand Down Expand Up @@ -55,7 +61,7 @@ const LandControl = ({ isOwner }: { isOwner: boolean }) => {
mainColor={"--color-yellow-01"}
pointColor={"--color-green-04"}
textColor={"--color-green-04"}
text={userName}
text={isOwner ? userName : name}
textSize={1.6}
borderRadius={1.5}
/>
Expand Down
4 changes: 2 additions & 2 deletions components/pages/island/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const Island = () => {
const { islandIsEdit, islandType } = useIsland()
const [isOwner, setIsOwner] = useState(true)
const {
query: { id },
query: { id, name },
} = useRouter()

const { userEmail } = useUserProfile()
Expand All @@ -41,7 +41,7 @@ const Island = () => {
endColor={BACKGROUND_COLOR[islandType].endColor}
degree="180deg"
>
<LandControl isOwner={isOwner} />
<LandControl isOwner={isOwner} name={name as string} />

<LandContent isOwner={isOwner} />
{isOwner && islandIsEdit && (
Expand Down

0 comments on commit db9fdd1

Please sign in to comment.