Compare commits

...

4 Commits

11 changed files with 80 additions and 27 deletions
@@ -67,7 +67,7 @@ export default function MyActiveJobTable({ MyJobList, className }) {
<span className="text-sm text-thin-light-gray"> <span className="text-sm text-thin-light-gray">
Price:{" "} Price:{" "}
<span className="text-purple"> <span className="text-purple">
{value.price * 0.01} {(value.price * 0.01).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")+'.00'}
</span> </span>
</span> </span>
<span className="text-sm text-thin-light-gray"> <span className="text-sm text-thin-light-gray">
+14 -8
View File
@@ -7,13 +7,15 @@ import SelectBox from "../Helpers/SelectBox";
import JobListPopout from "../jobPopout/JobListPopout"; import JobListPopout from "../jobPopout/JobListPopout";
import DeleteJobPopout from "../jobPopout/DeleteJobPopout"; import DeleteJobPopout from "../jobPopout/DeleteJobPopout";
import LoadingSpinner from "../Spinners/LoadingSpinner";
import PaginatedList from "../Pagination/PaginatedList"; import PaginatedList from "../Pagination/PaginatedList";
import { handlePagingFunc } from "../Pagination/HandlePagination"; import { handlePagingFunc } from "../Pagination/HandlePagination";
import EditJobPopOut from "../jobPopout/EditJobPopout"; import EditJobPopOut from "../jobPopout/EditJobPopout";
import usersService from "../../services/UsersService"; import usersService from "../../services/UsersService";
import { useSelector } from "react-redux"; import { useSelector } from "react-redux";
export default function MyJobTable({ MyJobList, className }) { export default function MyJobTable({ MyJobList, reloadJobList, className }) {
const [myCountry, setCountries] = useState(""); const [myCountry, setCountries] = useState("");
const { const {
userDetails: { country }, userDetails: { country },
@@ -61,7 +63,7 @@ export default function MyJobTable({ MyJobList, className }) {
const indexOfFirstItem = Number(currentPage); const indexOfFirstItem = Number(currentPage);
const indexOfLastItem = const indexOfLastItem =
Number(indexOfFirstItem) + Number(process.env.REACT_APP_ITEM_PER_PAGE); Number(indexOfFirstItem) + Number(process.env.REACT_APP_ITEM_PER_PAGE);
const currentJobList = MyJobList?.result_list?.slice( const currentJobList = MyJobList?.data?.result_list?.slice(
indexOfFirstItem, indexOfFirstItem,
indexOfLastItem indexOfLastItem
); );
@@ -89,7 +91,10 @@ export default function MyJobTable({ MyJobList, className }) {
contentBodyClasses="w-auto min-w-max" contentBodyClasses="w-auto min-w-max"
/> />
</div> </div>
{MyJobList && MyJobList?.result_list && ( {MyJobList.loading ?
<LoadingSpinner size='16' color='sky-blue' />
:
(
<div className="relative w-full overflow-x-auto sm:rounded-lg flex flex-col justify-between h-full"> <div className="relative w-full overflow-x-auto sm:rounded-lg flex flex-col justify-between h-full">
<table className="table-auto min-w-full text-sm text-left text-gray-500 dark:text-gray-400"> <table className="table-auto min-w-full text-sm text-left text-gray-500 dark:text-gray-400">
<tbody> <tbody>
@@ -101,8 +106,8 @@ export default function MyJobTable({ MyJobList, className }) {
{selectedCategory === "All Categories" ? ( {selectedCategory === "All Categories" ? (
<> <>
{MyJobList && {MyJobList &&
MyJobList?.result_list && MyJobList?.data?.result_list &&
MyJobList.result_list.length > 0 && MyJobList.data?.result_list.length > 0 &&
currentJobList.map((value, index) => ( currentJobList.map((value, index) => (
<tr <tr
key={index} key={index}
@@ -126,7 +131,7 @@ export default function MyJobTable({ MyJobList, className }) {
<span className="text-sm text-thin-light-gray"> <span className="text-sm text-thin-light-gray">
Price:{" "} Price:{" "}
<span className="text-purple"> <span className="text-purple">
{value.price * 0.01} {(value.price * 0.01).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")+'.00'}
</span> </span>
</span> </span>
<span className="text-sm text-thin-light-gray"> <span className="text-sm text-thin-light-gray">
@@ -197,11 +202,11 @@ export default function MyJobTable({ MyJobList, className }) {
prev={currentPage == 0 ? true : false} prev={currentPage == 0 ? true : false}
next={ next={
currentPage + Number(process.env.REACT_APP_ITEM_PER_PAGE) >= currentPage + Number(process.env.REACT_APP_ITEM_PER_PAGE) >=
MyJobList?.result_list?.length MyJobList?.data?.result_list?.length
? true ? true
: false : false
} }
data={MyJobList?.result_list} data={MyJobList?.data?.result_list}
start={indexOfFirstItem} start={indexOfFirstItem}
stop={indexOfLastItem} stop={indexOfLastItem}
/> />
@@ -228,6 +233,7 @@ export default function MyJobTable({ MyJobList, className }) {
onClose={() => { onClose={() => {
setDeleteJobPopout({ show: false, data: {} }); setDeleteJobPopout({ show: false, data: {} });
}} }}
reloadJobList={reloadJobList}
situation={deleteJobPopout.show} situation={deleteJobPopout.show}
/> />
)} )}
+1 -1
View File
@@ -40,7 +40,7 @@ export default function MyJobs(props) {
></div> ></div>
</div> </div>
</div> </div>
<MyJobTable MyJobList={props.MyJobList} /> <MyJobTable MyJobList={props.MyJobList} reloadJobList={props.reloadJobList} />
</div> </div>
</div> </div>
</Layout> </Layout>
@@ -62,7 +62,7 @@ export default function MyPendingJobTable({MyJobList, className }) {
{value.description} {value.description}
</div> </div>
<span className="text-sm text-thin-light-gray"> <span className="text-sm text-thin-light-gray">
Price: <span className="text-purple">{value.price*0.01}</span> Price: <span className="text-purple">{(value.price*0.01).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")+'.00'}</span>
</span> </span>
<span className="text-sm text-thin-light-gray"> <span className="text-sm text-thin-light-gray">
Duration: <span className="text-purple"> {value.timeline_days} day(s)</span> Duration: <span className="text-purple"> {value.timeline_days} day(s)</span>
+2 -2
View File
@@ -505,9 +505,9 @@ export default function Header({ logoutModalHandler, sidebarHandler }) {
</div> </div>
<div className="heading border-b dark:border-[#5356fb29] border-light-purple px-7 py-2"> <div className="heading border-b dark:border-[#5356fb29] border-light-purple px-7 py-2">
<h3 className="text-xl font-bold text-dark-gray dark:text-white"> <h3 className="text-xl font-bold text-dark-gray dark:text-white">
Surname Fullname
</h3> </h3>
<p className="text-sm text-gray-400 dark:text-white hover:text-sky-blue cursor-pointer">broklinslam_75@gamil.com</p> <p className="text-base text-gray-400 dark:text-white hover:text-sky-blue cursor-pointer">{`${firstname} ${lastname}`}</p>
</div> </div>
<div className="content"> <div className="content">
<ul className="px-7"> <ul className="px-7">
+8 -5
View File
@@ -3,8 +3,11 @@ import ModalCom from '../Helpers/ModalCom'
import { useNavigate } from 'react-router-dom' import { useNavigate } from 'react-router-dom'
import usersService from '../../services/UsersService' import usersService from '../../services/UsersService'
import LoadingSpinner from '../Spinners/LoadingSpinner' import LoadingSpinner from '../Spinners/LoadingSpinner'
import { useDispatch } from 'react-redux'
import { tableReload } from '../../store/TableReloads'
function DeleteJobPopout({details, onClose, situation}) { function DeleteJobPopout({details, onClose, situation}) {
let dispatch = useDispatch()
const navigate = useNavigate() const navigate = useNavigate()
const ApiCall = new usersService() const ApiCall = new usersService()
@@ -26,10 +29,10 @@ function DeleteJobPopout({details, onClose, situation}) {
} }
setRequestStatus({laoding: false, status:true, message: 'Job deleted successfully'}) setRequestStatus({laoding: false, status:true, message: 'Job deleted successfully'})
setTimeout(()=>{ setTimeout(()=>{
navigate('/myjobs', {replace: true}) dispatch(tableReload({type:'JOBTABLE'}))
onClose() navigate('/myjobs', {replace: true})
window.location.reload() onClose()
}, 1000) }, 1000)
}).catch(error => { }).catch(error => {
setRequestStatus({laoding: false, status:false, message: 'Opps! something went wrong, try again'}) setRequestStatus({laoding: false, status:false, message: 'Opps! something went wrong, try again'})
}).finally(()=>{ }).finally(()=>{
@@ -97,7 +100,7 @@ function DeleteJobPopout({details, onClose, situation}) {
{details.title} {details.title}
</p> </p>
<p className="text-lg tracking-wide text-dark-gray dark:text-white"> <p className="text-lg tracking-wide text-dark-gray dark:text-white">
Price: {details.price} Price: {(details.price * 0.01).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")+'.00'}
</p> </p>
<p className="text-lg tracking-wide text-dark-gray dark:text-white"> <p className="text-lg tracking-wide text-dark-gray dark:text-white">
Duration: {details.timeline_days} day(s) Duration: {details.timeline_days} day(s)
@@ -7,7 +7,13 @@ import LoadingSpinner from "../Spinners/LoadingSpinner";
import usersService from "../../services/UsersService"; import usersService from "../../services/UsersService";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import { tableReload } from "../../store/TableReloads";
import { useDispatch } from "react-redux";
const EditJobPopOut = ({ details, onClose, situation, country }) => { const EditJobPopOut = ({ details, onClose, situation, country }) => {
const dispatch = useDispatch()
let [requestStatus, setRequestStatus] = useState({ let [requestStatus, setRequestStatus] = useState({
loading: false, loading: false,
status: false, status: false,
@@ -68,6 +74,7 @@ const EditJobPopOut = ({ details, onClose, situation, country }) => {
if (data?.internal_return < 0) return; if (data?.internal_return < 0) return;
setRequestStatus({ loading: false, message: null }); setRequestStatus({ loading: false, message: null });
setTimeout(() => { setTimeout(() => {
dispatch(tableReload({type:'JOBTABLE'}))
navigate("/myjobs", { replace: true }); navigate("/myjobs", { replace: true });
onClose(); onClose();
}, 1000); }, 1000);
@@ -7,10 +7,10 @@ function PendingJobsPopout({details, onClose, situation}) {
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-end 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-26 font-bold text-dark-gray dark:text-white tracking-wide"> <h1 className="text-26 font-bold text-dark-gray dark:text-white tracking-wide">
Confirm Manage Pending Item
</h1> */} </h1>
<button <button
type="button" type="button"
className="text-[#374557] dark:text-red-500" className="text-[#374557] dark:text-red-500"
@@ -73,7 +73,7 @@ function PendingJobsPopout({details, onClose, situation}) {
<div className='my-2 md:flex'> <div className='my-2 md:flex'>
<Detail <Detail
label='Price' label='Price'
value={`${details.price*0.01} ${details.currency}`} value={`${(details.price*0.01).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")+'.00'} ${details.currency}`}
/> />
</div> </div>
+29
View File
@@ -0,0 +1,29 @@
import { createSlice } from "@reduxjs/toolkit";
const initialState = {
jobListTable: false,
pendingListTable: false
};
export const tableReloadSlice = createSlice({
name: "tableReload",
initialState,
reducers: {
tableReload: (state, action) => {
switch(action.payload.type){
case 'JOBTABLE':
state.jobListTable = !state.jobListTable;
return
case 'PENDINGTABLE' :
state.pendingListTable = !state.pendingListTable;
return
default:
return state
}
},
},
});
export const { tableReload } = tableReloadSlice.actions;
export default tableReloadSlice.reducer;
+3 -1
View File
@@ -3,11 +3,13 @@ import drawerReducer from "./drawer";
import userDetailReducer from "./UserDetails"; import userDetailReducer from "./UserDetails";
import jobReducer from "./jobLists"; import jobReducer from "./jobLists";
import tableReloadReducer from "./TableReloads";
export default configureStore({ export default configureStore({
reducer: { reducer: {
drawer: drawerReducer, drawer: drawerReducer,
userDetails: userDetailReducer, userDetails: userDetailReducer,
jobLists: jobReducer jobLists: jobReducer,
tableReload: tableReloadReducer
}, },
}); });
+9 -3
View File
@@ -4,25 +4,31 @@ import React, { useContext,useState, useEffect } from "react";
// import UsersService from "../services/UsersService"; // import UsersService from "../services/UsersService";
import usersService from "../services/UsersService"; import usersService from "../services/UsersService";
import MyJobs from "../components/MyJobs"; import MyJobs from "../components/MyJobs";
import { useSelector } from "react-redux";
export default function MyJobsPage() { export default function MyJobsPage() {
const {jobListTable} = useSelector((state) => state.tableReload)
// const userApi = new usersService(); // const userApi = new usersService();
// const activeJobList = userApi.getMyJobList(); // const activeJobList = userApi.getMyJobList();
const [MyJobList, setMyJobList] = useState([]); const [MyJobList, setMyJobList] = useState({loading: true, data:[]});
const api = new usersService(); const api = new usersService();
const getMyJobList = async () => { const getMyJobList = async () => {
setMyJobList({loading: true, data:[]})
try { try {
const res = await api.getMyJobList(); const res = await api.getMyJobList();
setMyJobList(res.data); setMyJobList({loading: false, data:res.data})
// setMyJobList(res.data);
} catch (error) { } catch (error) {
setMyJobList({loading: false, data:[]})
console.log("Error getting mode"); console.log("Error getting mode");
} }
}; };
useEffect(() => { useEffect(() => {
getMyJobList(); getMyJobList();
}, []); }, [jobListTable]);
// debugger; // debugger;
return ( return (