refactor: rename contact with user

This commit is contained in:
Tristan Yang
2022-07-04 16:12:23 +08:00
parent 6083040e2b
commit 101dbdb5ee
76 changed files with 319 additions and 286 deletions
+8 -8
View File
@@ -4,7 +4,7 @@ import { useNavigate } from "react-router-dom";
import Modal from "../Modal";
import Button from "../styled/Button";
import ChannelIcon from "../ChannelIcon";
import Contact from "../Contact";
import User from "../User";
import StyledWrapper from "./styled";
import StyledCheckbox from "../styled/Checkbox";
import StyledToggle from "../../component/styled/Toggle";
@@ -19,8 +19,8 @@ interface Props {
}
const ChannelModal: FC<Props> = ({ personal = false, closeModal }) => {
const { contactsData, loginUid } = useAppSelector((store) => {
return { contactsData: store.contacts.byId, loginUid: store.authData.user?.uid };
const { usersData, loginUid } = useAppSelector((store) => {
return { usersData: store.users.byId, loginUid: store.authData.user?.uid };
});
const navigateTo = useNavigate();
const [data, setData] = useState<CreateChannelDTO>({
@@ -30,7 +30,7 @@ const ChannelModal: FC<Props> = ({ personal = false, closeModal }) => {
is_public: !personal
});
const { contacts, input, updateInput } = useFilteredUsers();
const { users, input, updateInput } = useFilteredUsers();
const [createChannel, { isSuccess, isError, isLoading, data: newChannelId }] =
useCreateChannelMutation();
@@ -85,7 +85,7 @@ const ChannelModal: FC<Props> = ({ personal = false, closeModal }) => {
};
if (!loginUid) return null;
const loginUser = contactsData[Number(loginUid)];
const loginUser = usersData[Number(loginUid)];
if (!loginUser) return null;
const { name, members, is_public } = data;
@@ -101,9 +101,9 @@ const ChannelModal: FC<Props> = ({ personal = false, closeModal }) => {
placeholder="Type Username to search"
/>
</div>
{contacts && (
{users && (
<ul className="users">
{contacts.map((u) => {
{users.map((u) => {
const { uid } = u;
const checked = members ? members.includes(uid) : false;
return (
@@ -120,7 +120,7 @@ const ChannelModal: FC<Props> = ({ personal = false, closeModal }) => {
name="cb"
id="cb"
/>
<Contact uid={uid} interactive={false} />
<User uid={uid} interactive={false} />
</li>
);
})}