Merge branch 'master' of https://gitlab.chiefsoft.net/WrenchBoard/Users-Wrench
This commit is contained in:
+11
-8
@@ -2,19 +2,22 @@ import { Navigate, useLocation } from "react-router-dom";
|
|||||||
import Routers from "./Routers";
|
import Routers from "./Routers";
|
||||||
import Toaster from "./components/Helpers/Toaster";
|
import Toaster from "./components/Helpers/Toaster";
|
||||||
import Default from "./components/Partials/Default";
|
import Default from "./components/Partials/Default";
|
||||||
|
import SocketIOContextProvider from "./components/Contexts/SocketIOContext";
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const { pathname } = useLocation();
|
const { pathname } = useLocation();
|
||||||
return (
|
return (
|
||||||
<Default>
|
<Default>
|
||||||
<>
|
<SocketIOContextProvider>
|
||||||
{pathname.startsWith("/@") ? (
|
<>
|
||||||
<Navigate to="/app" replace={true} />
|
{pathname.startsWith("/@") ? (
|
||||||
) : (
|
<Navigate to="/app" replace={true} />
|
||||||
<Routers />
|
) : (
|
||||||
)}
|
<Routers />
|
||||||
<Toaster />
|
)}
|
||||||
</>
|
<Toaster />
|
||||||
|
</>
|
||||||
|
</SocketIOContextProvider>
|
||||||
</Default>
|
</Default>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,25 @@
|
|||||||
import React from 'react'
|
import React from "react";
|
||||||
import { Link } from 'react-router-dom'
|
import { Link } from "react-router-dom";
|
||||||
|
|
||||||
export default function CustomBreadcrumb({title, breadcrumb}) {
|
export default function CustomBreadcrumb({ title, breadcrumb }) {
|
||||||
return (
|
return (
|
||||||
<div className="">
|
<div className="">
|
||||||
<h3 className="text-26 font-bold text-dark-gray dark:text-white">{title}</h3>
|
<h3 className="text-26 font-bold text-dark-gray dark:text-white">
|
||||||
<nav aria-label="breadcrumb" className='text-base text-dark-gray dark:text-white flex items-center'>
|
{title}
|
||||||
{breadcrumb.map((value, index) => (
|
</h3>
|
||||||
<p key={index}>
|
<nav
|
||||||
<Link className={`${value.active ? 'opacity-60' : ''}`} to={value.link}>{value.title}</Link>
|
aria-label="breadcrumb"
|
||||||
{index != breadcrumb.length - 1 ?
|
className="text-base text-dark-gray dark:text-white flex items-center"
|
||||||
<span className='px-1'>/</span>
|
>
|
||||||
:
|
{breadcrumb.map((value, index) => (
|
||||||
null
|
<React.Fragment key={index}>
|
||||||
}
|
<Link className={value.active ? "opacity-60" : ""} to={value.link}>
|
||||||
</p>
|
{value.title}
|
||||||
))}
|
</Link>
|
||||||
</nav>
|
{index !== breadcrumb.length - 1 && <span className="px-1">\</span>}
|
||||||
|
</React.Fragment>
|
||||||
|
))}
|
||||||
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
import React, { createContext, useContext, useEffect, useState } from "react";
|
||||||
|
import { tableReload } from "../../store/TableReloads";
|
||||||
|
import { useDispatch } from "react-redux";
|
||||||
|
|
||||||
|
import io from "socket.io-client";
|
||||||
|
|
||||||
|
let SocketIOContext = createContext({})
|
||||||
|
|
||||||
|
export default function SocketIOContextProvider({children}) {
|
||||||
|
const dispatch = useDispatch()
|
||||||
|
|
||||||
|
const socket = io.connect(process.env.REACT_APP_PRIMARY_SOCKET);
|
||||||
|
|
||||||
|
// //Room State
|
||||||
|
// const [room, setRoom] = useState("");
|
||||||
|
|
||||||
|
// // Messages States
|
||||||
|
// const [message, setMessage] = useState("");
|
||||||
|
const [socketMsgReceived, setSocketMsgReceived] = useState("");
|
||||||
|
|
||||||
|
const joinRoom = (room) => {
|
||||||
|
if (room !== "") {
|
||||||
|
socket.emit("join_room", room);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const sendMessage = (message, room) => {
|
||||||
|
if(message && room){
|
||||||
|
socket.emit("send_message", { message, room });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
socket.on("receive_message", (data) => {
|
||||||
|
// setSocketMsgReceived(data.message);
|
||||||
|
dispatch(tableReload({type:'CHATMESSAGELIST'}))
|
||||||
|
});
|
||||||
|
}, [socket]);
|
||||||
|
|
||||||
|
let values = {
|
||||||
|
socket,
|
||||||
|
sendMessage,
|
||||||
|
joinRoom,
|
||||||
|
setSocketMsgReceived,
|
||||||
|
socketMsgReceived,
|
||||||
|
// room,
|
||||||
|
// setRoom,
|
||||||
|
// message,
|
||||||
|
// setMessage,
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<SocketIOContext.Provider value={values}>
|
||||||
|
{children}
|
||||||
|
</SocketIOContext.Provider>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const SocketValues = () => {
|
||||||
|
return useContext(SocketIOContext)
|
||||||
|
}
|
||||||
@@ -1,12 +1,11 @@
|
|||||||
import React, { Suspense, useMemo, useState } from "react";
|
import React, { Suspense } from "react";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import usersService from "../../services/UsersService";
|
import CustomBreadcrumb from "../Breadcrumb/CustomBreadcrumb";
|
||||||
import Layout from "../Partials/Layout";
|
import Layout from "../Partials/Layout";
|
||||||
import LoadingSpinner from "../Spinners/LoadingSpinner";
|
import LoadingSpinner from "../Spinners/LoadingSpinner";
|
||||||
import FamilyTableNew from "./FamilyTableNew";
|
import FamilyTableNew from "./FamilyTableNew";
|
||||||
|
|
||||||
export default function FamilyActivities() {
|
export default function FamilyActivities() {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Layout>
|
<Layout>
|
||||||
{/*<CommonHead />*/}
|
{/*<CommonHead />*/}
|
||||||
@@ -15,9 +14,21 @@ export default function FamilyActivities() {
|
|||||||
{/* heading */}
|
{/* heading */}
|
||||||
<div className="sm:flex justify-between items-center mb-6">
|
<div className="sm:flex justify-between items-center mb-6">
|
||||||
<div className="mb-5 sm:mb-0">
|
<div className="mb-5 sm:mb-0">
|
||||||
<h1 className="text-26 font-bold inline-flex gap-3 text-dark-gray dark:text-white items-center">
|
<CustomBreadcrumb
|
||||||
<span className={``}>Tasks & Chores</span>
|
title={"Tasks & Chores"}
|
||||||
</h1>
|
breadcrumb={[
|
||||||
|
{ link: "/", title: "Home" },
|
||||||
|
{
|
||||||
|
link: "/acc-family",
|
||||||
|
title: "Family Account",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
link: "/acc-family/activities",
|
||||||
|
title: "Tasks & Chores",
|
||||||
|
active: true,
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<Link
|
<Link
|
||||||
className="item-content relative text-[18px] transition-all duration-300 ease-in-out bg-[#76a5df] text-white font-medium dark:text-white h-12 px-2 flex items-center gap-2 rounded-md shadow-sm justify-center cursor-pointer dark:bg-[linear-gradient(134.38deg,#f539f8_0%,#c342f9_43.55%,#5356fb_104.51%)]"
|
className="item-content relative text-[18px] transition-all duration-300 ease-in-out bg-[#76a5df] text-white font-medium dark:text-white h-12 px-2 flex items-center gap-2 rounded-md shadow-sm justify-center cursor-pointer dark:bg-[linear-gradient(134.38deg,#f539f8_0%,#c342f9_43.55%,#5356fb_104.51%)]"
|
||||||
|
|||||||
@@ -188,31 +188,35 @@ const AssignTaskPopout = React.memo(
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
console.log(details);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ModalCom action={action} situation={situation}>
|
<ModalCom action={action} situation={situation}>
|
||||||
<div className="w-11/12 lg:w-[700px] bg-white dark:bg-dark-white lg:rounded-2xl overflow-y-auto">
|
<div className="w-11/12 lg:w-[700px] bg-white dark:bg-dark-white lg:rounded-2xl overflow-y-auto">
|
||||||
<div className="w-full flex items-center justify-between lg:px-10 lg:py-8 px-[30px] py-[23px] border-b dark:border-[#5356fb29] border-light-purple">
|
<div className="w-full flex items-center justify-between lg:px-10 lg:py-8 px-[30px] py-[23px] border-b dark:border-[#5356fb29] border-light-purple">
|
||||||
<h1 className="text-26 font-bold text-dark-gray dark:text-white tracking-wide flex items-center">
|
<h1 className="text-26 font-bold text-dark-gray dark:text-white tracking-wide flex items-center">
|
||||||
Assign task to{" "}
|
<>
|
||||||
{pathname === "/acc-family/activities" ? (
|
Assign task to{" "}
|
||||||
<div className="w-[270px] h-[40px] ml-2">
|
{pathname === "/acc-family/activities" ? (
|
||||||
<select
|
<div className="w-[270px] h-[40px] ml-2">
|
||||||
name=""
|
<select
|
||||||
id=""
|
name=""
|
||||||
className="text-black/70 bg-transparent px-2 transition-all cursor-pointer focus:outline-none border border-gray-200 rounded-lg w-full h-full py-1"
|
id=""
|
||||||
onChange={handleFamChange}
|
className="text-black/70 bg-transparent px-2 transition-all cursor-pointer focus:outline-none border border-gray-200 rounded-lg w-full h-full py-1"
|
||||||
value={selectedFamilyUid}
|
onChange={handleFamChange}
|
||||||
>
|
value={selectedFamilyUid}
|
||||||
<option value="" disabled selected>
|
>
|
||||||
Select a member
|
<option value="" disabled selected>
|
||||||
</option>
|
Select a member
|
||||||
{familyList}
|
</option>
|
||||||
</select>
|
{familyList}
|
||||||
</div>
|
</select>
|
||||||
) : (
|
</div>
|
||||||
<>{familyDetailsData?.firstname || details?.firstName}</>
|
) : (
|
||||||
)}
|
<>{familyDetailsData?.firstname || details?.firstName}</>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
</h1>
|
</h1>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { Link, useLocation } from "react-router-dom";
|
import { Link, useLocation } from "react-router-dom";
|
||||||
|
import CustomBreadcrumb from "../../Breadcrumb/CustomBreadcrumb";
|
||||||
import Icons from "../../Helpers/Icons";
|
import Icons from "../../Helpers/Icons";
|
||||||
import Layout from "../../Partials/Layout";
|
import Layout from "../../Partials/Layout";
|
||||||
import { AddFamily, FamilyBanner, Relatives } from "./Tabs";
|
import { AddFamily, FamilyBanner, Relatives } from "./Tabs";
|
||||||
|
|
||||||
const FamilySettings = () => {
|
const FamilySettings = () => {
|
||||||
let {state} = useLocation()
|
let { state } = useLocation();
|
||||||
const tabs = [
|
const tabs = [
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
@@ -58,15 +59,42 @@ const FamilySettings = () => {
|
|||||||
{/* heading */}
|
{/* heading */}
|
||||||
<div className="sm:flex justify-between items-center mb-6">
|
<div className="sm:flex justify-between items-center mb-6">
|
||||||
<div className="mb-5 sm:mb-0">
|
<div className="mb-5 sm:mb-0">
|
||||||
<h1 className="text-26 font-bold inline-flex gap-3 text-dark-gray dark:text-white items-center">
|
<CustomBreadcrumb
|
||||||
<span className={``}>Family Settings</span>
|
title={"Family Settings"}
|
||||||
</h1>
|
breadcrumb={[
|
||||||
|
{ link: "/", title: "Home" },
|
||||||
|
{
|
||||||
|
link: "/acc-family",
|
||||||
|
title: "Family Account",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
link: "/familysettings",
|
||||||
|
title: "Family Settings",
|
||||||
|
active: true,
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<Link to="/acc-family" className="flex gap-2 items-center text-dark-gray dark:text-white">
|
<Link
|
||||||
<svg className="w-5 h-5 rtl:rotate-180" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" strokeWidth="1.5" stroke="currentColor">
|
className="item-content relative text-[18px] transition-all duration-300 ease-in-out bg-[#76a5df] text-white font-medium dark:text-white h-12 px-2 flex items-center gap-2 rounded-md shadow-sm justify-center cursor-pointer dark:bg-[linear-gradient(134.38deg,#f539f8_0%,#c342f9_43.55%,#5356fb_104.51%)]"
|
||||||
<path strokeLinecap="round" strokeLinejoin="round" d="M6.75 15.75L3 12m0 0l3.75-3.75M3 12h18" />
|
to="/acc-family"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
fill="none"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
strokeWidth={1.5}
|
||||||
|
stroke="currentColor"
|
||||||
|
className="w-4 h-4"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
strokeLinecap="round"
|
||||||
|
strokeLinejoin="round"
|
||||||
|
d="M10.5 19.5 3 12m0 0 7.5-7.5M3 12h18"
|
||||||
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
Family
|
|
||||||
|
<span>Family</span>
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import React, { Suspense, lazy, useEffect, useMemo, useState } from "react";
|
import React, { Suspense, lazy, useEffect, useMemo, useState } from "react";
|
||||||
|
import { useLocation } from "react-router-dom";
|
||||||
import { apiConst } from "../../lib/apiConst";
|
import { apiConst } from "../../lib/apiConst";
|
||||||
import usersService from "../../services/UsersService";
|
import usersService from "../../services/UsersService";
|
||||||
import LoadingSpinner from "../Spinners/LoadingSpinner";
|
import LoadingSpinner from "../Spinners/LoadingSpinner";
|
||||||
import AssignTaskPopout from "./FamilyPopout/AssignTaskPopout";
|
import AssignTaskPopout from "./FamilyPopout/AssignTaskPopout";
|
||||||
import { useLocation } from "react-router-dom";
|
|
||||||
|
|
||||||
// Lazy Imports for components
|
// Lazy Imports for components
|
||||||
const FamilyWaitlist = lazy(() => import("./Tabs/FamilyNewWaitlist"));
|
const FamilyWaitlist = lazy(() => import("./Tabs/FamilyNewWaitlist"));
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ const FamilyNewWaitlist = ({
|
|||||||
setContinueTaskPopup({ show: false, data: {} });
|
setContinueTaskPopup({ show: false, data: {} });
|
||||||
};
|
};
|
||||||
|
|
||||||
// console.log("Check this >>",currentTask)
|
console.log("Check this >>",continueTaskPopup)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ export default function FamilyAcc() {
|
|||||||
breadcrumb={
|
breadcrumb={
|
||||||
[
|
[
|
||||||
{ link: "/", title: "Home" },
|
{ link: "/", title: "Home" },
|
||||||
{ link: "/acc-family", title: "Family-acc", active: true},
|
{ link: "/acc-family", title: "Family Account", active: true},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import { Form, Formik } from "formik";
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useLocation } from "react-router-dom";
|
import { useLocation } from "react-router-dom";
|
||||||
import usersService from "../../services/UsersService";
|
import usersService from "../../services/UsersService";
|
||||||
import Icons from "../Helpers/Icons";
|
|
||||||
import InputCom from "../Helpers/Inputs/InputCom";
|
import InputCom from "../Helpers/Inputs/InputCom";
|
||||||
import ModalCom from "../Helpers/ModalCom";
|
import ModalCom from "../Helpers/ModalCom";
|
||||||
|
|
||||||
@@ -52,22 +51,46 @@ const SuggestTask = ({ details, onClose, situation, continuePopupData }) => {
|
|||||||
|
|
||||||
const handleParentSuggestion = (values) => {
|
const handleParentSuggestion = (values) => {
|
||||||
if (suggestedNextStep === "Send Task") {
|
if (suggestedNextStep === "Send Task") {
|
||||||
let firstName = state?.firstname;
|
let firstname = state?.firstname || details?.firstname;
|
||||||
let family_uid = state?.family_uid;
|
let family_uid = state?.family_uid || details?.family_uid;
|
||||||
continuePopupData({ ...details, firstName, family_uid });
|
continuePopupData({
|
||||||
|
...details,
|
||||||
|
firstname,
|
||||||
|
family_uid,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
onClose();
|
onClose();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const isActivitiesPage = pathname === "/acc-family/activities";
|
||||||
|
const isManageFamilyPage = pathname === "/manage-family";
|
||||||
|
|
||||||
|
const getButtonText = () => {
|
||||||
|
if (isActivitiesPage) {
|
||||||
|
return suggestedNextStep === "Send Task" ? "Continue" : "Complete";
|
||||||
|
} else {
|
||||||
|
if (!isManageFamilyPage) {
|
||||||
|
if (submitTask.loading) return "Submitting Task";
|
||||||
|
if (submitTask.state === "success") return "Task Submitted";
|
||||||
|
if (submitTask.state === "bad") return "An Error Occurred";
|
||||||
|
return "Send to Parents";
|
||||||
|
} else {
|
||||||
|
return suggestedNextStep === "Send Task" ? "Continue" : "Complete";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
console.log(details);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ModalCom action={onClose} situation={situation}>
|
<ModalCom action={onClose} situation={situation}>
|
||||||
<div className="logout-modal-wrapper lw-[90%] md:w-[768px] h-full lg:h-auto bg-white dark:bg-dark-white lg:rounded-2xl overflow-y-auto">
|
<div className="logout-modal-wrapper lw-[90%] md:w-[768px] h-full lg:h-auto bg-white dark:bg-dark-white lg:rounded-2xl overflow-y-auto">
|
||||||
<div className="logout-modal-header w-full flex items-center justify-between lg:p-6 px-[30px] py-[23px] border-b dark:border-[#5356fb29] border-light-purple">
|
<div className="logout-modal-header w-full flex items-center justify-between lg:p-6 px-[30px] py-[23px] border-b dark:border-[#5356fb29] border-light-purple">
|
||||||
<h1 className="text-base md:text-lg font-bold text-dark-gray dark:text-white tracking-wide">
|
<h1 className="text-base md:text-lg font-bold text-dark-gray dark:text-white tracking-wide">
|
||||||
{pathname === "/manage-family"
|
{isManageFamilyPage
|
||||||
? `${state?.firstname}'s Suggested Task`
|
? `${state?.firstname}'s Suggested Task`
|
||||||
: pathname === "/acc-family/activities"
|
: isActivitiesPage
|
||||||
? "Suggested Task"
|
? `${details?.firstname}'s Suggested Task`
|
||||||
: "Suggest to Parent"}
|
: "Suggest to Parent"}
|
||||||
</h1>
|
</h1>
|
||||||
<button
|
<button
|
||||||
@@ -99,10 +122,11 @@ const SuggestTask = ({ details, onClose, situation, continuePopupData }) => {
|
|||||||
<Formik
|
<Formik
|
||||||
initialValues={initialValues}
|
initialValues={initialValues}
|
||||||
onSubmit={
|
onSubmit={
|
||||||
pathname !== "/manage-family" ||
|
isActivitiesPage
|
||||||
pathname !== "/acc-family/activities"
|
? handleParentSuggestion
|
||||||
? handleSuggestedTask
|
: isManageFamilyPage
|
||||||
: handleParentSuggestion
|
? handleParentSuggestion
|
||||||
|
: handleSuggestedTask
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{(props) => {
|
{(props) => {
|
||||||
@@ -252,18 +276,14 @@ const SuggestTask = ({ details, onClose, situation, continuePopupData }) => {
|
|||||||
disabled={props.isSubmitting}
|
disabled={props.isSubmitting}
|
||||||
className="text-white primary-gradient text-18 tracking-wide px-4 py-3 rounded-full transition duration-150 ease-in-out flex items-center"
|
className="text-white primary-gradient text-18 tracking-wide px-4 py-3 rounded-full transition duration-150 ease-in-out flex items-center"
|
||||||
>
|
>
|
||||||
{pathname === "/acc-family/activities" ? (
|
{/* {pathname === "/acc-family/activities" ? (
|
||||||
<>
|
<>
|
||||||
{submitTask.loading ? (
|
{suggestedNextStep === "Send Task" ? (
|
||||||
"Sending..."
|
|
||||||
) : submitTask.state === "success" ? (
|
|
||||||
"Completed"
|
|
||||||
) : submitTask.state === "bad" ? (
|
|
||||||
"An Error Occurred"
|
|
||||||
) : (
|
|
||||||
<>
|
<>
|
||||||
Continue <Icons name="chevron-right" />
|
Continue <Icons name="chevron-right" />
|
||||||
</>
|
</>
|
||||||
|
) : (
|
||||||
|
"Complete"
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
@@ -290,7 +310,8 @@ const SuggestTask = ({ details, onClose, situation, continuePopupData }) => {
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
)}
|
)} */}
|
||||||
|
{getButtonText()}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -11,8 +11,11 @@ import IndexJobActions from "./JobActions/IndexJobActions";
|
|||||||
|
|
||||||
import usersService from "../../services/UsersService";
|
import usersService from "../../services/UsersService";
|
||||||
import { PriceFormatter } from "../Helpers/PriceFormatter";
|
import { PriceFormatter } from "../Helpers/PriceFormatter";
|
||||||
|
import { SocketValues } from "../Contexts/SocketIOContext";
|
||||||
|
|
||||||
function ActiveJobs(props) {
|
function ActiveJobs(props) {
|
||||||
|
let {sendMessage, joinRoom} = SocketValues() // destructures 'SEND MESSAGE' and 'JOIN ROOM' FUNCTIONS FROM SOCKET
|
||||||
|
|
||||||
const ApiCall = new usersService();
|
const ApiCall = new usersService();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
@@ -139,6 +142,9 @@ function ActiveJobs(props) {
|
|||||||
status: true,
|
status: true,
|
||||||
message: "Message Sent Successfully",
|
message: "Message Sent Successfully",
|
||||||
});
|
});
|
||||||
|
// function to trigger socket to emit 'send_message'
|
||||||
|
sendMessage(messageToSend, `${props.details.contract}-${props.details.contract_uid}`)
|
||||||
|
|
||||||
props.reloadActiveJobList((prev) => !prev); // MAKES ACTIVE JOB MESSAGE LIST TO RELOAD
|
props.reloadActiveJobList((prev) => !prev); // MAKES ACTIVE JOB MESSAGE LIST TO RELOAD
|
||||||
setMessageToSend(""); // SENDS MESSAGE TO SEND BACK TO EMPTY STRINGS
|
setMessageToSend(""); // SENDS MESSAGE TO SEND BACK TO EMPTY STRINGS
|
||||||
})
|
})
|
||||||
@@ -255,6 +261,12 @@ function ActiveJobs(props) {
|
|||||||
props.details?.currency
|
props.details?.currency
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
useEffect(()=>{
|
||||||
|
// calls function to add user to a room
|
||||||
|
joinRoom(`${props.details.contract}-${props.details.contract_uid}`)
|
||||||
|
},[props.details.contract, props.details.contract_uid])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Layout>
|
<Layout>
|
||||||
<div className="py-[20px] bg-white dark:bg-black dark:text-white px-4 rounded-2xl shadow-md md:flex justify-between items-start gap-16">
|
<div className="py-[20px] bg-white dark:bg-black dark:text-white px-4 rounded-2xl shadow-md md:flex justify-between items-start gap-16">
|
||||||
|
|||||||
@@ -229,7 +229,7 @@ const AuthRoute = ({ redirectPath = "/login", children }) => {
|
|||||||
apiCall
|
apiCall
|
||||||
.getHeroJBanners()
|
.getHeroJBanners()
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res.data.internal_return < 0) {
|
if (res.data?.internal_return < 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dispatch(commonHeadBanner(res.data));
|
dispatch(commonHeadBanner(res.data));
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ const initialState = {
|
|||||||
walletTable: false,
|
walletTable: false,
|
||||||
uploadsTable: false,
|
uploadsTable: false,
|
||||||
familyBannersListTable: false,
|
familyBannersListTable: false,
|
||||||
|
chatMessageList: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const tableReloadSlice = createSlice({
|
export const tableReloadSlice = createSlice({
|
||||||
@@ -41,6 +42,9 @@ export const tableReloadSlice = createSlice({
|
|||||||
case "FAMILYBANNERSLIST":
|
case "FAMILYBANNERSLIST":
|
||||||
state.familyBannersListTable = !state.familyBannersListTable;
|
state.familyBannersListTable = !state.familyBannersListTable;
|
||||||
return;
|
return;
|
||||||
|
case "CHATMESSAGELIST":
|
||||||
|
state.chatMessageList = !state.chatMessageList;
|
||||||
|
return;
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,17 @@ import React, { useEffect, useState } from "react";
|
|||||||
import { useLocation, useNavigate } from "react-router-dom";
|
import { useLocation, useNavigate } from "react-router-dom";
|
||||||
import ActiveJobs from "../components/MyActiveJobs/ActiveJobs";
|
import ActiveJobs from "../components/MyActiveJobs/ActiveJobs";
|
||||||
import usersService from "../services/UsersService";
|
import usersService from "../services/UsersService";
|
||||||
|
import { useSelector } from "react-redux";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This code defines a React functional component called `ManageActiveJobs`.
|
* This code defines a React functional component called `ManageActiveJobs`.
|
||||||
* It fetches a list of active job messages and renders the `ActiveJobs` component with the necessary props.
|
* It fetches a list of active job messages and renders the `ActiveJobs` component with the necessary props.
|
||||||
*/
|
*/
|
||||||
function ManageActiveJobs() {
|
function ManageActiveJobs() {
|
||||||
|
const { chatMessageList } = useSelector(
|
||||||
|
(state) => state.tableReload
|
||||||
|
);
|
||||||
|
|
||||||
const ApiCall = new usersService();
|
const ApiCall = new usersService();
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@@ -54,7 +59,7 @@ function ManageActiveJobs() {
|
|||||||
}
|
}
|
||||||
setDetails(state);
|
setDetails(state);
|
||||||
getActiveJobMesList();
|
getActiveJobMesList();
|
||||||
}, [activeJobMesListReload]);
|
}, [activeJobMesListReload, chatMessageList]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ActiveJobs
|
<ActiveJobs
|
||||||
|
|||||||
Reference in New Issue
Block a user