-
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.
- Loading branch information
1 parent
5626fd7
commit dd84fb8
Showing
35 changed files
with
764 additions
and
19 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
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,3 @@ | ||
{ | ||
"title": "Чаты" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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 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 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,18 @@ | ||
import styles from "./chat.module.scss"; | ||
import { ChatUserList } from "./userList"; | ||
import { ChatCurrentUser } from "./currentUser"; | ||
import { ChatInput } from "./input"; | ||
import { ChatBody } from "./body"; | ||
|
||
export function Chat() { | ||
return ( | ||
<div className={styles.container}> | ||
<ChatUserList /> | ||
<div className={styles.chatBodyWrapper}> | ||
<ChatCurrentUser /> | ||
<ChatBody /> | ||
<ChatInput /> | ||
</div> | ||
</div> | ||
); | ||
} |
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,24 @@ | ||
import styles from "./chatBody.module.scss"; | ||
import { useAppSelector } from "../../../store.ts"; | ||
import { useGetCorrespondenceQuery } from "../../../services/api/sharebookApi.ts"; | ||
import { ChatMessage } from "../chatMessage"; | ||
|
||
export function ChatBody() { | ||
const activeChatId = useAppSelector((state) => state.chat.activeId); | ||
|
||
const response = useGetCorrespondenceQuery({ | ||
firstUserId: "6", | ||
secondUserId: "4", | ||
zone: 4, | ||
}); | ||
|
||
if (!activeChatId) return <div className={styles.centered}>Кому писать?</div>; | ||
|
||
return ( | ||
<div className={styles.scroll}> | ||
{response.currentData?.map((item) => ( | ||
<ChatMessage key={item.messageId} message={item} profileId={6} /> | ||
))} | ||
</div> | ||
); | ||
} |
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,23 @@ | ||
.wrapper { | ||
flex: 1; | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
.blank { | ||
flex: 1; | ||
} | ||
|
||
.centered { | ||
flex: 1; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
|
||
.scroll { | ||
flex: 1; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: flex-end; | ||
} |
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 @@ | ||
export { ChatBody } from "./ChatBody.tsx"; |
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,22 @@ | ||
.container { | ||
max-width: 1400px; | ||
margin: 0 auto; | ||
height: calc(100vh - 66px); | ||
display: flex; | ||
} | ||
|
||
.chatBodyWrapper { | ||
flex: 1; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: stretch; | ||
position: relative; | ||
} | ||
|
||
.dropdownOverlay { | ||
backdrop-filter: blur(50px); | ||
|
||
ul { | ||
margin-top: 2px !important; | ||
} | ||
} |
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,19 @@ | ||
import styles from "./chatMessage.module.scss"; | ||
import { MessageDto } from "../../../services/api/sharebookApi.ts"; | ||
import cn from "classnames"; | ||
|
||
interface ChatMessageProps { | ||
message: MessageDto; | ||
profileId: string | number; | ||
} | ||
|
||
export function ChatMessage(props: ChatMessageProps) { | ||
return ( | ||
<div className={cn(styles.wrapper, props.profileId === 6 && styles.own)}> | ||
{props.message.text} | ||
<span className={styles.time}> | ||
{props.message.departureDate?.split("T")[1].slice(0, 5)} | ||
</span> | ||
</div> | ||
); | ||
} |
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,23 @@ | ||
.wrapper { | ||
border-radius: 12px; | ||
background: #F1F4F6; | ||
padding: 10px 40px 10px 15px; | ||
margin-bottom: 16px; | ||
max-width: 530px; | ||
width: fit-content; | ||
position: relative; | ||
|
||
.time { | ||
position: absolute; | ||
right: 6px; | ||
bottom: 6px; | ||
font-size: 12px; | ||
line-height: 15px; | ||
} | ||
|
||
&.own { | ||
margin-left: auto; | ||
background: var(--ant-color-primary); | ||
color: #fff; | ||
} | ||
} |
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 @@ | ||
export { ChatMessage } from "./ChatMessage.tsx"; |
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,23 @@ | ||
import { createSlice, PayloadAction } from "@reduxjs/toolkit"; | ||
|
||
interface ChatState { | ||
activeId: string | null; | ||
} | ||
|
||
const initialState: ChatState = { | ||
activeId: null, | ||
}; | ||
|
||
const chatSlice = createSlice({ | ||
name: "chat", | ||
initialState, | ||
reducers: { | ||
setActiveId(state, action: PayloadAction<string>) { | ||
state.activeId = action.payload; | ||
}, | ||
}, | ||
}); | ||
|
||
export const { setActiveId } = chatSlice.actions; | ||
|
||
export const chatReducer = chatSlice.reducer; |
Oops, something went wrong.