Tabs and Manager list fix some functions
WIP Project stop by order chefpull/14/head^2
parent
3c43d78cfc
commit
4c24f81336
|
@ -1,9 +1,9 @@
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { BadgeComponentStyled } from "./BadgeComponent.style";
|
import { BadgeComponentStyled } from "./BadgeComponent.style";
|
||||||
|
|
||||||
const BadgeComponent = ({ counter, position, top, left, right, bottom }) => {
|
const BadgeComponent = ({ counter,fontSize, position, top, left, right, bottom,bgcolor }) => {
|
||||||
return (
|
return (
|
||||||
<BadgeComponentStyled position={position} top={top} left={left} right={right} bottom={bottom}>
|
<BadgeComponentStyled position={position} top={top} left={left} right={right} bottom={bottom} fontSize={fontSize} bgcolor={bgcolor}>
|
||||||
{counter}
|
{counter}
|
||||||
</BadgeComponentStyled>
|
</BadgeComponentStyled>
|
||||||
);
|
);
|
||||||
|
|
|
@ -15,8 +15,8 @@ export const BadgeComponentStyled = styled.span`
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
width: 21px;
|
width: 21px;
|
||||||
height: 21px;
|
height: 21px;
|
||||||
font-size: 16px;
|
font-size: ${({ fontSize }) => (fontSize ? fontSize : "16px")};
|
||||||
color: ${color.pricinpal.blanco};
|
color: ${color.pricinpal.blanco};
|
||||||
background-color: ${color.status.yes};
|
background-color: ${({ bgcolor }) => (bgcolor ? bgcolor : color.status.yes)};
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { color } from "../../../../style/varibles";
|
||||||
|
|
||||||
const InputComponentStyled = styled.input`
|
const InputComponentStyled = styled.input`
|
||||||
width: 100%;
|
width: 100%;
|
||||||
background: transparent;
|
background: ${color.complement.azulOscuro};
|
||||||
border: none;
|
border: none;
|
||||||
color: ${color.complement.azulCielo};
|
color: ${color.complement.azulCielo};
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -88,13 +88,9 @@ const Ticket = () => {
|
||||||
setDrawerOpen(false);
|
setDrawerOpen(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const style ={
|
|
||||||
height: "fit-content",
|
|
||||||
width: "100%",
|
|
||||||
position: "relative",
|
|
||||||
}
|
|
||||||
return (
|
return (
|
||||||
<div className="test" style={style} >
|
<div className="test" >
|
||||||
<TicketHeader loading={loading}>
|
<TicketHeader loading={loading}>
|
||||||
<div>
|
<div>
|
||||||
<TicketInfo contact={contact} ticket={ticket} onClick={handleDrawerOpen} />
|
<TicketInfo contact={contact} ticket={ticket} onClick={handleDrawerOpen} />
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
import styled from "styled-components";
|
||||||
|
import { color } from "../../style/varibles";
|
||||||
|
|
||||||
|
export const TicketStyled = styled.div`
|
||||||
|
width: 100%;
|
||||||
|
background-color: ${color.status.no};
|
||||||
|
`;
|
|
@ -1,5 +1,5 @@
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import {color} from "../../../../../style/varibles";
|
import { color } from "../../../../../style/varibles";
|
||||||
import { useHistory } from "react-router-dom";
|
import { useHistory } from "react-router-dom";
|
||||||
import { parseISO, format, isSameDay } from "date-fns";
|
import { parseISO, format, isSameDay } from "date-fns";
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import { i18n } from "../../../../../translate/i18n";
|
||||||
import api from "../../../../../services/api";
|
import api from "../../../../../services/api";
|
||||||
import { AuthContext } from "../../../../../context/Auth/AuthContext";
|
import { AuthContext } from "../../../../../context/Auth/AuthContext";
|
||||||
import toastError from "../../../../../errors/toastError";
|
import toastError from "../../../../../errors/toastError";
|
||||||
import Btn from "../../../../Base/Btn/Btn"
|
import Btn from "../../../../Base/Btn/Btn";
|
||||||
import {
|
import {
|
||||||
TicketDateStyled,
|
TicketDateStyled,
|
||||||
TicketImgStyled,
|
TicketImgStyled,
|
||||||
|
@ -24,7 +24,6 @@ const TicketListItem = ({ tickets }) => {
|
||||||
const [loading, setLoading] = React.useState(false);
|
const [loading, setLoading] = React.useState(false);
|
||||||
const isMounted = React.useRef(true);
|
const isMounted = React.useRef(true);
|
||||||
const { user } = React.useContext(AuthContext);
|
const { user } = React.useContext(AuthContext);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
return () => {
|
return () => {
|
||||||
isMounted.current = false;
|
isMounted.current = false;
|
||||||
|
@ -32,7 +31,7 @@ const TicketListItem = ({ tickets }) => {
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleAcepptTicket = async (id) => {
|
const handleAcepptTicket = async (id) => {
|
||||||
setLoading(true)
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
await api.put(`/tickets/${id}`, {
|
await api.put(`/tickets/${id}`, {
|
||||||
status: "open",
|
status: "open",
|
||||||
|
@ -54,10 +53,14 @@ const TicketListItem = ({ tickets }) => {
|
||||||
const handleSelectTicket = (id) => {
|
const handleSelectTicket = (id) => {
|
||||||
history.push(`/tickets/${id}`);
|
history.push(`/tickets/${id}`);
|
||||||
};
|
};
|
||||||
if (loading) return <LoadingScreen />;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<React.Fragment key={tickets.id} >
|
<React.Fragment key={tickets.id}>
|
||||||
<TicketListItemStyled queuecolor={tickets.queue} onClick={()=>handleSelectTicket(tickets.id)}>
|
<TicketListItemStyled
|
||||||
|
queuecolor={tickets.queue}
|
||||||
|
onClick={() => handleSelectTicket(tickets.id)}
|
||||||
|
>
|
||||||
{tickets.contact.profilePicUrl ? (
|
{tickets.contact.profilePicUrl ? (
|
||||||
<TicketImgStyled src={tickets.contact.profilePicUrl} alt={tickets.id} />
|
<TicketImgStyled src={tickets.contact.profilePicUrl} alt={tickets.id} />
|
||||||
) : (
|
) : (
|
||||||
|
@ -86,7 +89,13 @@ const TicketListItem = ({ tickets }) => {
|
||||||
)}
|
)}
|
||||||
</TicketDateStyled>
|
</TicketDateStyled>
|
||||||
{tickets.status === "pending" ? (
|
{tickets.status === "pending" ? (
|
||||||
<Btn text="Aceitar" bgcolor={color.complement.azulCielo} fontcolor={color.pricinpal.blanco} fontSize="12px"/>
|
<Btn
|
||||||
|
onClick={() => handleAcepptTicket(tickets.id)}
|
||||||
|
text="Aceitar"
|
||||||
|
bgcolor={color.complement.azulCielo}
|
||||||
|
fontcolor={color.pricinpal.blanco}
|
||||||
|
fontSize="12px"
|
||||||
|
/>
|
||||||
) : (
|
) : (
|
||||||
""
|
""
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -2,6 +2,8 @@ import React from "react";
|
||||||
|
|
||||||
import openSocket from "socket.io-client";
|
import openSocket from "socket.io-client";
|
||||||
|
|
||||||
|
import LoadingScreen from "../../../LoadingScreen/LoadingScreen";
|
||||||
|
|
||||||
import TicketListStyled from "./TicketsList.style";
|
import TicketListStyled from "./TicketsList.style";
|
||||||
import useTickets from "../../../../hooks/useTickets";
|
import useTickets from "../../../../hooks/useTickets";
|
||||||
import TicketListItem from "../TicketsList/TicketListItem/TicketListItem";
|
import TicketListItem from "../TicketsList/TicketListItem/TicketListItem";
|
||||||
|
@ -94,10 +96,14 @@ const reducer = (state, action) => {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const TicketsList = ({ status, searchParam, showAll, selectedQueueIds, updateCount }) => {
|
const TicketsList = ({ status, searchParam, showAll, selectedQueueIds, updateCount, valueTab }) => {
|
||||||
const [pageNumber, setPageNumber] = React.useState(1);
|
const [pageNumber, setPageNumber] = React.useState(1);
|
||||||
const [ticketsList, dispatch] = React.useReducer(reducer, []);
|
const [ticketsList, dispatch] = React.useReducer(reducer, []);
|
||||||
const { user } = React.useContext(AuthContext);
|
const { user } = React.useContext(AuthContext);
|
||||||
|
React.useEffect(() => {
|
||||||
|
dispatch({ type: "RESET" });
|
||||||
|
setPageNumber(1);
|
||||||
|
}, [status, searchParam, dispatch, showAll, selectedQueueIds]);
|
||||||
const { tickets, loading } = useTickets({
|
const { tickets, loading } = useTickets({
|
||||||
pageNumber,
|
pageNumber,
|
||||||
searchParam,
|
searchParam,
|
||||||
|
@ -105,10 +111,13 @@ const TicketsList = ({ status, searchParam, showAll, selectedQueueIds, updateCou
|
||||||
showAll,
|
showAll,
|
||||||
queueIds: JSON.stringify(selectedQueueIds),
|
queueIds: JSON.stringify(selectedQueueIds),
|
||||||
});
|
});
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
dispatch({ type: "RESET" });
|
if (typeof updateCount === "function") {
|
||||||
setPageNumber(1);
|
updateCount(ticketsList.length);
|
||||||
}, [status, searchParam, dispatch, showAll, selectedQueueIds]);
|
}
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [ticketsList]);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (!status && !searchParam) return;
|
if (!status && !searchParam) return;
|
||||||
|
@ -116,7 +125,7 @@ const TicketsList = ({ status, searchParam, showAll, selectedQueueIds, updateCou
|
||||||
type: "LOAD_TICKETS",
|
type: "LOAD_TICKETS",
|
||||||
payload: tickets,
|
payload: tickets,
|
||||||
});
|
});
|
||||||
}, [tickets, searchParam]);
|
}, [tickets, status, searchParam]);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
const socket = openSocket(process.env.REACT_APP_BACKEND_URL);
|
const socket = openSocket(process.env.REACT_APP_BACKEND_URL);
|
||||||
|
@ -162,6 +171,8 @@ const TicketsList = ({ status, searchParam, showAll, selectedQueueIds, updateCou
|
||||||
|
|
||||||
socket.on("appMessage", (data) => {
|
socket.on("appMessage", (data) => {
|
||||||
if (data.action === "create" && shouldUpdateTicket(data.ticket)) {
|
if (data.action === "create" && shouldUpdateTicket(data.ticket)) {
|
||||||
|
// console.log('((((((((((((((((((( DATA.MESSAGE: ', data.message)
|
||||||
|
|
||||||
dispatch({
|
dispatch({
|
||||||
type: "UPDATE_TICKET_UNREAD_MESSAGES",
|
type: "UPDATE_TICKET_UNREAD_MESSAGES",
|
||||||
// payload: data.ticket,
|
// payload: data.ticket,
|
||||||
|
@ -185,13 +196,16 @@ const TicketsList = ({ status, searchParam, showAll, selectedQueueIds, updateCou
|
||||||
}, [status, showAll, user, selectedQueueIds]);
|
}, [status, showAll, user, selectedQueueIds]);
|
||||||
|
|
||||||
if (loading) return <TicketsListSkeleton />;
|
if (loading) return <TicketsListSkeleton />;
|
||||||
return (
|
|
||||||
<TicketListStyled>
|
if (status === valueTab)
|
||||||
{ticketsList.map((ticket) => (
|
return (
|
||||||
<TicketListItem tickets={ticket} status={status} key={ticket.id} />
|
<TicketListStyled>
|
||||||
))}
|
{ticketsList.map((ticket) => (
|
||||||
</TicketListStyled>
|
<TicketListItem tickets={ticket} key={ticket.id} />
|
||||||
);
|
))}
|
||||||
|
</TicketListStyled>
|
||||||
|
);
|
||||||
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default TicketsList;
|
export default TicketsList;
|
||||||
|
|
|
@ -2,24 +2,25 @@ import React from "react";
|
||||||
|
|
||||||
import TicketsManagerStyled from "./TicketsManager.style";
|
import TicketsManagerStyled from "./TicketsManager.style";
|
||||||
import TicketsTabs from "./TicketsTabs/TicketsTabs";
|
import TicketsTabs from "./TicketsTabs/TicketsTabs";
|
||||||
|
|
||||||
|
import TicketSearch from "../TicketSearch/TicketSearch";
|
||||||
import TicketsList from "./TicketsList/TicketsList";
|
import TicketsList from "./TicketsList/TicketsList";
|
||||||
import NewTicketModal from "../../NewTicketModal";
|
import NewTicketModal from "../../NewTicketModal";
|
||||||
import useTickets from "../../../hooks/useTickets";
|
|
||||||
import { AuthContext } from "../../../context/Auth/AuthContext";
|
import { AuthContext } from "../../../context/Auth/AuthContext";
|
||||||
import TicketSearch from "../TicketSearch/TicketSearch";
|
|
||||||
|
|
||||||
const TicketsManager = () => {
|
const TicketsManager = () => {
|
||||||
const [valueTab, setValueTab] = React.useState("open");
|
const [valueTab, setValueTab] = React.useState("open");
|
||||||
const [searchParam, setSearchParam] = React.useState("");
|
const [searchParam, setSearchParam] = React.useState("");
|
||||||
const [spinning, setSpinning] = React.useState(false);
|
const [spinning, setSpinning] = React.useState(false);
|
||||||
const [newTicketModalOpen, setNewTicketModalOpen] = React.useState(false);
|
const [newTicketModalOpen, setNewTicketModalOpen] = React.useState(false);
|
||||||
|
const [openCount, setOpenCount] = React.useState(0);
|
||||||
|
const [pendingCount, setPendingCount] = React.useState(0);
|
||||||
|
const [closedCount, setClosedCount] = React.useState(0);
|
||||||
const [showAllTickets, setShowAllTickets] = React.useState(false);
|
const [showAllTickets, setShowAllTickets] = React.useState(false);
|
||||||
const { user } = React.useContext(AuthContext);
|
const { user } = React.useContext(AuthContext);
|
||||||
const userQueueIds = user.queues.map((q) => q.id);
|
const userQueueIds = user.queues.map((q) => q.id);
|
||||||
const [selectedQueueIds, setSelectedQueueIds] = React.useState(userQueueIds || []);
|
const [selectedQueueIds, setSelectedQueueIds] = React.useState(userQueueIds || []);
|
||||||
const { tickets } = useTickets({
|
|
||||||
searchParam
|
|
||||||
});
|
|
||||||
|
|
||||||
let searchTimeout;
|
let searchTimeout;
|
||||||
const handleSearch = (e) => {
|
const handleSearch = (e) => {
|
||||||
|
@ -47,23 +48,47 @@ const TicketsManager = () => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TicketsManagerStyled>
|
<TicketsManagerStyled>
|
||||||
<TicketsTabs tickets={tickets} setValueTab={setValueTab} valueTab={valueTab} />
|
<TicketsTabs
|
||||||
|
setValueTab={setValueTab}
|
||||||
|
valueTab={valueTab}
|
||||||
|
count={{ openCount, pendingCount, closedCount }}
|
||||||
|
/>
|
||||||
|
|
||||||
<TicketSearch
|
<TicketSearch
|
||||||
spinning={spinning}
|
spinning={spinning}
|
||||||
handleSearch={handleSearch}
|
handleSearch={handleSearch}
|
||||||
setNewTicketModalOpen={setNewTicketModalOpen}
|
setNewTicketModalOpen={setNewTicketModalOpen}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<TicketsList
|
<TicketsList
|
||||||
|
status="open"
|
||||||
|
updateCount={(v) => setOpenCount(v)}
|
||||||
showAll={showAllTickets}
|
showAll={showAllTickets}
|
||||||
status={valueTab}
|
|
||||||
selectedQueueIds={selectedQueueIds}
|
selectedQueueIds={selectedQueueIds}
|
||||||
searchParam={searchParam}
|
searchParam={searchParam}
|
||||||
|
valueTab={valueTab}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<TicketsList
|
||||||
|
status="pending"
|
||||||
|
updateCount={(v) => setPendingCount(v)}
|
||||||
|
selectedQueueIds={selectedQueueIds}
|
||||||
|
searchParam={searchParam}
|
||||||
|
valueTab={valueTab}
|
||||||
|
/>
|
||||||
|
<TicketsList
|
||||||
|
status="closed"
|
||||||
|
updateCount={(v) => setClosedCount(v)}
|
||||||
|
selectedQueueIds={selectedQueueIds}
|
||||||
|
searchParam={searchParam}
|
||||||
|
valueTab={valueTab}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<NewTicketModal
|
<NewTicketModal
|
||||||
modalOpen={newTicketModalOpen}
|
modalOpen={newTicketModalOpen}
|
||||||
onClose={(e) => setNewTicketModalOpen(false)}
|
onClose={(e) => setNewTicketModalOpen(false)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</TicketsManagerStyled>
|
</TicketsManagerStyled>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { TicketsTabStyled } from "./TicketsTab.style";
|
import { TicketsTabStyled } from "./TicketsTab.style";
|
||||||
|
import { color } from "../../../../../style/varibles";
|
||||||
|
|
||||||
const TicketsTab = ({ text, id, setValueTab, valueTab }) => {
|
import BadgeComponent from "../../../../Base/Badge/BadgeComponent";
|
||||||
|
|
||||||
|
const TicketsTab = ({ text, id, setValueTab, valueTab, count }) => {
|
||||||
const [active, setActive] = React.useState(false);
|
const [active, setActive] = React.useState(false);
|
||||||
|
|
||||||
const handleClick = ({ target }) => {
|
const handleClick = ({ target }) => {
|
||||||
|
@ -11,6 +14,7 @@ const TicketsTab = ({ text, id, setValueTab, valueTab }) => {
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
valueTab === id ? setActive(true) : setActive(false);
|
valueTab === id ? setActive(true) : setActive(false);
|
||||||
}, [valueTab, id]);
|
}, [valueTab, id]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TicketsTabStyled
|
<TicketsTabStyled
|
||||||
id={id}
|
id={id}
|
||||||
|
@ -19,6 +23,18 @@ const TicketsTab = ({ text, id, setValueTab, valueTab }) => {
|
||||||
className={active ? "active" : ""}
|
className={active ? "active" : ""}
|
||||||
>
|
>
|
||||||
{text}
|
{text}
|
||||||
|
{id !== "open" ? (
|
||||||
|
<BadgeComponent
|
||||||
|
counter={count}
|
||||||
|
position="absolute"
|
||||||
|
right="4px"
|
||||||
|
top="6px"
|
||||||
|
fontSize="12px"
|
||||||
|
bgcolor={id === "pending" ? color.status.warning : color.status.no}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
""
|
||||||
|
)}
|
||||||
</TicketsTabStyled>
|
</TicketsTabStyled>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,16 +1,32 @@
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
import TicketsTab from "../TicketsTabs/TicketsTab/TicketsTab";
|
||||||
import { TicketTabsStyled } from "./TicketsTabs.style";
|
import { TicketTabsStyled } from "./TicketsTabs.style";
|
||||||
|
|
||||||
import TicketsTab from "./TicketsTab/TicketsTab";
|
const TicketsTabs = ({ setValueTab, valueTab, count }) => {
|
||||||
|
|
||||||
const TicketsTabs = ({ tickets, setValueTab, valueTab }) => {
|
|
||||||
|
|
||||||
if (!setValueTab) return null;
|
|
||||||
return (
|
return (
|
||||||
<TicketTabsStyled>
|
<TicketTabsStyled>
|
||||||
<TicketsTab text="Aberto" id="open" setValueTab={setValueTab} valueTab={valueTab} />
|
<TicketsTab
|
||||||
<TicketsTab text="Aguardando" id="pending" setValueTab={setValueTab} valueTab={valueTab} />
|
text="Aberto"
|
||||||
<TicketsTab text="Fechado" id="closed" setValueTab={setValueTab} valueTab={valueTab} />
|
id="open"
|
||||||
|
setValueTab={setValueTab}
|
||||||
|
valueTab={valueTab}
|
||||||
|
count={count.openCount}
|
||||||
|
/>
|
||||||
|
<TicketsTab
|
||||||
|
text="Aguardando"
|
||||||
|
id="pending"
|
||||||
|
setValueTab={setValueTab}
|
||||||
|
valueTab={valueTab}
|
||||||
|
count={count.pendingCount}
|
||||||
|
/>
|
||||||
|
<TicketsTab
|
||||||
|
text="Fechado"
|
||||||
|
id="closed"
|
||||||
|
setValueTab={setValueTab}
|
||||||
|
valueTab={valueTab}
|
||||||
|
count={count.closedCount}
|
||||||
|
/>
|
||||||
</TicketTabsStyled>
|
</TicketTabsStyled>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -47,7 +47,7 @@ export const color = {
|
||||||
status: {
|
status: {
|
||||||
no: "#FF0000",
|
no: "#FF0000",
|
||||||
yes: "#00BE1E",
|
yes: "#00BE1E",
|
||||||
warning: "#FFC700",
|
warning: "#ffc800c7",
|
||||||
},
|
},
|
||||||
gradient: {
|
gradient: {
|
||||||
bgOpacity: "#212f3cd7",
|
bgOpacity: "#212f3cd7",
|
||||||
|
|
Loading…
Reference in New Issue