mirror of
https://github.com/balzack/databag.git
synced 2025-02-14 20:49:16 +00:00
adding conversation page
This commit is contained in:
parent
489239b10b
commit
5da72353cd
@ -6,6 +6,7 @@ import { Create } from './Create/Create';
|
|||||||
import { User } from './User/User';
|
import { User } from './User/User';
|
||||||
import { Profile } from './User/Profile/Profile';
|
import { Profile } from './User/Profile/Profile';
|
||||||
import { Contact } from './User/Contact/Contact';
|
import { Contact } from './User/Contact/Contact';
|
||||||
|
import { Conversation } from './User/Conversation/Conversation';
|
||||||
import { HashRouter as Router, Routes, Route } from "react-router-dom";
|
import { HashRouter as Router, Routes, Route } from "react-router-dom";
|
||||||
import 'antd/dist/antd.min.css';
|
import 'antd/dist/antd.min.css';
|
||||||
|
|
||||||
@ -25,6 +26,7 @@ function App() {
|
|||||||
<Route path="/user" element={ <User /> }>
|
<Route path="/user" element={ <User /> }>
|
||||||
<Route path="profile" element={<Profile />} />
|
<Route path="profile" element={<Profile />} />
|
||||||
<Route path="contact/:guid" element={<Contact />} />
|
<Route path="contact/:guid" element={<Contact />} />
|
||||||
|
<Route path="conversation/:id" element={<Conversation />} />
|
||||||
</Route>
|
</Route>
|
||||||
</Routes>
|
</Routes>
|
||||||
</Router>
|
</Router>
|
||||||
|
21
net/web/src/User/Conversation/Conversation.jsx
Normal file
21
net/web/src/User/Conversation/Conversation.jsx
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import React, { useState, useEffect, useRef } from 'react'
|
||||||
|
import { CloseOutlined, UserOutlined } from '@ant-design/icons';
|
||||||
|
import { useConversation } from './useConversation.hook';
|
||||||
|
import { Button, Checkbox, Modal } from 'antd'
|
||||||
|
import { ConversationWrapper, CloseButton } from './Conversation.styled';
|
||||||
|
|
||||||
|
export function Conversation() {
|
||||||
|
|
||||||
|
const { state, actions } = useConversation();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ConversationWrapper>
|
||||||
|
<div class="header">
|
||||||
|
<div class="title">{ state.handle }</div>
|
||||||
|
<CloseButton type="text" class="close" size={'large'} onClick={() => actions.close()} icon={<CloseOutlined />} />
|
||||||
|
</div>
|
||||||
|
<div class="container"></div>
|
||||||
|
</ConversationWrapper>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
47
net/web/src/User/Conversation/Conversation.styled.jsx
Normal file
47
net/web/src/User/Conversation/Conversation.styled.jsx
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
import styled from 'styled-components';
|
||||||
|
import { Button, Spin } from 'antd';
|
||||||
|
|
||||||
|
export const ConversationWrapper = styled.div`
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background-color: #f6f5ed;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
.header {
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
background-color: #888888;
|
||||||
|
height: 64px;
|
||||||
|
padding-right: 16px;
|
||||||
|
padding-left: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
height: 64px;
|
||||||
|
flex-grow: 1;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 2em;
|
||||||
|
font-weight: bold;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: flex-begin;
|
||||||
|
color: white;
|
||||||
|
padding-left: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.close {
|
||||||
|
font-size: 24px;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const CloseButton = styled(Button)`
|
||||||
|
font-size: 24px;
|
||||||
|
color: white;
|
||||||
|
`;
|
||||||
|
|
32
net/web/src/User/Conversation/useConversation.hook.js
Normal file
32
net/web/src/User/Conversation/useConversation.hook.js
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import { useContext, useState, useEffect } from 'react';
|
||||||
|
import { AppContext } from '../../AppContext/AppContext';
|
||||||
|
import { useNavigate, useLocation, useParams } from "react-router-dom";
|
||||||
|
|
||||||
|
export function useConversation() {
|
||||||
|
|
||||||
|
const [state, setState] = useState({
|
||||||
|
});
|
||||||
|
|
||||||
|
const data = useLocation();
|
||||||
|
const { id } = useParams();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const app = useContext(AppContext);
|
||||||
|
|
||||||
|
const updateState = (value) => {
|
||||||
|
setState((s) => ({ ...s, ...value }));
|
||||||
|
}
|
||||||
|
|
||||||
|
const actions = {
|
||||||
|
close: () => {
|
||||||
|
navigate('/user')
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (app?.state?.access === 'user') {
|
||||||
|
console.log("CONVERSATION:", id);
|
||||||
|
}
|
||||||
|
}, [app, id])
|
||||||
|
|
||||||
|
return { state, actions };
|
||||||
|
}
|
@ -1,18 +1,15 @@
|
|||||||
import React, { useEffect, useState } from 'react'
|
import React, { useEffect, useState } from 'react'
|
||||||
|
import { useChannelItem } from './useChannelItem.hook';
|
||||||
import { ChannelItemWrapper } from './ChannelItem.styled';
|
import { ChannelItemWrapper } from './ChannelItem.styled';
|
||||||
import { ChannelLogo } from './ChannelLogo/ChannelLogo';
|
import { ChannelLogo } from './ChannelLogo/ChannelLogo';
|
||||||
import { ChannelLabel } from './ChannelLabel/ChannelLabel';
|
import { ChannelLabel } from './ChannelLabel/ChannelLabel';
|
||||||
|
|
||||||
export function ChannelItem({ item }) {
|
export function ChannelItem({ item }) {
|
||||||
|
|
||||||
// if 0 or 5+ render number in big border
|
let { state, actions } = useChannelItem();
|
||||||
// if 2 renber other in big border
|
|
||||||
// if 3 or 4 render others in small borders
|
|
||||||
|
|
||||||
// subject, hosting, username list, last msg, updated time, unread flag
|
|
||||||
|
|
||||||
const onSelect = () => {
|
const onSelect = () => {
|
||||||
console.log(item);
|
actions.select(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
import { useContext, useState, useEffect } from 'react';
|
||||||
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
|
export function useChannelItem() {
|
||||||
|
|
||||||
|
const [state, setState] = useState({
|
||||||
|
});
|
||||||
|
|
||||||
|
const updateState = (value) => {
|
||||||
|
setState((s) => ({ ...s, ...value }));
|
||||||
|
}
|
||||||
|
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
const actions = {
|
||||||
|
select: (item) => {
|
||||||
|
navigate(`/user/conversation/${item.channel.id}`);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
return { state, actions };
|
||||||
|
}
|
||||||
|
|
@ -20,6 +20,9 @@ export function useChannels() {
|
|||||||
const app = useContext(AppContext);
|
const app = useContext(AppContext);
|
||||||
|
|
||||||
const actions = {
|
const actions = {
|
||||||
|
select: (channel) => {
|
||||||
|
navigate(`/user/channel/${channel.id}`);
|
||||||
|
},
|
||||||
getCardImageUrl: app?.actions?.getCardImageurl,
|
getCardImageUrl: app?.actions?.getCardImageurl,
|
||||||
getCards: app?.actions?.getConnectedCards,
|
getCards: app?.actions?.getConnectedCards,
|
||||||
setStartCards: (cards) => updateState({ startCards: cards }),
|
setStartCards: (cards) => updateState({ startCards: cards }),
|
||||||
|
Loading…
Reference in New Issue
Block a user