-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
a159910
commit c84d58d
Showing
2 changed files
with
57 additions
and
32 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,33 @@ | ||
import { useState } from "react"; | ||
import { schoolOptions } from "src/constants/profile/schoolOptions"; | ||
|
||
const useModal = (value: string, title: string) => { | ||
const [inputValue, setInputValue] = useState(value); | ||
const [selectedSchool, setSelectedSchool] = useState(schoolOptions[0]); | ||
const [password, setPassword] = useState(""); | ||
|
||
const handleSave = (onSave: (newValue: string) => void, onClose: () => void) => { | ||
if (title === "학교") { | ||
onSave(selectedSchool); | ||
} else if (title === "이름") { | ||
onSave(inputValue); | ||
} else if (title === "비밀번호") { | ||
onSave(password); | ||
} else { | ||
onSave(inputValue); | ||
} | ||
onClose(); | ||
}; | ||
|
||
return { | ||
inputValue, | ||
selectedSchool, | ||
password, | ||
setInputValue, | ||
setSelectedSchool, | ||
setPassword, | ||
handleSave | ||
}; | ||
}; | ||
|
||
export default useModal; |