Skip to content

Commit 1fe006d

Browse files
committed
feat: 초대할 멤버 래스트 보여주기
1 parent 541e778 commit 1fe006d

File tree

7 files changed

+106
-4
lines changed

7 files changed

+106
-4
lines changed

src/components/common/Dialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const Dialog = forwardRef<DialogElement, Props>((props, ref) => {
3434
<dialog ref={dialogRef} className="modal modal-middle" onClick={handleClose}>
3535
<div className="modal-box" onClick={(e) => e.stopPropagation()}>
3636
{title && <h3 className="text-lg font-bold">{title}</h3>}
37-
<p className={descClassName}>{desc}</p>
37+
{desc && <p className={descClassName}>{desc}</p>}
3838
{children && <div>{children}</div>}
3939
<form method="dialog" className="modal-action flex justify-center">
4040
<button type="button" className="btn bg-primary text-base-100" onClick={() => dialogRef.current?.close()}>

src/components/common/InputForm.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,13 @@ const InputForm: React.FC<Props> = ({ title, placeholder, hint, onChange, error
2222
onChange={onChange}
2323
{...rest}
2424
/>
25-
<div className="label flex h-8 flex-row items-center">
26-
<span className={`label-text-alt ${error ? 'text-error' : ''}`}>{error ? errorText : hint}</span>
27-
</div>
25+
{error || hint ? (
26+
<div className="label flex h-8 flex-row items-center">
27+
<span className={`label-text-alt ${error ? 'text-error' : ''}`}>{error ? errorText : hint}</span>
28+
</div>
29+
) : (
30+
''
31+
)}
2832
</label>
2933
);
3034
};

src/components/common/UserPlus.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { FC } from 'react';
2+
import DialogButton from '@/components/common/DialogButton';
3+
import IconUserPlus from '@/assets/icons/IconUserPlus';
4+
import UserPlusDialog from '@/components/common/UserPlusDialog';
5+
6+
const AddCalendarPage: FC = () => {
7+
return (
8+
<div>
9+
멤버 초대하기 *
10+
<DialogButton
11+
classname={'userplus'}
12+
name={<IconUserPlus />}
13+
title={'멤버 찾기'}
14+
desc={''}
15+
children={<UserPlusDialog />}
16+
/>
17+
</div>
18+
);
19+
};
20+
21+
export default AddCalendarPage;
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import InputForm from './InputForm.tsx';
2+
import { searchUser } from '../../apis/authApis.ts';
3+
import { FC, useState } from 'react';
4+
import IconSearch from '@/assets/icons/IconSearch.tsx';
5+
import UserPlusList from './UserPlusList.tsx';
6+
7+
const UserPlus: FC = () => {
8+
const [email, setEamil] = useState('');
9+
const [list, setList] = useState<any[]>([]);
10+
11+
const onChange = (event: React.ChangeEvent<HTMLInputElement>) => {
12+
setEamil(event.target.value);
13+
};
14+
15+
const onSearchClick = () => {
16+
searchUser(email).then((value) => {
17+
setList(value.map(({ user_nickname, id }) => <UserPlusList user_nickname={user_nickname} id={id} />));
18+
return list;
19+
});
20+
};
21+
22+
return (
23+
<div>
24+
<div className="flex items-end">
25+
<InputForm title={'닉네임으로 검색하기'} placeholder={'닉네임을 입력하세요'} hint={''} onChange={onChange} />
26+
<button className="btn btn-outline btn-primary" onClick={onSearchClick}>
27+
<IconSearch />
28+
</button>
29+
</div>
30+
<ul id="searchList" role="list" className="divide-y divide-gray-100">
31+
{list}
32+
</ul>
33+
</div>
34+
);
35+
};
36+
37+
export default UserPlus;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { FC } from 'react';
2+
import IconPlus from '@/assets/icons/IconPlus.tsx';
3+
4+
interface Props {
5+
user_nickname: any;
6+
id: string;
7+
}
8+
9+
const UserPlusList: FC<Props> = ({ user_nickname, id }) => {
10+
return (
11+
<li key={id} className="border-b">
12+
<button className="ju btn block flex w-full justify-between border-none bg-transparent" onClick={onPlusClick}>
13+
{user_nickname}
14+
<IconPlus />
15+
</button>
16+
</li>
17+
);
18+
};
19+
20+
const onPlusClick = () => {
21+
console.log('aa');
22+
};
23+
24+
export default UserPlusList;

src/main.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import TextInputForm from './pages/InputFormTest.tsx';
77
import { createBrowserRouter, RouterProvider } from 'react-router-dom';
88
import { JoinPage, LoginPage, ResetPwPage, NotFound, Policy } from './pages/index.ts';
99

10+
import UserPlus from './components/common/UserPlus.tsx';
11+
1012
const router = createBrowserRouter([
1113
{
1214
path: '/',
@@ -35,6 +37,10 @@ const router = createBrowserRouter([
3537
path: 'inputForm',
3638
element: <TextInputForm />,
3739
},
40+
{
41+
path: 'userPlus',
42+
element: <UserPlus />,
43+
},
3844
],
3945
},
4046
{

src/styles/index.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
11
@tailwind base;
22
@tailwind components;
33
@tailwind utilities;
4+
5+
.userplus {
6+
padding: 2rem 1.3rem;
7+
border: 1px solid oklch(var(--b3));
8+
border-radius: 0.5rem;
9+
background-color: oklch(var(--b2));
10+
}
11+
.userplus:hover {
12+
background-color: oklch(var(--b3));
13+
}

0 commit comments

Comments
 (0)