Skip to content

Commit

Permalink
Fix: selecting user to delete
Browse files Browse the repository at this point in the history
  • Loading branch information
yoosaemsol committed Apr 7, 2021
1 parent be81b69 commit 8c8c614
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 61 deletions.
17 changes: 4 additions & 13 deletions src/components/Content/AdminContent.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
import React from "react";
import React, { useState } from "react";
import styled from "styled-components";
import { useSelector, useDispatch } from "react-redux";
import AdminDeleteModal from "../Modal/AdminDeleteModal";
import { adminDelete } from "../../store/actions/exporterActions";

const AdminContent = ({
admin,
deleteAdmin,
cancleAdminDeleteModal,
isAdminDeleteModalActive,
setIsAdminDeleteModalActive,
setSelectedAdmiin,
}) => {
const dispatch = useDispatch();
const changeTheme = useSelector((store) => store.darkThemeReducer);
const handleAdminDelete = (e) => {
const payload = e.target.name;
setIsAdminDeleteModalActive(!isAdminDeleteModalActive);
dispatch(adminDelete(payload));
setSelectedAdmiin(e.target.name);
};

return (
<AdminCard dark={changeTheme}>
<AdminInfo>
Expand All @@ -34,13 +32,6 @@ const AdminContent = ({
>
Resign
</AdminResign>
{isAdminDeleteModalActive && (
<AdminDeleteModal
adminName={admin.username}
deleteAdmin={deleteAdmin}
cancleAdminDeleteModal={cancleAdminDeleteModal}
/>
)}
</AdminCard>
);
};
Expand Down
2 changes: 0 additions & 2 deletions src/components/Content/UsersContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ const UsersContent = ({
setUserType(e.target.name);
setIsAdminAddModalActive(true);
}
console.log(e.target.id);
console.log(e.target.name);
};
return (
<>
Expand Down
6 changes: 0 additions & 6 deletions src/components/Login/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ const Login = ({ history }) => {
const callBackUrl = window.location.href;
const code = callBackUrl.substring(callBackUrl.indexOf("=") + 1);
const dispatch = useDispatch();
console.log("code ?? >>", code);
console.log("id ?? >> ", clientID);
console.log("secret ?? >> ", clientSecret);
console.log("url ?? >>", callBackUrl);
const getAccessToken = () => {
axios({
method: "POST",
Expand All @@ -34,7 +30,6 @@ const Login = ({ history }) => {
},
})
.then((res) => {
console.log("성공1 res >> ", res);
setAccessToken(res.data["access_token"]);
})
.catch((err) => console.log(err));
Expand All @@ -48,7 +43,6 @@ const Login = ({ history }) => {
},
})
.then((res) => {
console.log("성공2 res >> ", res);
sessionStorage.setItem("access_token", res.data.access_token);
sessionStorage.setItem("user_type", res.data.type);
dispatch(getLoginState(true));
Expand Down
3 changes: 1 addition & 2 deletions src/components/Modal/AdminAddModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ const AdminAddModal = ({
cancleAdminAddModal();
setSearchUser("");
};
console.log("a", userName);
console.log("b", userType);

return (
<ModalContainer>
<Div>
Expand Down
10 changes: 6 additions & 4 deletions src/components/Modal/AdminDeleteModal.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import React from "react";
import styled from "styled-components";
import { useSelector } from "react-redux";

const AdminDeleteModal = ({ cancleAdminDeleteModal, deleteAdmin }) => {
const selectAdmin = useSelector((store) => store.adminDeleteReducer);
const AdminDeleteModal = ({
cancleAdminDeleteModal,
deleteAdmin,
adminName,
}) => {
return (
<ModalContainer>
<Div>
<h4>Are you sure to resign this admin ?</h4>
<Container>
<button onClick={() => deleteAdmin(selectAdmin)}>Yes</button>
<button onClick={() => deleteAdmin(adminName)}>Yes</button>
<button onClick={cancleAdminDeleteModal}>Cancle</button>
</Container>
</Div>
Expand Down
8 changes: 0 additions & 8 deletions src/components/MyBucket/MyBucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,9 @@ const MyBucket = () => {
<Permission
isAdminAddModalActive={isAdminAddModalActive}
setIsAdminAddModalActive={setIsAdminAddModalActive}
// isAdminDeleteModalActive={isAdminDeleteModalActive}
// setIsAdminDeleteModalActive={setIsAdminDeleteModalActive}
// cancleAdminDeleteModal={cancleAdminDeleteModal}
/>
),
};
// console.log("삭제모달켜짐?", isAdminDeleteModalActive);
// const TABMENU = [
// { id: 0, tabName: "Fork" },
// { id: 1, tabName: "Set Admin" },
// ];

const TABMENU = isAdmin
? [
Expand Down
9 changes: 6 additions & 3 deletions src/components/MyBucket/components/Permission.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import axios from "axios";
import { changeBucketPage } from "../../../store/actions/exporterActions";
import { ADMIN_API, API_SURVER } from "../../../config";
import UsersContent from "../../Content/UsersContent";
import AdminDeleteModal from "../../Modal/AdminDeleteModal";

const Permission = () => {
const [searchUser, setSearchUser] = useState();
Expand All @@ -17,6 +18,7 @@ const Permission = () => {
const [isAdminDeleteModalActive, setIsAdminDeleteModalActive] = useState(
false
);
const [selectedAdmin, setSelectedAdmiin] = useState();
const token = sessionStorage.getItem("access_token");
const changeTheme = useSelector((store) => store.darkThemeReducer);
const dispatch = useDispatch();
Expand Down Expand Up @@ -152,20 +154,21 @@ const Permission = () => {
cancleAdminDeleteModal={cancleAdminDeleteModal}
isAdminDeleteModalActive={isAdminDeleteModalActive}
setIsAdminDeleteModalActive={setIsAdminDeleteModalActive}
setSelectedAdmiin={setSelectedAdmiin}
/>
);
})}
</AdminContainer>
<AlertModal isActive={alertModal}>
<p>Invitation has been sent to the user's email!!</p>
</AlertModal>
{/* {isAdminDeleteModalActive && (
{isAdminDeleteModalActive && (
<AdminDeleteModal
adminName={admin.username}
adminName={selectedAdmin}
deleteAdmin={deleteAdmin}
cancleAdminDeleteModal={cancleAdminDeleteModal}
/>
)} */}
)}
</Container>
);
};
Expand Down
6 changes: 0 additions & 6 deletions src/store/actions/exporterActions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const ADD_ADMIN_STATE = "ADD_ADMIN_STATE";
const ADD_ADMIN_TYPE_STATE = "ADD_ADMIN_TYPE_STATE";
const DELETE_ADMIN_STATE = "DELETE_ADMIN_STATE";
const CHANGE_BUCKET_PAGE = "CHANGE_BUCKET_PAGE";
const FILTER_BY_USER = "FILTER_BY_USER";
const ALL_DATA = "ALL_DATA";
Expand All @@ -24,11 +23,6 @@ export const adminAdd = (payload) => ({
payload,
});

export const adminDelete = (payload) => ({
type: DELETE_ADMIN_STATE,
payload,
});

export const changeDarkTheme = (payload) => ({
type: GET_DARK_THEME,
payload,
Expand Down
1 change: 0 additions & 1 deletion src/store/reducers/adminAddTypeReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const initialState = null;
const adminAddTypeReducer = (state = initialState, action) => {
switch (action.type) {
case ADD_ADMIN_TYPE_STATE:
console.log("type >> ", action.payload);
return action.payload;
default:
return state;
Expand Down
14 changes: 0 additions & 14 deletions src/store/reducers/adminDeleteReducer.js

This file was deleted.

2 changes: 0 additions & 2 deletions src/store/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import navFilterReducer from "./navFilterReducer";
import cateFilterReducer from "./cateFilterReducer";
import sortFilterReducer from "./sortFilterReducer";
import darkThemeReducer from "./darkThemeReducer";
import adminDeleteReducer from "./adminDeleteReducer";
import adminAddReducer from "./adminAddReducer";
import adminAddTypeReducer from "./adminAddTypeReducer";
export default combineReducers({
Expand All @@ -31,7 +30,6 @@ export default combineReducers({
sortFilterReducer,
searchFilterReducer,
darkThemeReducer,
adminDeleteReducer,
adminAddReducer,
adminAddTypeReducer,
});

0 comments on commit 8c8c614

Please sign in to comment.