Skip to content

Commit b2a2a79

Browse files
committed
Update edit modal UI and request
1 parent ceed8db commit b2a2a79

2 files changed

Lines changed: 14 additions & 60 deletions

File tree

frontend/app/components/EditModal.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ function EditModal({ isOpen, setOpen, circleId }: InviteModalProps) {
104104
/>
105105
<svg xmlns="http://www.w3.org/2000/svg"
106106
className="size-11 search-icon hover:cursor-pointer"
107-
fill="hsl(0, 0%, 95%)"
107+
fill="hsl(0, 0%, 100%)"
108108
viewBox="0 0 24 24"
109-
stroke="hsl(0, 0%, 95%)"
109+
stroke="hsl(0, 0%, 100%)"
110110
strokeWidth="1">
111111
<path d="M 9 2 C 5.1458514 2 2 5.1458514 2 9 C 2 12.854149 5.1458514 16 9 16 C 10.747998 16 12.345009 15.348024 13.574219 14.28125 L 14 14.707031 L 14 16 L 20 22 L 22 20 L 16 14 L 14.707031 14 L 14.28125 13.574219 C 15.348024 12.345009 16 10.747998 16 9 C 16 5.1458514 12.854149 2 9 2 z M 9 4 C 11.773268 4 14 6.2267316 14 9 C 14 11.773268 11.773268 14 9 14 C 6.2267316 14 4 11.773268 4 9 C 4 6.2267316 6.2267316 4 9 4 z"></path>
112112
</svg>

frontend/app/components/SearchModal.tsx

Lines changed: 12 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import React, { useEffect, useState } from 'react';
1+
import React, { use, useEffect, useState } from 'react';
22
import { useAuth } from "../context/authContext";
3-
import { User } from "../types";
43
import "./SearchModal.css"
4+
import { text } from 'stream/consumers';
55

66
interface SearchModalProps {
77
isOpen: boolean;
@@ -16,53 +16,15 @@ function SearchModal({ isOpen, setOpen, circleId }: SearchModalProps) {
1616
}
1717
const { getAccessToken } = authContext;
1818

19-
const [users, setUsers] = useState<User[]>([]);
20-
useEffect(() => {
21-
async function fetchInviteUsers() {
22-
const token = await getAccessToken();
23-
const headers = {
24-
'Authorization': `Bearer ${token}`,
25-
};
26-
const body = {
27-
circle_id: circleId,
28-
};
29-
fetch('http://localhost:8000/api/circles/invite', {
30-
method: 'POST',
31-
headers: headers,
32-
body: JSON.stringify(body),
33-
})
34-
.then(async (response) => {
35-
const data = await response.json();
36-
if (!response.ok) {
37-
console.log("Error:", data);
38-
}
39-
else {
40-
console.log("Data:", data);
41-
const mappedUsers = data.map((user: any) => ({
42-
id: user.id,
43-
username: user.username,
44-
checked: false
45-
}));
46-
setUsers(mappedUsers);
47-
}
48-
})
49-
.catch(error => {
50-
console.log(error);
51-
});
52-
}
53-
fetchInviteUsers();
54-
}, [circleId]);
55-
5619
async function handleSubmit(e: React.FormEvent<HTMLFormElement>) {
5720
e.preventDefault();
58-
const invitedUsers = users.filter(user => user.checked).map(user => user.id);
5921
const token = await getAccessToken();
6022
const headers = {
6123
'Authorization': `Bearer ${token}`,
6224
};
6325
const body = {
6426
circle_id: circleId,
65-
users: invitedUsers,
27+
content: (e.currentTarget.elements.namedItem('circleName') as HTMLInputElement).value,
6628
};
6729
console.log(body);
6830
fetch('http://localhost:8000/api/circles/search', {
@@ -85,8 +47,6 @@ function SearchModal({ isOpen, setOpen, circleId }: SearchModalProps) {
8547
});
8648
};
8749

88-
const [inviteAll, setInviteAll] = useState(false);
89-
9050
if (!isOpen) return null;
9151

9252
return (
@@ -98,21 +58,15 @@ function SearchModal({ isOpen, setOpen, circleId }: SearchModalProps) {
9858
placeholder="Search text"
9959
id="circleName"
10060
/>
101-
<svg xmlns="http://www.w3.org/2000/svg"
102-
className="size-11 search-icon hover:cursor-pointer"
103-
fill="hsl(0, 0%, 95%)"
104-
viewBox="0 0 24 24"
105-
stroke="hsl(0, 0%, 95%)"
106-
strokeWidth="1">
107-
<path d="M 9 2 C 5.1458514 2 2 5.1458514 2 9 C 2 12.854149 5.1458514 16 9 16 C 10.747998 16 12.345009 15.348024 13.574219 14.28125 L 14 14.707031 L 14 16 L 20 22 L 22 20 L 16 14 L 14.707031 14 L 14.28125 13.574219 C 15.348024 12.345009 16 10.747998 16 9 C 16 5.1458514 12.854149 2 9 2 z M 9 4 C 11.773268 4 14 6.2267316 14 9 C 14 11.773268 11.773268 14 9 14 C 6.2267316 14 4 11.773268 4 9 C 4 6.2267316 6.2267316 4 9 4 z"></path>
108-
</svg>
109-
</div>
110-
<div className="flex items-center justify-between">
111-
<button
112-
type="submit"
113-
className="inline-block rounded-lg bg-blue-500 px-5 py-3 text-sm font-medium text-white"
114-
>
115-
Submit
61+
<button type="submit">
62+
<svg xmlns="http://www.w3.org/2000/svg"
63+
className="size-11 search-icon hover:cursor-pointer"
64+
fill="hsl(0, 0%, 100%)"
65+
viewBox="0 0 24 24"
66+
stroke="hsl(0, 0%, 100%)"
67+
strokeWidth="1">
68+
<path d="M 9 2 C 5.1458514 2 2 5.1458514 2 9 C 2 12.854149 5.1458514 16 9 16 C 10.747998 16 12.345009 15.348024 13.574219 14.28125 L 14 14.707031 L 14 16 L 20 22 L 22 20 L 16 14 L 14.707031 14 L 14.28125 13.574219 C 15.348024 12.345009 16 10.747998 16 9 C 16 5.1458514 12.854149 2 9 2 z M 9 4 C 11.773268 4 14 6.2267316 14 9 C 14 11.773268 11.773268 14 9 14 C 6.2267316 14 4 11.773268 4 9 C 4 6.2267316 6.2267316 4 9 4 z"></path>
69+
</svg>
11670
</button>
11771
</div>
11872
</form>

0 commit comments

Comments
 (0)