Skip to content

Commit 4c8e6cb

Browse files
committed
Merge branch 'dev' of https://github.com/imaginer-dev/DateLeaf into 164---ui-ν”„λ‘œν•„-μˆ˜μ •-κ΅¬ν˜„
2 parents b51bbe1 + c2cc942 commit 4c8e6cb

25 files changed

+246
-296
lines changed

β€ŽREADME.mdβ€Ž

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,8 @@
3232
## OUR CHALLENGE
3333

3434
## WHO WE ARE
35-
36-
μ΄μ˜ˆμ„œ
35+
* μ΄μ˜ˆμ„œ
36+
* 이정아
37+
* κΉ€λ„μ˜
38+
* ν•œν˜„μ •
39+
* μ΅œκΈ°ν™˜
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import supabase from '@/supabase';
2+
import { Member } from '@/types/Member.ts';
3+
4+
interface CreateNewGroup {
5+
name: string;
6+
description: string;
7+
startDate: string;
8+
endDate: string;
9+
memo: string;
10+
newMemberList: Member[];
11+
}
12+
13+
export const createNewGroupApi = async ({ startDate, endDate, newMemberList, ...props }: CreateNewGroup) => {
14+
// ν˜„μž¬ 둜그인된 μ‚¬μš©μžλ₯Ό κ°€μ Έμ˜¨λ‹€.
15+
const { data: user, error: userError } = await supabase.auth.getUser();
16+
17+
if (userError) {
18+
throw userError;
19+
}
20+
21+
// 그룹을 μƒμ„±ν•œλ‹€.
22+
const { data: groupInfo, error: groupInfoError } = await supabase
23+
.from('groups')
24+
.insert({
25+
name: props.name,
26+
description: props.description,
27+
memo: props.memo,
28+
open: true,
29+
start_date: startDate,
30+
end_date: endDate,
31+
})
32+
.select()
33+
.single();
34+
35+
if (!groupInfo || groupInfoError) {
36+
throw groupInfoError;
37+
}
38+
39+
// 그룹에 멀버λ₯Ό μΆ”κ°€ν•œλ‹€.
40+
const newRelationSchema = newMemberList.map((member) => ({
41+
group_id: groupInfo.id,
42+
user_id: member.id,
43+
}));
44+
45+
newRelationSchema.push({
46+
group_id: groupInfo.id,
47+
user_id: user.user.id,
48+
});
49+
50+
const { error: groupMemberError } = await supabase.from('group_user_ralations').insert(newRelationSchema);
51+
if (groupMemberError) {
52+
throw groupMemberError;
53+
}
54+
55+
return true;
56+
};
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import supabase from '@/supabase';
2+
3+
export const getAllGroupMembers = async (groupId: string) => {
4+
// group_user_ralations 의 응닡 결과의 user_idλ₯Ό ν¬ν•¨ν•˜λŠ” profile리슀트λ₯Ό λ°›μ•„μ˜¨λ‹€.
5+
const { data, error } = await supabase.from('group_user_ralations').select('user_id').eq('group_id', +groupId);
6+
7+
if (error) {
8+
throw error;
9+
}
10+
11+
if (!data) {
12+
throw new Error('데이터λ₯Ό 찾을 수 μ—†μŠ΅λ‹ˆλ‹€.');
13+
}
14+
15+
const { data: allUserProfile, error: getProfileError } = await supabase
16+
.from('profiles')
17+
.select('*')
18+
.in(
19+
'id',
20+
data.map((d) => d.user_id),
21+
);
22+
23+
if (getProfileError) {
24+
throw getProfileError;
25+
}
26+
27+
return allUserProfile;
28+
};

β€Žsrc/apis/getAllMemberSchedule.tsβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { getAllGroupMembers } from '@/apis/groupScheduleApis.ts';
21
import supabase from '@/supabase';
2+
import { getAllGroupMembers } from '@/apis/getAllGroupMember.ts';
33

44
export const getAllMemberSchedule = async (groupId: string) => {
55
const memberList = await getAllGroupMembers(groupId);

β€Žsrc/apis/getOneGroupApi.tsβ€Ž

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import supabase from '@/supabase';
2+
3+
export const getOneGroupApi = async (groupId: string) => {
4+
const { data, error } = await supabase.from('groups').select('*').eq('id', +groupId);
5+
6+
if (error) {
7+
throw error;
8+
}
9+
10+
if (!data) {
11+
throw new Error('데이터λ₯Ό 찾을 수 μ—†μŠ΅λ‹ˆλ‹€.');
12+
}
13+
14+
return data[0];
15+
};

β€Žsrc/apis/groupScheduleApis.tsβ€Ž

Lines changed: 0 additions & 176 deletions
This file was deleted.

β€Žsrc/apis/updateGroupApi.tsβ€Ž

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import supabase from '@/supabase';
2+
3+
interface UpdateGroup {
4+
name: string;
5+
description: string;
6+
startDate: string;
7+
endDate: string;
8+
memo: string;
9+
groupId: string;
10+
}
11+
12+
export const updateGroup = async ({ name, description, startDate, endDate, memo, groupId }: UpdateGroup) => {
13+
console.log(memo);
14+
console.log(description);
15+
const { data, error } = await supabase
16+
.from('groups')
17+
.update({
18+
name,
19+
description,
20+
start_date: startDate,
21+
end_date: endDate,
22+
memo,
23+
})
24+
.eq('id', +groupId);
25+
26+
if (error) {
27+
throw error;
28+
}
29+
30+
return data;
31+
};
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import supabase from '@/supabase';
2+
import { Member } from '@/types/Member.ts';
3+
4+
interface UpdateGroupMember {
5+
updatedMemberList: Member[];
6+
groupId: string;
7+
}
8+
9+
export const updateGroupMember = async ({ updatedMemberList, groupId }: UpdateGroupMember) => {
10+
const { error: deleteError } = await supabase.from('group_user_ralations').delete().eq('group_id', groupId);
11+
if (deleteError) {
12+
throw deleteError;
13+
}
14+
15+
const { data, error: insertError } = await supabase.from('group_user_ralations').insert(
16+
updatedMemberList.map((member) => ({
17+
group_id: +groupId,
18+
user_id: member.id,
19+
})),
20+
);
21+
22+
if (insertError) {
23+
throw insertError;
24+
}
25+
26+
return data;
27+
};

β€Žsrc/components/common/Calendar.tsxβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export default function Calendar({ db_events, onDeleteClicked }: CalendarProps)
3838

3939
const handleDateSelection = (dateClickInfo: { dateStr: string }) => {
4040
console.log(dateClickInfo);
41+
console.log(db_events);
4142
const clickedDateStr = dateClickInfo.dateStr;
4243
setSelectedDate(clickedDateStr);
4344
setSelectedEvents(

β€Žsrc/components/common/SideBar/SideBarGroupList.tsxβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const SideBarGroupList: FC<Props> = ({ userId }) => {
3131
key={group.id + 'sidebar-group-list'}
3232
>
3333
<Link to={`/group/${group.id}`}>{group.name}</Link>
34-
<Link to={`/group/${group.id}/edit/${group.id}`}>
34+
<Link to={`/group/${group.id}/edit`}>
3535
<PencilIcon />
3636
</Link>
3737
</li>

0 commit comments

Comments
Β (0)