-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
154 changed files
with
5,630 additions
and
2,027 deletions.
There are no files selected for viewing
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,27 @@ | ||
import axios from 'axios'; | ||
|
||
import {SearchItemType} from '@/types/home'; | ||
|
||
export async function getSearchData( | ||
page: number, | ||
areaCode: number, | ||
sigunguCode: number, | ||
placeTypeId: number, | ||
keyword: string, | ||
sort: string, | ||
categoryCode: string, | ||
) { | ||
const searchData: SearchItemType = await axios.get('/api/places/search', { | ||
params: { | ||
page: page, | ||
size: 20, | ||
areaCode: areaCode, | ||
sigunguCode: sigunguCode, | ||
placeTypeId: placeTypeId, | ||
keyword: keyword, | ||
sort: sort, | ||
categoryCode: categoryCode, | ||
}, | ||
}); | ||
return searchData; | ||
} |
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,29 +1,86 @@ | ||
import axios from 'axios'; | ||
|
||
import {postTaglineProps, postVoteTitleProps, VoteListInfo} from '@/types/vote'; | ||
import { | ||
DeleteCandidatesProps, | ||
EditVoteTitleProps, | ||
PostNewCandidateProps, | ||
PostVoteTitleProps, | ||
VoteInfo, | ||
VoteListInfo, | ||
} from '@/types/vote'; | ||
|
||
//단일vote | ||
export const getVoteInfo = async (voteId: string) => { | ||
/* ----------------------------------- G E T ---------------------------------- */ | ||
|
||
//단일 보트 | ||
export const getVoteInfo = async (voteId: number): Promise<VoteInfo> => { | ||
const response = await axios.get(`/api/votes/${voteId}`); | ||
return response.data.data; | ||
return response.data; | ||
}; | ||
|
||
//voteList in space | ||
export const getVoteListInfo = async (spaceId: string): Promise<VoteListInfo> => { | ||
//보트 리스트 | ||
export const getVoteListInfo = async (spaceId: number): Promise<VoteListInfo[]> => { | ||
const response = await axios.get(`/api/votes/${spaceId}`); | ||
return response.data.data; | ||
return response.data; | ||
}; | ||
|
||
//getVotesResults | ||
|
||
/* ----------------------------------- P O S T ---------------------------------- */ | ||
|
||
//vote 추가 | ||
export const PostNewVote = async ({spaceId, title}: postVoteTitleProps): Promise<void> => { | ||
const response = await axios.post('/api/votes', {params: {spaceId, title}}); | ||
return response.data; | ||
export const PostNewVote = async ({spaceId, title}: PostVoteTitleProps) => { | ||
try { | ||
const response = await axios.post('/api/votes', {spaceId, title}); | ||
console.log('axios 포스트 성공', response); | ||
return response; | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
}; | ||
|
||
//후보 메모 후 추가 | ||
export const postTagline = async ({voteId, placeId, tagline}: postTaglineProps) => { | ||
const response = await axios.post(`/api/votes/${voteId}`, {params: {placeId, tagline}}); | ||
export const postNewCandidate = async ({voteId, candidates}: PostNewCandidateProps) => { | ||
const response = await axios.post(`/api/votes/${voteId}`, {params: candidates}); | ||
return response.data; | ||
}; | ||
|
||
/* ----------------------------------- P U T ---------------------------------- */ | ||
|
||
//voteTitle 수정 PUT - api미정 | ||
export const editVoteTitle = async ({title, voteId}: EditVoteTitleProps) => { | ||
try { | ||
const response = await axios.put(`/api/votes/${voteId}`, {params: title}); | ||
return response.data; | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
}; | ||
|
||
/* ----------------------------------- D E L E T E ---------------------------------- */ | ||
|
||
//votes/{voteId} vote 삭제 | ||
export const deleteVote = async (voteId: number) => { | ||
try { | ||
const response = await axios.delete(`/api/votes/${voteId}`); | ||
return response.data; | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
}; | ||
|
||
//msw 돌려야함 | ||
//candidate 삭제- api 미정 / candidateId:number[] 여러아이디 배열에 담음 | ||
export const deleteCandidates = async ({voteId, candidateId}: DeleteCandidatesProps) => { | ||
try { | ||
const response = await axios.delete(`/api/votes/${voteId}/candidates/${candidateId}`); | ||
return response.data; | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
}; | ||
|
||
///votes/{voteId}/candidates candidate메모와 함께 추가 POST | ||
|
||
//votes/{voteId}/candidates/{candidatesId} 별 투표하기 POST -> + DELETE 투표 삭제? | ||
|
||
//PUT 투표 상태 변경(재진행) -> ? |
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.
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.
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.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -154,4 +154,8 @@ | |
margin-top: 2px; | ||
margin-bottom: 12px; | ||
} | ||
|
||
.removeBtn { | ||
top: 81px; | ||
} | ||
} |
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,39 @@ | ||
import styles from "./Input.module.scss"; | ||
|
||
import validationForm from "@/utils/inputValidation"; | ||
|
||
import { InputOldPasswordProps } from "@/types/auth"; | ||
|
||
function InputOldPassword({ | ||
register, | ||
dirtyFields, | ||
errors, | ||
}: InputOldPasswordProps) { | ||
return ( | ||
<section className={styles.password}> | ||
<label htmlFor="oldPassword">비밀번호</label> | ||
|
||
<input | ||
id="password" | ||
type="password" | ||
className={`${styles.input} ${ | ||
dirtyFields?.oldPassword && errors?.oldPassword ? styles.error : "" | ||
}`} | ||
placeholder="영문, 숫자, 특수문자 포함 8자 이상" | ||
{...register("oldPassword", { | ||
required: true, | ||
pattern: { | ||
value: validationForm.password, | ||
message: "비밀번호 형식이 올바르지 않습니다.", | ||
}, | ||
})} | ||
/> | ||
|
||
{!dirtyFields?.oldPassword || errors?.oldPassword ? ( | ||
<small>{errors?.oldPassword?.message}</small> | ||
) : null} | ||
</section> | ||
); | ||
} | ||
|
||
export default InputOldPassword; |
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
10 changes: 10 additions & 0 deletions
10
src/components/Auth/ModifyPassword/ModifyPasswordForm.module.scss
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,10 @@ | ||
@use "@/sass" as *; | ||
|
||
.container { | ||
position: relative; | ||
color: $neutral900; | ||
|
||
h2 { | ||
@include typography(headline); | ||
} | ||
} |
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,71 @@ | ||
import axios from "axios"; | ||
import { useState } from "react"; | ||
import { useForm } from "react-hook-form"; | ||
|
||
import styles from "./ModifyPasswordForm.module.scss"; | ||
|
||
import StepNewPassword from "./Step/StepNewPassword"; | ||
import StepOldPassword from "./Step/StepOldPassword"; | ||
|
||
import { AuthForm } from "@/types/auth"; | ||
|
||
function ModifyPasswordForm() { | ||
const { | ||
register, | ||
resetField, | ||
handleSubmit, | ||
watch, | ||
formState: { errors, dirtyFields }, | ||
} = useForm<AuthForm>({ | ||
mode: "onChange", | ||
defaultValues: { | ||
oldPassword: "", | ||
password: "", | ||
passwordConfirm: "", | ||
}, | ||
}); | ||
const watchFields = watch(); | ||
|
||
// steps : oldPassword, newPassword | ||
const [step, setStep] = useState("oldPassword"); | ||
const [token, setToken] = useState(""); | ||
|
||
const onSubmit = async () => { | ||
try { | ||
const res = axios.post("/api/auth/modify/password", { | ||
token, | ||
newPassword: watchFields.password, | ||
}); | ||
|
||
console.log(res); | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
}; | ||
|
||
return ( | ||
<form className={styles.container} onSubmit={handleSubmit(onSubmit)}> | ||
{step === "oldPassword" && ( | ||
<StepOldPassword | ||
setToken={setToken} | ||
register={register} | ||
dirtyFields={dirtyFields} | ||
errors={errors} | ||
setStep={setStep} | ||
/> | ||
)} | ||
|
||
{step === "newPassword" && ( | ||
<StepNewPassword | ||
register={register} | ||
resetField={resetField} | ||
watchFields={watchFields} | ||
dirtyFields={dirtyFields} | ||
errors={errors} | ||
/> | ||
)} | ||
</form> | ||
); | ||
} | ||
|
||
export default ModifyPasswordForm; |
Oops, something went wrong.