Skip to content

Commit

Permalink
Merge pull request #103 from KUIT-Space/feat#51-chat_detail
Browse files Browse the repository at this point in the history
Fix: ์ •์‚ฐ ํƒญ๋ทฐ์ผ๋•Œ ์ดˆ๊ธฐ ๋ฉค๋ฒ„ ๋ชฉ๋ก ํ‘œ์‹œ ์•ˆ๋˜๋Š” ๋ฌธ์ œ ํ•ด๊ฒฐ
  • Loading branch information
Turtle-Hwan authored Aug 19, 2024
2 parents 7ca9fe1 + 5af6b09 commit 8084dc1
Show file tree
Hide file tree
Showing 5 changed files with 166 additions and 163 deletions.
46 changes: 25 additions & 21 deletions src/apis/Pay/PayPageAPI.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { DetailPayData, PayReceiveInfo, PayRequestInfo } from "@/pages/PayPage/PayPage";
import { useNavigate } from "react-router-dom";

import {
createRequestOptionsJSON,
RequestOptions,
createRequestOptionsJSON_AUTH,
fetchApi,
RequestOptions,
} from "@/apis/_createRequestOptions";
import { BankInfo, ChatUserInfoInSpace } from "@/pages/PayPage/CreateRequestPage";
import { useNavigate } from "react-router-dom";
import { UserInfoInSpace } from "@/apis/Space/SpaceSearchAllUserApi";
import { BankInfo, ChatUserInfoInSpace } from "@/pages/PayPage/CreateRequestPage";
import { DetailPayData, PayReceiveInfo, PayRequestInfo } from "@/pages/PayPage/PayPage";

