@@ -17,6 +17,7 @@ import { router } from "expo-router";
1717import { Colors } from "@/constants/theme" ;
1818import { useColorScheme } from "@/hooks/use-color-scheme" ;
1919import CreateProposalScreen from "../create-proposal" ;
20+ import { getUserId } from "@/utils/user-storage" ;
2021
2122const { width : screenWidth } = Dimensions . get ( "window" ) ;
2223
@@ -134,10 +135,18 @@ export default function ProposalsScreen() {
134135 const [ refreshing , setRefreshing ] = useState ( false ) ;
135136 const [ fadeAnim ] = useState ( new Animated . Value ( 0 ) ) ;
136137 const [ slideAnim ] = useState ( new Animated . Value ( 50 ) ) ;
138+ const [ currentUserId , setCurrentUserId ] = useState < number | null > ( null ) ;
137139 const colorScheme = useColorScheme ( ) ;
138140 const colors = Colors [ colorScheme ?? "light" ] ;
139141
140142 useEffect ( ( ) => {
143+ // 現在のユーザーIDを取得
144+ const getCurrentUser = async ( ) => {
145+ const userId = await getUserId ( ) ;
146+ setCurrentUserId ( userId ) ;
147+ } ;
148+ getCurrentUser ( ) ;
149+
141150 // エントランスアニメーション
142151 Animated . parallel ( [
143152 Animated . timing ( fadeAnim , {
@@ -179,13 +188,15 @@ export default function ProposalsScreen() {
179188 } ;
180189
181190 const handleAccept = ( proposalId : number ) => {
191+ if ( ! currentUserId ) return ;
192+
182193 setProposals ( ( prev ) =>
183194 prev . map ( ( p ) =>
184195 p . id === proposalId
185196 ? {
186197 ...p ,
187198 participants : p . participants . map ( ( participant ) =>
188- participant . user_id === 1 // 仮に現在のユーザーのIDを1とする
199+ participant . user_id === currentUserId
189200 ? { ...participant , status : "accepted" as const }
190201 : participant
191202 ) ,
@@ -213,7 +224,7 @@ export default function ProposalsScreen() {
213224
214225 // ヘルパー関数: 現在のユーザーが作成者かどうか
215226 const isCurrentUserCreator = ( creatorId : number ) => {
216- return creatorId === 1 ; // 仮に現在のユーザーのIDを1とする
227+ return currentUserId !== null && creatorId === currentUserId ;
217228 } ;
218229
219230 const renderProposalCard = ( {
@@ -367,15 +378,17 @@ export default function ProposalsScreen() {
367378 < Text style = { [ styles . infoText , { color : "#4A5565" } ] } >
368379 { item . participants . length } 人
369380 </ Text >
370- { getAcceptedCount ( item . participants ) > 0 && (
371- < Text
372- style = { [ styles . acceptedInfo , { color : "#155DFC" } ] }
373- >
374- { getAcceptedCount ( item . participants ) } /
375- { item . participants . length }
376- 人が承認
377- </ Text >
378- ) }
381+ { /* 自分が作成者の場合のみ承認情報を表示 */ }
382+ { isCurrentUserCreator ( item . creator_id ) &&
383+ getAcceptedCount ( item . participants ) > 0 && (
384+ < Text
385+ style = { [ styles . acceptedInfo , { color : "#155DFC" } ] }
386+ >
387+ { getAcceptedCount ( item . participants ) } /
388+ { item . participants . length }
389+ 人が承認
390+ </ Text >
391+ ) }
379392 </ View >
380393 </ View >
381394
@@ -494,26 +507,26 @@ export default function ProposalsScreen() {
494507 . join ( ", " ) }
495508 </ Text >
496509 </ View >
497- < View style = { styles . detailRow } >
498- < View
499- style = { [
500- styles . iconContainer ,
501- { backgroundColor : colors . warning + "20" } ,
502- ] }
503- >
504- < IconSymbol
505- name = "person"
506- size = { 20 }
507- color = { colors . warning }
508- />
510+ { /* 作成者情報は自分が作成者の場合のみ表示 */ }
511+ { isCurrentUserCreator ( selectedProposal . creator_id ) && (
512+ < View style = { styles . detailRow } >
513+ < View
514+ style = { [
515+ styles . iconContainer ,
516+ { backgroundColor : colors . warning + "20" } ,
517+ ] }
518+ >
519+ < IconSymbol
520+ name = "person"
521+ size = { 20 }
522+ color = { colors . warning }
523+ />
524+ </ View >
525+ < Text style = { [ styles . detailText , { color : colors . text } ] } >
526+ 作成者: あなた
527+ </ Text >
509528 </ View >
510- < Text style = { [ styles . detailText , { color : colors . text } ] } >
511- 作成者:{ " " }
512- { isCurrentUserCreator ( selectedProposal . creator_id )
513- ? "あなた"
514- : "友達" }
515- </ Text >
516- </ View >
529+ ) }
517530 </ View >
518531
519532 { /* Action Buttons and Status */ }
@@ -544,6 +557,7 @@ export default function ProposalsScreen() {
544557 </ View >
545558 ) }
546559
560+ { /* 自分が作成者の場合のみ承認・拒否統計を表示 */ }
547561 { isCurrentUserCreator ( selectedProposal . creator_id ) && (
548562 < View
549563 style = { [
0 commit comments