diff --git a/components/Outbox.js b/components/Outbox.js
index 40d096d..d87eeeb 100644
--- a/components/Outbox.js
+++ b/components/Outbox.js
@@ -1,7 +1,7 @@
import { StatusBar } from 'expo-status-bar';
import React, {useEffect, useState} from 'react';
import { StyleSheet, Text, View,
- Dimensions, Pressable, ScrollView, Image } from 'react-native';
+ Dimensions, Pressable, ScrollView, Image, TouchableOpacity } from 'react-native';
import { format } from "date-fns";
import { Calendar } from 'react-native-calendars';
import { color, commomStyle, images } from '../theme';
@@ -11,7 +11,11 @@ import AsyncStorage from '@react-native-async-storage/async-storage';
const { width: SCREEN_WIDTH, height: SCREEN_HEIGHT } = Dimensions.get("window");
export default function Outbox({navigation, route}) {
- const [accessToken,setAccessToken]=useState(null);
+ const [accessToken,setAccessToken] = useState(null);
+ const [data, setData] = useState({});
+ const [posts, setPosts] = useState([]);
+ const [selectedData, setSelectedData] = useState([]);
+
const getData = async () => {
const storageData = JSON.parse(await AsyncStorage.getItem("accessToken"));
@@ -19,16 +23,25 @@ export default function Outbox({navigation, route}) {
setAccessToken(storageData);
}
}
+
useEffect(()=>{
getData();
},[]);
+
useEffect(()=>{
// console.log(accessToken);
if(accessToken!=null){
getSentMessage();
}
-
},[accessToken]);
+
+ useEffect(() => {
+ if (selectedDate != null){
+ // console.log(selectedDate)
+ // console.log(selectedData)
+ }
+ }, [selectedDate, selectedData])
+
const getSentMessage=()=>{
axios.get("http://3.34.212.92:8080/api/message/outbox",
{
@@ -36,23 +49,49 @@ export default function Outbox({navigation, route}) {
Authorization:`Bearer ${accessToken}`,
},
withCredentials:true,
- }).then((response)=>{
- // console.log(response.data.data);
- }).catch((error)=>{
- console.log(error);
+ }).then((response) => {
+ setData(response.data.data[0]);
- })
-
+ // 날짜만
+ const dates = Object.keys(response.data.data[0]);
+ const newPosts = dates.map((date, index) => ({
+ id : posts.length + index,
+ date: date,
+ }))
+ setPosts(newPosts);
+
+ const currentDate = format(new Date(), "yyyy-MM-dd")
+ if (dates.includes(currentDate)){
+ setSelectedData(response.data.data[0][currentDate])
+ }
+ console.log(selectedData);
+ }).catch((error) => {
+ console.log(error);
+ })
};
- const onPress = () => navigation.navigate('detail', {date: selectedDate});
- const [selectMarkDate, setSelectMarkDate] = useState(false);
- const posts = [
- {id: 0, date: "2023-09-17",},
- {id: 1, date: "2023-08-08",},
- {id: 2, date: "2023-08-14",},
- {id: 3, date: "2023-09-27",}
- ];
+ const onPressItem = (messageId) => {
+ return () => {
+ getMessageDetail(messageId);
+ };
+ }
+
+ const getMessageDetail = async (messageId) => {
+ console.log(messageId)
+ await axios.get(`http://3.34.212.92:8080/api/message/${messageId}`,
+ {
+ headers: {
+ Authorization:`Bearer ${accessToken}`,
+ },
+ withCredentials:true,
+ }).then((response) => {
+ console.log(response.data.data[0])
+ navigation.navigate('detail', {day: selectedDate, data : response.data.data[0]});
+ // console.log(selectedData);
+ }).catch((error) => {
+ console.log(error);
+ })
+ }
const markedDates = posts.reduce((acc, current) => {
const formattedDate = format(new Date(current.date), 'yyyy-MM-dd');
@@ -74,6 +113,7 @@ export default function Outbox({navigation, route}) {
const onChangeSelect = (day) => {
setSelectedDate(day.dateString)
+ setSelectedData(data[day.dateString])
}
function isSelected(element) {
@@ -87,48 +127,36 @@ export default function Outbox({navigation, route}) {
- {/* */}
-
- {posts.find(isSelected) ?
-
-
-
-
- 그림
-
-
-
-
- 그림
-
-
-
-
-
-
-
- 그림
-
-
-
-
- 그림
-
-
-
-
-
- : }
+
+
+ {posts.find(isSelected) ?
+
+
+ {Array.from({ length: Math.ceil(selectedData.length / 2) }).map((_, rowIndex) => (
+
+ {selectedData.slice(rowIndex * 2, rowIndex * 2 + 2).map((item, index) => (
+
+
+ {item.messageId}
+
+
+ ))}
+
+ ))}
+
+
+ :
+ }
);
@@ -160,21 +188,26 @@ const styles = StyleSheet.create({
},
letter:{
position: 'relative',
+ marginTop: 60
},
- list: {
+ outerScrollView: {
flex: 1,
- // backgroundColor: color.g3,
width: SCREEN_WIDTH-40,
},
- oneLine: {
- flexDirection: "row",
+ innerContainer: {
+ flexDirection: "column",
justifyContent: "space-between",
marginHorizontal: 10,
marginVertical: 10,
+ // alignItems: "center"
+ },
+ row: {
+ flexDirection: "row"
},
listPost: {
width: SCREEN_WIDTH/2.5,
height: 160,
+ margin: 5,
borderWidth: 1,
},
listPic: {
diff --git a/components/OutboxDetail.js b/components/OutboxDetail.js
index a8ab5b6..5e48bf1 100644
--- a/components/OutboxDetail.js
+++ b/components/OutboxDetail.js
@@ -1,7 +1,7 @@
import { StatusBar } from 'expo-status-bar';
import React, {useEffect, useState} from 'react';
import { StyleSheet, Text,
- View, Dimensions } from 'react-native';
+ View, Dimensions, Image } from 'react-native';
import { color, commomStyle, images } from '../theme';
import Dinfo from './detail/Dinfo';
import Dtitle from './detail/Dtitle';
@@ -13,41 +13,33 @@ export default function OutboxDetail({ route }) {
const [member, setMember] = useState([{id: 0, name: '회원1'}, {id: 1, name: '회원2'}, {id: 2, name: '회원3'}])
const [notmember, setNotmember] = useState([{id: 0, tel: '01012341234'}])
+ const {day, data} = route.params;
+
return (
-
-
+
+
- 그림 O
+
-
+
받은 사람
- {member.map((item) => (
-
-
- {item.name}
-
-
- ))}
- {notmember.map((item) => (
-
-
- {item.tel}
-
-
- ))}
+
+
+ {data.receiverNickname}
+
+
-
);
}
@@ -72,7 +64,11 @@ const styles = StyleSheet.create({
borderBottomWidth: 1,
borderBottomColor: "black",
alignItems: "center",
- justifyContent: "center"
+ justifyContent: "center",
+ },
+ image: {
+ width: "100%",
+ height: "100%",
},
letterTo: {
flex: 2.5,
diff --git a/components/SendLetter.js b/components/SendLetter.js
index 2d4bf02..c889207 100644
--- a/components/SendLetter.js
+++ b/components/SendLetter.js
@@ -64,8 +64,8 @@ export default function SendLetter({navigation, route}) {
} else if (error.response && error.response.data.message === "찾을 수 없는 아이디") {
console.log("no user");
Alert.alert(
- "에러",
- `존재하지 않는 아이디입니다.\n [ ${error.response.data.data} ]`,
+ "존재하지 않는 아이디",
+ `[ ${error.response.data.data} ]`,
[
{ text: "확인" }
]
diff --git a/components/detail/Dinfo.js b/components/detail/Dinfo.js
index 3d3413e..f1817fe 100644
--- a/components/detail/Dinfo.js
+++ b/components/detail/Dinfo.js
@@ -4,11 +4,19 @@ import { Fontisto } from '@expo/vector-icons';
export default function Dinfo(props) {
- const[sun, setSun] = useState(true);
+ const[sun, setSun] = useState(false);
const[cloud, setCloud] = useState(false);
const[rain, setRain] = useState(false);
const[snow, setSnow] = useState(false);
+ useEffect(() => {
+ // weatherValue에 따라 Pressable을 자동 설정하는 로직
+ setSun(props.weather === "sunny");
+ setCloud(props.weather === "cloudy");
+ setRain(props.weather === "rainy");
+ setSnow(props.weather === "snowy");
+ }, [props.weather]);
+
return (
@@ -16,7 +24,7 @@ export default function Dinfo(props) {
fontSize: 18,
fontWeight: "600",
}}>
- {props.date}
+ {props.day}
diff --git a/components/detail/Dtext.js b/components/detail/Dtext.js
index d7425da..69864bf 100644
--- a/components/detail/Dtext.js
+++ b/components/detail/Dtext.js
@@ -2,19 +2,27 @@ import React, {useEffect, useState} from 'react';
import { ScrollView, StyleSheet, Text, View } from 'react-native';
import { color, commomStyle, images } from '../../theme';
-export default function Dtext() {
+export default function Dtext(props) {
return (
+ {/* 편지 내용 */}
안녕하세요. 저 ysy입니다. 오늘은 ~~~~했어요.
+ }}>{props.text}
+ {/*
+ 부가 메시지
+ {props.extra}
+ */}
-
);
};
diff --git a/components/detail/Dtitle.js b/components/detail/Dtitle.js
index 9b4bb1e..edfd3a8 100644
--- a/components/detail/Dtitle.js
+++ b/components/detail/Dtitle.js
@@ -1,7 +1,7 @@
import React, {useEffect, useState} from 'react';
import {StyleSheet, Text, View} from 'react-native';
-export default function Dtitle() {
+export default function Dtitle(props) {
return (
@@ -12,7 +12,7 @@ export default function Dtitle() {
marginLeft: 10,
}}
>
- 안녕하세요.
+ {props.title}
);