interface SpaceSearchAllUserApiResponseType {
code: number;
Expand Down Expand Up @@ -203,24 +204,27 @@ export const getAllChatMemberApi = async (
if (response) {
response.json().then((data) => {
const _temp: chatRoomList[] = data.result.chatRoomList;
let _temp2: ChatUserInfoInSpace[] = new Array();
_temp.map(async (value, index) => {
let _temp3: ChatUserInfoInSpace = {
chatRoomId: -1,
chatRoomName: "",
userList: [],
imgUrl: "",
};
_temp3.chatRoomId = value.id;
_temp3.chatRoomName = value.name;
_temp3.imgUrl = value.imgUrl;
getChatRoomMemberApi(spaceID, value.id).then((res) => {
res ? (_temp3.userList = res.result.userList) : (_temp3.userList = []);
_temp2.push(_temp3);
});
const _temp2: ChatUserInfoInSpace[] = [];
Promise.all(
_temp.map((value) => {
const _temp3: ChatUserInfoInSpace = {
chatRoomId: value.id,
chatRoomName: value.name,
userList: [],
imgUrl: value.imgUrl,
};

return getChatRoomMemberApi(spaceID, value.id).then((res) => {
if (res) {
_temp3.userList = res.result.userList;
_temp2.push(_temp3);
return _temp3;
}
});
}),
).then((res) => {
setChatUserInfoData(_temp2);
});

setChatUserInfoData(_temp2);
});
}
};
Expand Down
23 changes: 20 additions & 3 deletions src/components/TopBarText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,30 @@ interface topbarProps {
center: string | React.ReactNode;
right: string | React.ReactNode;
rightHandler?: () => void;
backHandler?: () => void;
logoHandler?: () => void;
}

const TopBarText: FC<topbarProps> = ({ left, center, right, rightHandler }) => {
const TopBarText: FC<topbarProps> = ({
left,
center,
right,
rightHandler,
backHandler,
logoHandler,
}) => {
const navigate = useNavigate();
switch (left) {
case "logo":
return (
<sty.StyledTopBarDiv>
<sty.StyledLeftDiv
onClick={() => {
navigate("/");
if (logoHandler) {
logoHandler();
} else {
navigate("/");
}
}}
>
<img src={logo}></img>
Expand All @@ -49,7 +62,11 @@ const TopBarText: FC<topbarProps> = ({ left, center, right, rightHandler }) => {
<sty.StyledTopBarDiv>
<sty.StyledLeftDiv
onClick={() => {
navigate(-1);
if (backHandler) {
backHandler();
} else {
navigate(-1);
}
}}
>
<img src={back}></img>
Expand Down
24 changes: 0 additions & 24 deletions src/pages/HomePage.tsx

This file was deleted.

57 changes: 25 additions & 32 deletions src/pages/PayPage/CreatePayComponents.tsx
Original file line number Diff line number Diff line change
@@ -1,61 +1,54 @@
import CheckBox from "@/components/CheckBox";
import { Member } from "@/pages/ChatPage/ChatCreatePage/ChatCreatePage.styled";
import ReactImg from "@/assets/react.svg";
import { useState } from "react";

import { UserInfoInSpace } from "@/apis/Space/SpaceSearchAllUserApi";
import CheckBox from "@/components/CheckBox";
import { Member } from "@/pages/ChatPage/ChatCreatePage/ChatCreatePage.styled";
import * as s from "@/pages/PayPage/PayPage.styled";
import { getUserDefaultImageURL } from "@/utils/getUserDefaultImageURL";

import { ChatUserInfoInSpace } from "./CreateRequestPage";
import { UserInfoInSpace } from "@/apis/Space/SpaceSearchAllUserApi";
interface payChatDivtype {
img: string;
name: string;
cnt: number;
}
// interface payChatDivtype {
// img: string;
// name: string;
// cnt: number;
// }

const PayChatMemberDiv = ({ props }: { props: UserInfoInSpace }) => {
const imgUrl = props.profileImgUrl === null ? undefined : props.profileImgUrl;
const PayChatMemberDiv = ({ info }: { info: UserInfoInSpace }) => {
return (
<s.RowFlexDiv style={{ alignItems: "center" }}>
<img style={{ width: "2.5rem", height: "2.5rem", marginLeft: "1.875rem" }} src={imgUrl} />
<img
style={{ width: "2.5rem", height: "2.5rem", marginLeft: "1.875rem" }}
src={info.profileImgUrl ?? getUserDefaultImageURL(info.userId)}
/>
<span className="name" style={{ marginLeft: "0.75rem" }}>
{props.userName}
{info.userName}
</span>
<CheckBox></CheckBox>
</s.RowFlexDiv>
);
};
export const PayChatDiv = ({ props }: { props: ChatUserInfoInSpace }) => {
console.log(props);
export const PayChatDiv = ({ info }: { info: ChatUserInfoInSpace }) => {
const [flag, setFlag] = useState(false);
const controlFlag = () => {
setFlag(!flag);
};

return (
<s.ColumnFlexDiv>
<Member>
<section>
<img src={props.imgUrl} />
<span className="name">{props.chatRoomName}</span>
<s.CountText className="count">{props.userList?.length}</s.CountText>
<img src={info.imgUrl} />
<span className="name">{info.chatRoomName}</span>
<s.CountText className="count">{info.userList?.length}</s.CountText>
</section>
{flag ? (
<CheckBox
checked={true}
onClick={() => {
controlFlag();
}}
></CheckBox>
<CheckBox checked={true} onClick={controlFlag}></CheckBox>
) : (
<CheckBox
checked={false}
onClick={() => {
controlFlag();
}}
></CheckBox>
<CheckBox checked={false} onClick={controlFlag}></CheckBox>
)}
</Member>
{props.userList?.map((value, index) => {
return <PayChatMemberDiv props={value}></PayChatMemberDiv>;
{info.userList?.map((value, index) => {
return <PayChatMemberDiv key={index} info={value}></PayChatMemberDiv>;
})}
</s.ColumnFlexDiv>
);
Expand Down
Loading

0 comments on commit 8084dc1

Please sign in to comment.