1
1
"use client" ;
2
2
3
- import { SetStateAction , useRef , useState } from "react" ;
3
+ import { SetStateAction , useContext , useRef , useState } from "react" ;
4
4
import styles from "./modal.module.scss" ;
5
5
import Image from "next/image" ;
6
6
import ImageFormModal from "./ImageFormModal" ;
@@ -9,6 +9,7 @@ import { CardDesignType } from "@/types/cardDesignType";
9
9
import { toast } from "react-toastify" ;
10
10
import { RxCross2 } from "react-icons/rx" ;
11
11
import { CgAdd , CgSelectO } from "react-icons/cg" ;
12
+ import { MentorsDataContext } from "@/middleware/MentorsDataProvider" ;
12
13
13
14
const postMessage = async ( memberName : string , body : string , cardDesign : number , mentorId : number ) => {
14
15
try {
@@ -38,6 +39,9 @@ export default function MemberFormModal({
38
39
const [ isImgModalOpen , setIsImgModalOpen ] = useState ( false ) ;
39
40
const textareaRef = useRef < any > ( null ) ;
40
41
42
+ const mentorsData = useContext ( MentorsDataContext ) ;
43
+ const mentorData = mentorsData . find ( ( item ) => item . id === id ) ;
44
+
41
45
const handleMessageChange = ( e : { target : { value : SetStateAction < string > ; } ; } ) => {
42
46
setMessage ( e . target . value ) ;
43
47
const element = textareaRef . current ;
@@ -78,7 +82,7 @@ export default function MemberFormModal({
78
82
< div className = { styles [ "close-button" ] } onClick = { onClose } >
79
83
< RxCross2 />
80
84
</ div >
81
- < p className = { styles [ 'modal-title' ] } > < span > メンター </ span > へ</ p >
85
+ < p className = { styles [ 'modal-title' ] } > < span > { mentorData ?. name } </ span > へ</ p >
82
86
< div className = { styles [ 'index-container' ] } >
83
87
< div className = { styles [ 'input-container' ] } >
84
88
< div className = { styles [ 'input-top-box' ] } >
@@ -153,9 +157,6 @@ export default function MemberFormModal({
153
157
< div className = { styles [ "modal-bg-black" ] } onClick = { onClose } />
154
158
{ isImgModalOpen && (
155
159
< ImageFormModal
156
- id = { id }
157
- memberName = { memberName }
158
- message = { message }
159
160
designNumber = { cardDesign ? cardDesign . id : 0 }
160
161
onClose = { handleImgModal }
161
162
setCardDesign = { handleCardDesign }
0 commit comments