Skip to content

Commit

Permalink
Merge pull request #23 from CNU-OOHub/feat/#17-organization
Browse files Browse the repository at this point in the history
feat/#17 organization
  • Loading branch information
miraekwak authored Oct 30, 2022
2 parents b3a4958 + eecafd0 commit f010651
Show file tree
Hide file tree
Showing 7 changed files with 397 additions and 8 deletions.
61 changes: 56 additions & 5 deletions src/api.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,28 @@ export const addUserInOrganization = async (organizationName, userInfo) => {
alert("organization에 사용자가 추가되었습니다");
}
} catch (error) {
console.log(error);
if (error.response.data.status === 409) {
alert("해당 사용자는 이미 그룹에 있습니다.");
}
throw new Error("Add user in organization error");
}
};

// organization에서 사용자 삭제
export const deleteOrganizationMember = async (organizationName, username) => {
try {
const response = await axios.delete(
`${SERVER}/api/v1/organization/${organizationName}/${username}`
);
if (response.status === 200) {
alert("해당 사용자가 그룹에서 제외되었습니다");
}
} catch (error) {
console.log(error);
throw new Error("delete organization error");
}
};

// 사용자별 organization 목록 조회
export const getAllOrganization = async (username) => {
try {
Expand All @@ -200,10 +217,42 @@ export const getAllOrganization = async (username) => {
};

export const useGetAllOrganizations = (username) => {
return useQuery(["organizations"], () => getAllOrganization(username), {
staleTime: 5000,
cacheTime: Infinity,
});
return useQuery(
["organizationList", username],
() => getAllOrganization(username),
{
staleTime: 5000,
cacheTime: Infinity,
}
);
};

// 그룹의 사용자 목록 조회
export const getOrganizationMemberList = async (organizationName) => {
try {
const { data } = await axios.get(
`${SERVER}/api/v1/organization/${organizationName}`,
{}
);
return data;
} catch (err) {
throw new Error("fetch all organization error");
}
};

export const useGetOrganizationMemberList = (organizationName) => {
return useQuery(
["memberList", organizationName],
() => getOrganizationMemberList(organizationName),
{
enabled: false,
staleTime: 5000,
cacheTime: Infinity,
refetchOnWindowFocus: false,
initialData: [],
}
);

};

//////////////////////공유 파일/////////////////////////
Expand Down Expand Up @@ -267,6 +316,7 @@ export const deleteSharedFile = async (organizationName, fileName) => {
}
};


// 파일로 실행
export const runFile = async (userInfo) => {
try {
Expand Down Expand Up @@ -361,3 +411,4 @@ export const getAllResource = async () => {
}
};


4 changes: 2 additions & 2 deletions src/atom.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { atom } from "recoil";

export const loginState = atom({ key: "login", default: true });
export const loginState = atom({ key: "login", default: false });

export const adminState = atom({ key: "admin", default: false });
export const adminState = atom({ key: "admin", default: true });

export const adminCategoryModalVisibleState = atom({
key: "adminCategoryModal",
Expand Down
4 changes: 4 additions & 0 deletions src/components/atoms/button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const CustomButton = styled.button`
background-color: ${(props) => props.bgColor};
font-size: ${(props) => `${props.fontSize}rem`};
font-weight: ${(props) => props.fontWeight};
//border: ${(props) => props.border};
margin-top: ${(props) => `${props.marginTop}rem`};
${(props) =>
props.hoverEvent &&
css`
Expand All @@ -37,6 +39,7 @@ const Button = ({
fontWeight = 700,
border = "none",
hoverEvent = false,
marginTop = "0",
borderBottom,
}) => {
return (
Expand All @@ -52,6 +55,7 @@ const Button = ({
fontWeight={fontWeight}
border={border}
hoverEvent={hoverEvent}
marginTop={marginTop}
borderBottom={borderBottom}
type="button"
>
Expand Down
2 changes: 2 additions & 0 deletions src/components/atoms/text.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const Text = ({
fontWeight = "normal",
color = "black",
marginTop = "0vh",
marginRight = "0vh",
marginBottom = "0vh",
marginLeft = "0vh",
onClick,
Expand Down Expand Up @@ -33,6 +34,7 @@ const Text = ({
marginBottom: marginBottom,
marginLeft: marginLeft,
fontFamily: "inter",
marginRight: marginRight,
}}
>
{children}
Expand Down
2 changes: 1 addition & 1 deletion src/components/molecules/flexColumn.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const Container = styled.div`
padding-left: ${(props) => `${props.horizontalPadding}rem`};
padding-right: ${(props) => `${props.horizontalPadding}rem`};
align-content: center;
//align-items: center;
// align-items: center;
text-align: center;
vertical-align: middle;
`;
Expand Down
Loading

0 comments on commit f010651

Please sign in to comment.