-
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.
Merge branch 'FE/main' into FE/feature/visit/changeSnowBalls
- Loading branch information
Showing
15 changed files
with
329 additions
and
95 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,104 @@ | ||
import styled from 'styled-components'; | ||
import axios from 'axios'; | ||
|
||
interface MsgProps { | ||
color: string; | ||
content: string; | ||
sender: string; | ||
to: string; | ||
messageId: number; | ||
} | ||
|
||
interface MsgColor { | ||
color: string; | ||
} | ||
|
||
const StyledLetterBox = styled.div<MsgColor>` | ||
width: 80%; | ||
display: flex; | ||
align-self: center; | ||
font: ${props => props.theme.font['--normal-introduce-font']}; | ||
text-shadow: -1px 0px black, 0px 1px black, 1px 0px black, 0px -1px black; | ||
flex-direction: column; | ||
border-radius: 1rem; | ||
padding: 1.5rem; | ||
gap: 1rem; | ||
background-color: ${props => props.color + '80'}; | ||
margin: 1rem; | ||
`; | ||
|
||
const StyledLetterPerson = styled.div` | ||
display: flex; | ||
justify-content: space-between; | ||
color: white; | ||
`; | ||
|
||
const StyledTo = styled.span` | ||
color: ${props => props.theme.colors['--nick-name']}; | ||
`; | ||
|
||
const StyledLetterContent = styled.div` | ||
white-space: pre; | ||
text-align: center; | ||
color: white; | ||
`; | ||
|
||
const StyledFromBox = styled(StyledLetterPerson)` | ||
flex-direction: row-reverse; | ||
display: flex; | ||
justify-content: space-between; | ||
`; | ||
|
||
const StyledFrom = styled.span` | ||
text-align: right; | ||
color: ${props => props.theme.colors['--primary-redp-variant']}; | ||
`; | ||
|
||
|
||
const StyledFromInput = styled.input` | ||
width: 55%; | ||
outline: none; | ||
border: none; | ||
background-color: transparent; | ||
color: ${props => props.theme.colors['--nick-name']}; | ||
text-shadow: -1px 0px black, 0px 1px black, 1px 0px black, 0px -1px black; | ||
font-size: 1rem; | ||
font-weight: 700; | ||
pointer-events: stroke; | ||
`; | ||
|
||
const StyledToWrap = styled.div``; | ||
|
||
const StyledDeleteButton = styled.button` | ||
`; | ||
|
||
const ListMsg = (props: MsgProps): JSX.Element => { | ||
|
||
const deleteMsg = () => { | ||
axios.delete(`/api/message/${props.messageId}`, { | ||
withCredentials: true | ||
}).then(() => { | ||
// 리렌더링 구현해야함 | ||
}); | ||
}; | ||
|
||
return ( | ||
<StyledLetterBox color={props.color}> | ||
<StyledLetterPerson> | ||
<StyledToWrap>To. <StyledTo>{props.to}</StyledTo></StyledToWrap> | ||
<StyledDeleteButton onClick={deleteMsg}>X</StyledDeleteButton> | ||
</StyledLetterPerson> | ||
|
||
<StyledLetterContent>{props.content}</StyledLetterContent> | ||
|
||
<StyledFromBox> | ||
<StyledFrom> | ||
From. | ||
<StyledFromInput value={props.sender} disabled /> | ||
</StyledFrom> | ||
</StyledFromBox> | ||
</StyledLetterBox> | ||
); | ||
}; | ||
|
||
export default ListMsg; |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
export { default as Msg } from './Msg'; | ||
export { default as ListMsg } from './ListMsg'; |
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
This file was deleted.
Oops, something went wrong.
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,77 @@ | ||
import styled from 'styled-components'; | ||
import { ListMsg } from '../../components'; | ||
import { Prev } from '../../components'; | ||
import axios from 'axios'; | ||
import { useEffect, useState } from 'react'; | ||
import { MSG_COLOR } from '../../constants/deco'; | ||
|
||
interface ListMsgProps { | ||
set: React.Dispatch<React.SetStateAction<boolean>>; | ||
} | ||
|
||
const StyledList = styled.div` | ||
pointer-events: auto; | ||
position: absolute; | ||
width: 100%; | ||
top: 10%; | ||
height: 85%; | ||
overflow-y: scroll; | ||
`; | ||
|
||
const StyledListWrap = styled.div` | ||
display: flex; | ||
justify-content: center; | ||
flex-direction: column; | ||
`; | ||
|
||
interface MsgResponse { | ||
user_id: number; | ||
snowball_id: number; | ||
location: number; | ||
content: string; | ||
sender: string; | ||
to: string; | ||
created: string; | ||
decoration_id: number; | ||
decoration_color: string; | ||
id: number; | ||
is_deleted: boolean; | ||
opened: string; | ||
letter_id: number; | ||
}; | ||
|
||
const ListMsgs = (props: ListMsgProps) => { | ||
const [messages, setMessages] = useState<Array<MsgResponse>>([]); | ||
|
||
useEffect(() => { | ||
axios.get('/api/message').then(res => { | ||
console.log(res.data); | ||
setMessages(res.data); | ||
}); | ||
}, []); | ||
|
||
return ( | ||
<> | ||
<Prev set={props.set} /> | ||
|
||
<StyledList> | ||
<StyledListWrap> | ||
{messages.map((msg, idx) => { | ||
return ( | ||
<ListMsg | ||
key={idx} | ||
color={MSG_COLOR[msg.letter_id].color} | ||
content={msg.content} | ||
sender={msg.sender} | ||
to={msg.to} // 요게 지금 없음 | ||
messageId={msg.id} | ||
/> | ||
); | ||
})} | ||
</StyledListWrap> | ||
</StyledList> | ||
</> | ||
); | ||
}; | ||
|
||
export default ListMsgs; |
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
Oops, something went wrong.