Merge branch 'main' into tracker-connect-back

This commit is contained in:
Николай Полтщук 2023-05-15 21:24:25 +03:00
commit 65874161c7
3 changed files with 34 additions and 23 deletions

View File

@ -7,7 +7,8 @@ import {
getValueModalType, getValueModalType,
setProject, setProject,
setProjectBoardFetch, setProjectBoardFetch,
editProjectName editProjectName,
getColumnTitle,
} from "../../../redux/projectsTrackerSlice"; } from "../../../redux/projectsTrackerSlice";
import "./trackerModal.scss"; import "./trackerModal.scss";
@ -18,7 +19,8 @@ export const TrackerModal = ({
selectedTab, selectedTab,
defautlInput, defautlInput,
titleProject, titleProject,
projectId projectId,
titleColumn
}) => { }) => {
const dispatch = useDispatch(); const dispatch = useDispatch();
const projectBoard = useSelector(getProjectBoard); const projectBoard = useSelector(getProjectBoard);
@ -27,6 +29,8 @@ export const TrackerModal = ({
const [emailWorker, setEmailWorker] = useState(""); const [emailWorker, setEmailWorker] = useState("");
const [projectName, setProjectName] = useState(defautlInput); const [projectName, setProjectName] = useState(defautlInput);
const [editTitleColumn, setEditTitleColumn] = useState(titleColumn);
const [valueColumn, setValueColumn] = useState(""); const [valueColumn, setValueColumn] = useState("");
const [nameProject, setNameProject] = useState(""); const [nameProject, setNameProject] = useState("");
@ -80,11 +84,11 @@ export const TrackerModal = ({
method: "PUT", method: "PUT",
data: { data: {
project_id: projectId, project_id: projectId,
name: projectName name: projectName,
}, },
}).then((res) => { }).then((res) => {
setActive(false) setActive(false);
dispatch(editProjectName({id: projectId, name: projectName})) dispatch(editProjectName({ id: projectId, name: projectName }));
}); });
} }
@ -232,7 +236,6 @@ export const TrackerModal = ({
</button> </button>
</div> </div>
)} )}
{/* TODO: fix state */}
{modalType === "editColumn" && ( {modalType === "editColumn" && (
<div> <div>
<div className="title-project"> <div className="title-project">
@ -240,8 +243,8 @@ export const TrackerModal = ({
<div className="input-container"> <div className="input-container">
<input <input
className="name-project" className="name-project"
value={defautlInput} value={editTitleColumn}
onChange={(e) => setValueTiket(e.target.value)} onChange={(e) => setEditTitleColumn(e.target.value)}
/> />
</div> </div>
</div> </div>

View File

@ -16,6 +16,7 @@ import {
setProjectBoardFetch, setProjectBoardFetch,
setToggleTab, setToggleTab,
activeLoader, activeLoader,
setColumnTitle,
} from "../../redux/projectsTrackerSlice"; } from "../../redux/projectsTrackerSlice";
import ModalTicket from "../../components/UI/ModalTicket/ModalTicket"; import ModalTicket from "../../components/UI/ModalTicket/ModalTicket";
@ -191,6 +192,12 @@ export const ProjectTracker = () => {
</Link> </Link>
</div> </div>
<div className="tracker__tabs__content"> <div className="tracker__tabs__content">
<TrackerModal
active={modalAdd}
setActive={setModalAdd}
selectedTab={selectedTab}
/>
{loader && <Loader style="green" />} {loader && <Loader style="green" />}
{!loader && ( {!loader && (
<div className="tracker__tabs__content__tasks tasks active__content"> <div className="tracker__tabs__content__tasks tasks active__content">
@ -198,12 +205,6 @@ export const ProjectTracker = () => {
<div className="tasks__head__wrapper"> <div className="tasks__head__wrapper">
<h4>Проект : {projectBoard.name}</h4> <h4>Проект : {projectBoard.name}</h4>
<TrackerModal
active={modalAdd}
setActive={setModalAdd}
selectedTab={selectedTab}
></TrackerModal>
<div className="tasks__head__add"> <div className="tasks__head__add">
<span <span
onClick={() => { onClick={() => {
@ -269,6 +270,12 @@ export const ProjectTracker = () => {
wrapperHover[column.id] ? "tasks__board__hover" : "" wrapperHover[column.id] ? "tasks__board__hover" : ""
}`} }`}
> >
<TrackerModal
active={modalAdd}
setActive={setModalAdd}
selectedTab={selectedTab}
titleColumn={column.title}
/>
<div className="board__head"> <div className="board__head">
{/*<span className={wrapperIndex === 3 ? "done" : ""}>*/} {/*<span className={wrapperIndex === 3 ? "done" : ""}>*/}
<span>{column.title}</span> <span>{column.title}</span>

View File

@ -6,7 +6,7 @@ const initialState = {
projectBoard: {}, projectBoard: {},
toggleTab: 1, toggleTab: 1,
modalType: "", modalType: "",
boardLoader: false boardLoader: false,
}; };
export const setProjectBoardFetch = createAsyncThunk("userInfo", (id) => export const setProjectBoardFetch = createAsyncThunk("userInfo", (id) =>
@ -29,12 +29,12 @@ export const projectsTrackerSlice = createSlice({
deleteProject: (state, action) => { deleteProject: (state, action) => {
state.projects.forEach((project) => { state.projects.forEach((project) => {
if (project.id === action.payload.id) { if (project.id === action.payload.id) {
project.status = 10 project.status = 10;
} }
}) });
}, },
activeLoader: (state) => { activeLoader: (state) => {
state.boardLoader = true state.boardLoader = true;
}, },
moveProjectTask: (state, action) => { moveProjectTask: (state, action) => {
state.projectBoard.columns.forEach((column, index) => { state.projectBoard.columns.forEach((column, index) => {
@ -58,9 +58,9 @@ export const projectsTrackerSlice = createSlice({
editProjectName: (state, action) => { editProjectName: (state, action) => {
state.projects.forEach((project) => { state.projects.forEach((project) => {
if (project.id === action.payload.id) { if (project.id === action.payload.id) {
project.name = action.payload.name project.name = action.payload.name;
} }
}) });
}, },
modalToggle: (state, action) => { modalToggle: (state, action) => {
state.modalType = action.payload; state.modalType = action.payload;
@ -69,7 +69,7 @@ export const projectsTrackerSlice = createSlice({
extraReducers: { extraReducers: {
[setProjectBoardFetch.fulfilled]: (state, action) => { [setProjectBoardFetch.fulfilled]: (state, action) => {
state.projectBoard = action.payload; state.projectBoard = action.payload;
state.boardLoader = false state.boardLoader = false;
}, },
}, },
}); });
@ -82,13 +82,14 @@ export const {
setToggleTab, setToggleTab,
modalToggle, modalToggle,
activeLoader, activeLoader,
editProjectName editProjectName,
setColumnTitle,
} = projectsTrackerSlice.actions; } = projectsTrackerSlice.actions;
export const getProjects = (state) => state.tracker.projects; export const getProjects = (state) => state.tracker.projects;
export const getProjectBoard = (state) => state.tracker.projectBoard; export const getProjectBoard = (state) => state.tracker.projectBoard;
export const getToggleTab = (state) => state.tracker.toggleTab; export const getToggleTab = (state) => state.tracker.toggleTab;
export const getValueModalType = (state) => state.tracker.modalType; export const getValueModalType = (state) => state.tracker.modalType;
export const getBoarderLoader = (state) => state.tracker.boardLoader export const getBoarderLoader = (state) => state.tracker.boardLoader;
export default projectsTrackerSlice.reducer; export default projectsTrackerSlice.reducer;