-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from AmorGakCo/feat/RemainingPage#2
Feat/remaining page#2
- Loading branch information
Showing
15 changed files
with
253 additions
and
26 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
'use client'; | ||
import { Button } from '@/components/ui/button'; | ||
import { | ||
Form, | ||
FormField, | ||
FormItem, | ||
FormLabel, | ||
FormControl, | ||
FormMessage, | ||
} from '@/components/ui/form'; | ||
import { Input } from '@/components/ui/input'; | ||
import { zodResolver } from '@hookform/resolvers/zod'; | ||
import { useForm } from 'react-hook-form'; | ||
import { formSchema } from '../_lib/InfoFormSchema'; | ||
import { z } from 'zod'; | ||
import { useEffect, useState } from 'react'; | ||
import useLocationStore from '@/hooks/useLocationStore'; | ||
import { geolocation } from '@/app/_types/Map'; | ||
import { getCurrentPosition } from '../../_lib/getCurrentPosition'; | ||
import { fetchMemberInfo } from '../_lib/fetchMemberInfo'; | ||
|
||
export function InfoForm() { | ||
const setCurLocation = useLocationStore((state) => state.setCurLocation); | ||
const curLocation = useLocationStore((state) => state.curLocation); | ||
const [location, setLocation] = useState<geolocation>({ | ||
center: { | ||
lat: 37.54619261015808, | ||
lng: 126.7303762529431, | ||
}, | ||
radius: 300, | ||
errMsg: null, | ||
isLoading: true, | ||
}); | ||
useEffect(() => { | ||
async function fetchPosition() { | ||
if (curLocation.centerLat === 0 && curLocation.centerLon === 0) { | ||
const { currentLat: centerLat, currentLon: centerLon } = | ||
await getCurrentPosition(); | ||
setCurLocation({ centerLat, centerLon }); | ||
} | ||
setLocation((prev) => ({ | ||
...prev, | ||
centerLat: curLocation.centerLat, | ||
centerLon: curLocation.centerLon, | ||
})); | ||
} | ||
fetchPosition(); | ||
}, []); | ||
const form = useForm<z.infer<typeof formSchema>>({ | ||
resolver: zodResolver(formSchema), | ||
mode: 'onChange', | ||
defaultValues: { | ||
smsNotificationSetting: true, | ||
latitude: location.center.lat, | ||
longitude: location.center.lng, | ||
}, | ||
}); | ||
return ( | ||
<Form {...form}> | ||
<div className="w-full flex justify-center"> | ||
<form | ||
onSubmit={form.handleSubmit(onSubmit)} | ||
className="gap-6 flex flex-col mt-6 px-6 w-full max-w-96" | ||
> | ||
<FormField | ||
control={form.control} | ||
name="smsNotificationSetting" | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormLabel>SMS 알림</FormLabel> | ||
<FormControl> | ||
<div className="flex gap-4"> | ||
<Button | ||
onClick={() => field.onChange(true)} | ||
type="button" | ||
className="w-full" | ||
variant={`${field.value ? 'default' : 'outline'}`} | ||
> | ||
ON | ||
</Button> | ||
<Button | ||
onClick={() => field.onChange(false)} | ||
className="w-full" | ||
type="button" | ||
variant={`${field.value ? 'outline' : 'default'}`} | ||
> | ||
OFF | ||
</Button> | ||
</div> | ||
</FormControl> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
<FormField | ||
control={form.control} | ||
name="githubUrl" | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormLabel>Github 주소 설정</FormLabel> | ||
<FormControl> | ||
<Input | ||
placeholder="github 주소를 입력해주세요" | ||
{...field} | ||
className="w-full" | ||
/> | ||
</FormControl> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
<FormField | ||
control={form.control} | ||
name="phoneNumber" | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormLabel>전화번호</FormLabel> | ||
<FormControl> | ||
<Input placeholder="전화번호를 입력해주세요" {...field} /> | ||
</FormControl> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
<Button type="submit" className="mt-40"> | ||
설정 | ||
</Button> | ||
</form> | ||
</div> | ||
</Form> | ||
); | ||
} | ||
async function onSubmit(value: z.infer<typeof formSchema>) { | ||
const data = await fetchMemberInfo(value); | ||
console.log(data); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { z } from "zod"; | ||
|
||
|
||
const githubUrlRegex = /^https:\/\/github\.com\/[a-zA-Z0-9-_]+(\/[a-zA-Z0-9-_]+)?$/; | ||
const phoneNumberRegex = /^010-?\d{4}-?\d{4}$/; // 한국 010 번호 형식 | ||
|
||
export const formSchema = z | ||
.object({ | ||
latitude: z.number(), | ||
longitude: z.number(), | ||
smsNotificationSetting: z | ||
.boolean(), | ||
githubUrl: z | ||
.string() | ||
.url("유효한 URL 형식이 아닙니다.") | ||
.regex(githubUrlRegex, "올바른 GitHub URL을 입력해주세요. 예: https://github.com/username 또는 https://github.com/username/repo"), | ||
phoneNumber: z | ||
.string() | ||
.regex(phoneNumberRegex, "유효한 전화번호를 입력해주세요. 예: 010-1234-5678 또는 01012345678"), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { fetchWithAuth } from '@/app/(afterLogin)/_lib/FetchWithAuth'; | ||
import { memberPatchInfo } from '@/app/_types/Api'; | ||
|
||
export async function fetchMemberInfo(data: memberPatchInfo) { | ||
try { | ||
const response = await fetchWithAuth(`/members`, { | ||
method: 'PATCH', | ||
credentials: 'include', | ||
body: JSON.stringify(data), | ||
cache: 'no-cache', | ||
}); | ||
const result = await response; | ||
if (result.status === 'success') { | ||
alert('추가정보를 등록했습니다.'); | ||
} else { | ||
console.error(result.message); | ||
alert(result.message); | ||
} | ||
|
||
return result.data; | ||
} catch (error) { | ||
console.error('Error submitting the form:', error); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,47 @@ | ||
'use client' | ||
import KakaoLoginButton from '@/components/ui/KakaoLoginButton'; | ||
import Image from 'next/image'; | ||
export default function Home() { | ||
return ( | ||
<main className="flex flex-col items-center justify-between p-24"> | ||
랜딩페이지 | ||
<main className="w-full -mb-navbarHeight min-h-[calc(100vh-48px)] overflow-auto flex flex-col items-center"> | ||
<Image | ||
width={194} | ||
height={60} | ||
alt="landing logo" | ||
src={'/landing_logo.png'} | ||
className="mt-[27px]" | ||
/> | ||
<Image | ||
width={270} | ||
height={160} | ||
alt="landing logo" | ||
src={'/landing_bg.png'} | ||
className="mt-9" | ||
/> | ||
<div className="w-full h-full flex-1 relative mt-9"> | ||
<Image | ||
layout="fill" | ||
alt="landing logo" | ||
src={'/landing_bg_2.png'} | ||
className="object-cover z-10" | ||
/> | ||
<div className="relaitve mt-14 w-full h-full relative flex flex-col text-center items-center z-30 font-extrabold text-2xl leading-relaxed"> | ||
<div className="w-[152px] flex flex-col items-start gap-2"> | ||
<div> | ||
<span className="text-blue-900">개발자</span>를 위한 | ||
</div> | ||
<div> | ||
<span className="text-blue-600">지도</span> 기반 | ||
</div> | ||
<div> | ||
<span className="text-blue-300">모각코</span> 플랫폼 | ||
</div> | ||
</div> | ||
<div className='mt-9 mb-6'> | ||
<KakaoLoginButton/> | ||
</div> | ||
</div> | ||
</div> | ||
</main> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters