@@ -23,6 +23,7 @@ import {
2323import { useAuthValue } from '@/features/auth' ;
2424import { getImageURL , putImage } from '@/features/image' ;
2525import {
26+ useCreateDormitorySharedPost ,
2627 useCreateSharedPost ,
2728 usePostMateCardInputSection ,
2829 useSharedPostProps ,
@@ -458,6 +459,7 @@ export function WritingPostPage() {
458459
459460 const { mutate : createSharedPost } = useCreateSharedPost ( ) ;
460461 const { mutate : updateSharedPost } = useUpdateSharedPost ( ) ;
462+ const { mutate : createDormitorySharedPost } = useCreateDormitorySharedPost ( ) ;
461463
462464 const { createToast } = useToast ( ) ;
463465
@@ -610,72 +612,10 @@ export function WritingPostPage() {
610612 } ) ;
611613 } , [ ] ) ;
612614
613- if ( postId == null ) {
614- createSharedPost (
615- {
616- imageFilesData : uploadedImages ,
617- postData : { title, content } ,
618- transactionData : {
619- rentalType : dealTypeValue ,
620- expectedPayment : expectedMonthlyFee ,
621- } ,
622- roomDetailData : {
623- roomType : roomTypeValue ,
624- floorType : floorTypeValue ,
625- size : houseSize ,
626- numberOfRoom,
627- numberOfBathRoom,
628- hasLivingRoom : selectedOptions . livingRoom === '유' ,
629- recruitmentCapacity : mateLimit ,
630- extraOption : {
631- canPark : selectedExtraOptions . canPark ?? false ,
632- hasAirConditioner :
633- selectedExtraOptions . hasAirConditioner ?? false ,
634- hasRefrigerator :
635- selectedExtraOptions . hasRefrigerator ?? false ,
636- hasWasher : selectedExtraOptions . hasWasher ?? false ,
637- hasTerrace : selectedExtraOptions . hasTerrace ?? false ,
638- } ,
639- } ,
640- locationData : {
641- oldAddress : address ?. jibunAddress ,
642- roadAddress : address ?. roadAddress ,
643- } ,
644- roomMateCardData : {
645- location : address ?. roadAddress ,
646- features : derivedFeatures ,
647- } ,
648- participationData : {
649- recruitmentCapacity : mateLimit ,
650- participationMemberIds :
651- auth ?. user != null ? [ auth . user . memberId ] : [ ] ,
652- } ,
653- } ,
654- {
655- onSuccess : ( ) => {
656- createToast ( {
657- message : '게시글이 정상적으로 업로드되었습니다.' ,
658- option : {
659- duration : 3000 ,
660- } ,
661- } ) ;
662- router . back ( ) ;
663- } ,
664- onError : ( ) => {
665- createToast ( {
666- message : '게시글 업로드에 실패했습니다.' ,
667- option : {
668- duration : 3000 ,
669- } ,
670- } ) ;
671- } ,
672- } ,
673- ) ;
674- } else if ( postId != null ) {
675- updateSharedPost (
676- {
677- postId,
678- postData : {
615+ if ( type === 'hasRoom' ) {
616+ if ( postId == null ) {
617+ createSharedPost (
618+ {
679619 imageFilesData : uploadedImages ,
680620 postData : { title, content } ,
681621 transactionData : {
@@ -714,27 +654,111 @@ export function WritingPostPage() {
714654 auth ?. user != null ? [ auth . user . memberId ] : [ ] ,
715655 } ,
716656 } ,
717- } ,
718- {
719- onSuccess : ( ) => {
720- createToast ( {
721- message : '게시글이 정상적으로 수정되었습니다.' ,
722- option : {
723- duration : 3000 ,
724- } ,
725- } ) ;
726- router . back ( ) ;
657+ {
658+ onSuccess : ( ) => {
659+ createToast ( {
660+ message : '게시글이 정상적으로 업로드되었습니다.' ,
661+ option : {
662+ duration : 3000 ,
663+ } ,
664+ } ) ;
665+ router . back ( ) ;
666+ } ,
667+ onError : ( ) => {
668+ createToast ( {
669+ message : '게시글 업로드에 실패했습니다.' ,
670+ option : {
671+ duration : 3000 ,
672+ } ,
673+ } ) ;
674+ } ,
727675 } ,
728- onError : ( ) => {
729- createToast ( {
730- message : '게시글 수정에 실패했습니다.' ,
731- option : {
732- duration : 3000 ,
676+ ) ;
677+ } else if ( postId != null ) {
678+ updateSharedPost (
679+ {
680+ postId,
681+ postData : {
682+ imageFilesData : uploadedImages ,
683+ postData : { title, content } ,
684+ transactionData : {
685+ rentalType : dealTypeValue ,
686+ expectedPayment : expectedMonthlyFee ,
733687 } ,
734- } ) ;
688+ roomDetailData : {
689+ roomType : roomTypeValue ,
690+ floorType : floorTypeValue ,
691+ size : houseSize ,
692+ numberOfRoom,
693+ numberOfBathRoom,
694+ hasLivingRoom : selectedOptions . livingRoom === '유' ,
695+ recruitmentCapacity : mateLimit ,
696+ extraOption : {
697+ canPark : selectedExtraOptions . canPark ?? false ,
698+ hasAirConditioner :
699+ selectedExtraOptions . hasAirConditioner ?? false ,
700+ hasRefrigerator :
701+ selectedExtraOptions . hasRefrigerator ?? false ,
702+ hasWasher : selectedExtraOptions . hasWasher ?? false ,
703+ hasTerrace : selectedExtraOptions . hasTerrace ?? false ,
704+ } ,
705+ } ,
706+ locationData : {
707+ oldAddress : address ?. jibunAddress ,
708+ roadAddress : address ?. roadAddress ,
709+ } ,
710+ roomMateCardData : {
711+ location : address ?. roadAddress ,
712+ features : derivedFeatures ,
713+ } ,
714+ participationData : {
715+ recruitmentCapacity : mateLimit ,
716+ participationMemberIds :
717+ auth ?. user != null ? [ auth . user . memberId ] : [ ] ,
718+ } ,
719+ } ,
735720 } ,
736- } ,
737- ) ;
721+ {
722+ onSuccess : ( ) => {
723+ createToast ( {
724+ message : '게시글이 정상적으로 수정되었습니다.' ,
725+ option : {
726+ duration : 3000 ,
727+ } ,
728+ } ) ;
729+ router . back ( ) ;
730+ } ,
731+ onError : ( ) => {
732+ createToast ( {
733+ message : '게시글 수정에 실패했습니다.' ,
734+ option : {
735+ duration : 3000 ,
736+ } ,
737+ } ) ;
738+ } ,
739+ } ,
740+ ) ;
741+ }
742+ } else if ( type === 'dormitory' ) {
743+ if ( postId == null ) {
744+ createDormitorySharedPost ( {
745+ imageFilesData : uploadedImages ,
746+ postData : { title, content } ,
747+ locationData : {
748+ oldAddress : address ?. jibunAddress ,
749+ roadAddress : address ?. roadAddress ,
750+ } ,
751+ roomMateCardData : {
752+ location : address ?. roadAddress ,
753+ features : derivedFeatures ,
754+ } ,
755+ participationData : {
756+ recruitmentCapacity : mateLimit ,
757+ participationMemberIds :
758+ auth ?. user != null ? [ auth . user . memberId ] : [ ] ,
759+ } ,
760+ } ) ;
761+ }
738762 }
739763 } catch ( error ) {
740764 createToast ( {
0 commit comments