APi call from Manage post completed
This commit is contained in:
4
.env
4
.env
@@ -1,7 +1,9 @@
|
||||
VITE_API_URL='https://ssa.betadelivery.com/apia/v1'
|
||||
VITE_MAIN_URL='https://ssa.betadelivery.com'
|
||||
# VITE_API_URL='http://192.16.50.44/seo-backend/apia/v1'
|
||||
VITE_USER_NAME="Admin"
|
||||
VITE_PASSWORD="71%@L%es^bUX94`J9XT*@bh,._WWM{$%^^&&"
|
||||
# VITE_PASSWORD="71%@L%es^bUX94`J9XT*%4&^%tUU^%Q^ffgt"
|
||||
VITE_APP_NAME=MyViteApp
|
||||
VITE_IMG_TEMPLATES='https://ssa.betadelivery.com/storage/app/public/uploads/post_templates/'
|
||||
VITE_IMG_TEMPLATES='https://ssa.betadelivery.com/storage/app/public/uploads/post_templates/'
|
||||
VITE_POST_IMG=`${VITE_MAIN_URL}/storage/app/public/uploads/post/`
|
||||
@@ -82,7 +82,7 @@ define(['./workbox-54d0af47'], (function (workbox) { 'use strict';
|
||||
"revision": "3ca0b8505b4bec776b69afdba2768812"
|
||||
}, {
|
||||
"url": "index.html",
|
||||
"revision": "0.4sre1e6vpfo"
|
||||
"revision": "0.bma87cujt8g"
|
||||
}], {});
|
||||
workbox.cleanupOutdatedCaches();
|
||||
workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { Box, HStack,
|
||||
import {
|
||||
Box, HStack,
|
||||
// Image,
|
||||
Input, Text } from "@chakra-ui/react";
|
||||
Input, Text
|
||||
} from "@chakra-ui/react";
|
||||
import { LuSearch } from "react-icons/lu";
|
||||
// import { RiDeleteBin5Line } from "react-icons/ri";
|
||||
// import AlertDailog from "../../components/AlertDailog";
|
||||
@@ -9,6 +11,8 @@ import MainFrame from "../../components/MainFrame";
|
||||
import { InputGroup } from "../../components/ui/input-group";
|
||||
import ManageJobsAdd from "./ManageJobsAdd";
|
||||
import ViewManageJob from "./ViewManageJob";
|
||||
// import { useState } from "react";
|
||||
// import { useGetManageJobsQuery } from "../../Redux/Service/manage.jobs.service";
|
||||
// import Delete from "../../components/ActionIcons/Delete";
|
||||
|
||||
// table data
|
||||
@@ -50,6 +54,10 @@ const managepost: any[] = [
|
||||
];
|
||||
|
||||
const ManageJobs = () => {
|
||||
// const [currentPage, setCurrentPage] = useState(1);
|
||||
// const { data, refetch } = useGetManageJobsQuery(currentPage)
|
||||
// console.log(data?.data.data);
|
||||
|
||||
return (
|
||||
<MainFrame>
|
||||
<Box>
|
||||
|
||||
@@ -1,67 +1,205 @@
|
||||
import { Box, HStack, Image, Input,
|
||||
import {
|
||||
Box, HStack, Icon, Image,
|
||||
// Span,
|
||||
Text } from "@chakra-ui/react";
|
||||
Text
|
||||
} from "@chakra-ui/react";
|
||||
import MainFrame from "../../components/MainFrame";
|
||||
import { InputGroup } from "../../components/ui/input-group";
|
||||
import { LuSearch } from "react-icons/lu";
|
||||
// import { InputGroup } from "../../components/ui/input-group";
|
||||
// import { LuSearch } from "react-icons/lu";
|
||||
import DataTable from "../../components/DataTable";
|
||||
// import AlertDailog from "../../components/AlertDailog";
|
||||
import { Switch } from "../../components/ui/switch";
|
||||
import img from "../../assets/waterfall.jpg";
|
||||
// import img from "../../assets/waterfall.jpg";
|
||||
// import { RiDeleteBin5Line } from "react-icons/ri";
|
||||
import ViewDailog from "./ViewDailog";
|
||||
import { useGetManagePostsQuery, usePostStatusToggleMutation } from "../../Redux/Service/manage.post.service";
|
||||
import { useEffect, useState } from "react";
|
||||
import { toaster } from "../../components/ui/toaster";
|
||||
import { FaVideo } from "react-icons/fa";
|
||||
import SearchComponent from "../../components/SearchComponent";
|
||||
// import Delete from "../../components/ActionIcons/Delete";
|
||||
// import ViewDailog from './ViewDailog'
|
||||
|
||||
// table data
|
||||
const APIURL = import.meta.env.VITE_POST_IMG
|
||||
|
||||
const tableHeadRow = [
|
||||
"Sr. No",
|
||||
"Images",
|
||||
"Description",
|
||||
"Publish Data",
|
||||
"Activate/Deactivate",
|
||||
// "Activate/Deactivate",
|
||||
"Action",
|
||||
];
|
||||
|
||||
const managepost: any[] = [
|
||||
...Array.from({ length: 12 }, (_, i) => ({
|
||||
"Sr. No": i + 1,
|
||||
// const managepost: any[] = [
|
||||
// ...Array.from({ length: 12 }, (_, i) => ({
|
||||
// "Sr. No": i + 1,
|
||||
// Images: (
|
||||
// // <Image w={50} src={img} />
|
||||
// <Image rounded={"lg"} w={100} h={50} src={img} />
|
||||
// ),
|
||||
// Description: (
|
||||
// <Text>
|
||||
// {`Lorem ipsum dolor, sit amet consectetur adipisicing elit.}`.slice(
|
||||
// 0,
|
||||
// 30
|
||||
// ) + "..."}
|
||||
// </Text>
|
||||
// ),
|
||||
// "Publish Data": "12/01/2025",
|
||||
// "Activate/Deactivate": (
|
||||
// <Box w={"100%"}>
|
||||
// <Switch size={"sm"} colorPalette={"teal"} />
|
||||
// </Box>
|
||||
// ),
|
||||
// Action: (
|
||||
// <HStack justifyContent="center">
|
||||
// <ViewDailog />
|
||||
// {/* <AlertDailog
|
||||
// AltertTiggerIcon={() => <Span><Delete /> </Span>}
|
||||
// alertText="Delete Users"
|
||||
// alertIcon={<Image src={"DeleteIcon"} h={"39px"} />}
|
||||
// alertCaption="are you sure you want to delete ?"
|
||||
// onConfirm={() => {
|
||||
// console.log("User deleted:", i + 1);
|
||||
// }}
|
||||
// /> */}
|
||||
// </HStack>
|
||||
// ),
|
||||
// })),
|
||||
// ];
|
||||
|
||||
const ManagePost = () => {
|
||||
const [currentPage, setCurrentPage] = useState(1);
|
||||
const { data, refetch } = useGetManagePostsQuery(currentPage)
|
||||
const [localData, setLocalData] = useState<any[]>([]);
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
const [postStatusToggle] = usePostStatusToggleMutation()
|
||||
console.log('POSTS', data?.data.data);
|
||||
|
||||
useEffect(() => {
|
||||
if (data?.data?.data) {
|
||||
setLocalData(data?.data.data);
|
||||
}
|
||||
}, [data]);
|
||||
|
||||
const handlePageChange = (page: number) => {
|
||||
setCurrentPage(page);
|
||||
};
|
||||
|
||||
const handleToggle = async (agencyId: string, currentStatus: number) => {
|
||||
const newStatus = currentStatus ? 0 : 1;
|
||||
setLocalData((prevData) =>
|
||||
prevData.map((agency) =>
|
||||
agency.id === agencyId ? { ...agency, is_active: newStatus } : agency
|
||||
)
|
||||
);
|
||||
try {
|
||||
await postStatusToggle({ id: agencyId, is_active: newStatus }).unwrap();
|
||||
refetch()
|
||||
} catch (error) {
|
||||
console.error("Error updating:", error);
|
||||
toaster.create({
|
||||
title: "Error",
|
||||
description: "Someting went wrong.",
|
||||
type: "error",
|
||||
});
|
||||
setLocalData((prevData) =>
|
||||
prevData.map((agency) =>
|
||||
agency.id === agencyId ? { ...agency, is_active: currentStatus } : agency
|
||||
)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
function formatAPIDate(apiDateString: any) {
|
||||
const date = new Date(apiDateString);
|
||||
|
||||
// Get month, day, and year
|
||||
const month = date.getMonth() + 1; // Months are 0-indexed
|
||||
const day = date.getDate();
|
||||
const year = date.getFullYear();
|
||||
|
||||
// Pad with leading zeros if needed
|
||||
const formattedMonth = month.toString().padStart(2, '0');
|
||||
const formattedDay = day.toString().padStart(2, '0');
|
||||
|
||||
return `${formattedMonth}/${formattedDay}/${year}`;
|
||||
}
|
||||
|
||||
const filteredData = localData?.filter((agency) => {
|
||||
return (agency.post_content_translation.some((item: any) => {
|
||||
const searchLower = searchTerm.toLowerCase();
|
||||
const title = item.content?.toLowerCase().includes(searchLower);
|
||||
return title;
|
||||
}))
|
||||
});
|
||||
|
||||
const managepost = filteredData?.flatMap((agency: any, index: number) => (agency.post_content_translation.map((translation: any) => ({
|
||||
'id': agency.id,
|
||||
"Sr. No": (currentPage - 1) * (data?.data.per_page ?? 0) + index + 1,
|
||||
Images: (
|
||||
// <Image w={50} src={img} />
|
||||
<Image rounded={"lg"} w={100} h={50} src={img} />
|
||||
agency.images.length > 0 ?
|
||||
agency.images[0].type === "image" ? (
|
||||
<HStack>
|
||||
<Image
|
||||
rounded={"lg"}
|
||||
w={100}
|
||||
h={50}
|
||||
src={`${APIURL}${agency.images[0].image_name}`}
|
||||
/>
|
||||
<Text fontSize="xs" color={'lightgray'}>
|
||||
{`${Number(agency.images.length) > 1 ? '+' + (Number(agency.images.length) - 1) : ''}`}
|
||||
</Text>
|
||||
</HStack>
|
||||
) : (
|
||||
<HStack>
|
||||
<Box
|
||||
rounded={"lg"}
|
||||
w={100}
|
||||
h={50}
|
||||
bg="gray.200"
|
||||
display="flex"
|
||||
alignItems="center"
|
||||
justifyContent="center"
|
||||
>
|
||||
<Icon as={FaVideo} color="gray.500" />
|
||||
</Box>
|
||||
<Text fontSize="xs" color={'lightgray'}>
|
||||
{`${Number(agency.images.length) > 1 ? '+' + (Number(agency.images.length) - 1) : ''}`}
|
||||
</Text>
|
||||
</HStack>
|
||||
) : ''
|
||||
// <Image rounded={"lg"} w={100} h={50} src={img} />
|
||||
),
|
||||
Description: (
|
||||
<Text>
|
||||
{`Lorem ipsum dolor, sit amet consectetur adipisicing elit.}`.slice(
|
||||
{`${translation?.content}`.slice(
|
||||
0,
|
||||
30
|
||||
) + "..."}
|
||||
</Text>
|
||||
),
|
||||
"Publish Data": "12/01/2025",
|
||||
"Activate/Deactivate": (
|
||||
<Box w={"100%"}>
|
||||
<Switch size={"sm"} colorPalette={"teal"} />
|
||||
</Box>
|
||||
),
|
||||
Action: (
|
||||
"Publish Data": formatAPIDate(agency.created_at),
|
||||
"is_active": agency.is_active,
|
||||
"Action": (
|
||||
<HStack justifyContent="center">
|
||||
<ViewDailog />
|
||||
{/* <AlertDailog
|
||||
AltertTiggerIcon={() => <Span><Delete /> </Span>}
|
||||
alertText="Delete Users"
|
||||
alertIcon={<Image src={"DeleteIcon"} h={"39px"} />}
|
||||
alertCaption="are you sure you want to delete ?"
|
||||
onConfirm={() => {
|
||||
console.log("User deleted:", i + 1);
|
||||
}}
|
||||
/> */}
|
||||
{/* <ViewAgencyMaster agency={localData} id={agency.id} /> */}
|
||||
<ViewDailog localData={{ ...agency, translation }} refetch={refetch} />
|
||||
<Box>
|
||||
<Switch
|
||||
colorPalette={"teal"}
|
||||
size={"xs"}
|
||||
onChange={() => handleToggle(agency.id, Number(agency.is_active))}
|
||||
checked={Boolean(Number(agency.is_active))}
|
||||
/>
|
||||
</Box>
|
||||
</HStack>
|
||||
),
|
||||
})),
|
||||
];
|
||||
const ManagePost = () => {
|
||||
}))));
|
||||
|
||||
|
||||
return (
|
||||
<MainFrame>
|
||||
<Box>
|
||||
@@ -77,35 +215,27 @@ const ManagePost = () => {
|
||||
</Text>
|
||||
|
||||
<HStack>
|
||||
<InputGroup
|
||||
startElement={
|
||||
<LuSearch
|
||||
fontSize={"xs"}
|
||||
style={{ position: "relative", left: "10px" }}
|
||||
/>
|
||||
}
|
||||
color={"#000"}
|
||||
>
|
||||
<Input
|
||||
p={3}
|
||||
w={300}
|
||||
bg={"#fff"}
|
||||
colorPalette={"blue"}
|
||||
_focus={{ border: "1px solid #02A0A0" }}
|
||||
rounded={"md"}
|
||||
size={"xs"}
|
||||
fontSize={"sm"}
|
||||
placeholder="Search..."
|
||||
bgColor={"#EEEEEE"}
|
||||
ps={8}
|
||||
/>
|
||||
</InputGroup>
|
||||
<SearchComponent
|
||||
value={searchTerm}
|
||||
onChange={(value) => {
|
||||
setSearchTerm(value);
|
||||
// setCurrentPage(1);
|
||||
refetch()
|
||||
}}
|
||||
/>
|
||||
</HStack>
|
||||
</HStack>
|
||||
<DataTable
|
||||
sortableColumns={["Name", "Registration Date "]}
|
||||
tableHeadRow={tableHeadRow}
|
||||
data={managepost}
|
||||
paginationData={{
|
||||
current_page: data?.data.current_page || 1,
|
||||
last_page: data?.data.last_page || 1,
|
||||
per_page: data?.data.per_page || 10,
|
||||
total: data?.data.total || 0
|
||||
}}
|
||||
onPageChange={handlePageChange}
|
||||
/>
|
||||
</Box>
|
||||
</MainFrame>
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
import { Field, Image, Input, Span, Stack } from "@chakra-ui/react"
|
||||
import { Field, HStack, Image, Input, Stack } from "@chakra-ui/react"
|
||||
// import { TbEdit } from "react-icons/tb"
|
||||
import img from "../../assets/waterfall.jpg"
|
||||
// import img from "../../assets/waterfall.jpg"
|
||||
import { DialogBody, DialogCloseTrigger, DialogContent, DialogHeader, DialogRoot, DialogTitle, DialogTrigger } from "../../components/ui/dialog"
|
||||
import Edit from "../../components/ActionIcons/Edit"
|
||||
// import Edit from "../../components/ActionIcons/Edit"
|
||||
import { LuEye } from "react-icons/lu"
|
||||
|
||||
function ViewDailog() {
|
||||
const APIURL = import.meta.env.VITE_POST_IMG
|
||||
|
||||
function ViewDailog({ localData }: { localData: any, refetch: VoidFunction }) {
|
||||
return (
|
||||
|
||||
<DialogRoot placement="center">
|
||||
<DialogTrigger asChild>
|
||||
<Span><Edit /></Span>
|
||||
{/* <Span><Edit /></Span> */}
|
||||
<LuEye fontSize={"xm"} cursor={'pointer'} />
|
||||
</DialogTrigger>
|
||||
|
||||
<DialogContent
|
||||
@@ -25,17 +28,49 @@ function ViewDailog() {
|
||||
<DialogBody bg="white">
|
||||
<Stack py={3} >
|
||||
<Field.Root>
|
||||
<Field.Label color="black" pt={1} fontSize="12px">Title</Field.Label>
|
||||
<Input placeholder="Enter the Title" bgColor="#EEEEEE" color="black" border="none" pl={1} fontSize="12px" height="30px" readOnly />
|
||||
|
||||
<Field.Label color="black" pt={1} fontSize="12px">Subtitle</Field.Label>
|
||||
<Input placeholder="Enter the Subtitle" bgColor="#EEEEEE" color="black" border="none" pl={1} fontSize="12px" height="30px" readOnly />
|
||||
|
||||
<Field.Label color="black" pt={1} fontSize="12px">Description</Field.Label>
|
||||
<Input placeholder="Enter the Description" bgColor="#EEEEEE" color="black" border="none" pl={1} fontSize="12px" height="30px" readOnly />
|
||||
<Input
|
||||
// placeholder="Enter the Title"
|
||||
value={localData.translation.content}
|
||||
bgColor="#EEEEEE"
|
||||
color="black"
|
||||
border="none"
|
||||
pl={1}
|
||||
fontSize="12px"
|
||||
height="30px"
|
||||
readOnly
|
||||
/>
|
||||
|
||||
{/* <Field.Label color="black" pt={1} fontSize="12px">Subtitle</Field.Label>
|
||||
<Input placeholder="Enter the Subtitle" bgColor="#EEEEEE" color="black" border="none" pl={1} fontSize="12px" height="30px" readOnly /> */}
|
||||
|
||||
{/* <Field.Label color="black" pt={1} fontSize="12px">Description</Field.Label>
|
||||
<Input placeholder="Enter the Description" bgColor="#EEEEEE" color="black" border="none" pl={1} fontSize="12px" height="30px" readOnly /> */}
|
||||
<Field.Label color="black" pt={1} fontSize="12px">Image</Field.Label>
|
||||
<Image src={img} w="100%" maxH="150px" objectFit="contain" />
|
||||
<HStack w="fit-content" flexWrap={'wrap'}>
|
||||
{localData.images.map((img: any) => (
|
||||
img.type === 'image' ? (
|
||||
<Image
|
||||
key={img.id}
|
||||
src={`${APIURL}${img.image_name}`}
|
||||
w="30%"
|
||||
maxH="150px"
|
||||
objectFit="contain"
|
||||
/>
|
||||
) : (
|
||||
<video
|
||||
key={img.id}
|
||||
width="45%"
|
||||
height="50"
|
||||
controls
|
||||
>
|
||||
<source src={`${APIURL}${img.image_name}`} type="video/mp4" />
|
||||
</video>
|
||||
)
|
||||
))}
|
||||
</HStack>
|
||||
|
||||
{/* <Image src={img} w="100%" maxH="150px" objectFit="contain" /> */}
|
||||
</Field.Root>
|
||||
</Stack>
|
||||
</DialogBody>
|
||||
|
||||
@@ -139,7 +139,8 @@ const Country = () => {
|
||||
value={searchTerm}
|
||||
onChange={(value) => {
|
||||
setSearchTerm(value);
|
||||
setCurrentPage(1);
|
||||
// setCurrentPage(1);
|
||||
refetch()
|
||||
}}
|
||||
/>
|
||||
{/* <Button bgColor={'#EEEEEE'} pl={3} pr={3}><IoMdAdd /> <Text>Add</Text></Button> */}
|
||||
|
||||
@@ -114,7 +114,8 @@ const DepartmentMasterList = () => {
|
||||
value={searchTerm}
|
||||
onChange={(value) => {
|
||||
setSearchTerm(value);
|
||||
setCurrentPage(1);
|
||||
// setCurrentPage(1);
|
||||
refetch()
|
||||
}}
|
||||
/>
|
||||
{/* <Button bgColor={'#EEEEEE'} pl={3} pr={3}><IoMdAdd /> <Text>Add</Text></Button> */}
|
||||
|
||||
@@ -132,7 +132,8 @@ const IndustryMasterList = () => {
|
||||
value={searchTerm}
|
||||
onChange={(value) => {
|
||||
setSearchTerm(value);
|
||||
setCurrentPage(1);
|
||||
// setCurrentPage(1);
|
||||
refetch()
|
||||
}}
|
||||
/>
|
||||
{/* <Button bgColor={'#EEEEEE'} pl={3} pr={3}><IoMdAdd /> <Text>Add</Text></Button> */}
|
||||
|
||||
@@ -127,7 +127,8 @@ const JobStatus = () => {
|
||||
value={searchTerm}
|
||||
onChange={(value) => {
|
||||
setSearchTerm(value);
|
||||
setCurrentPage(1);
|
||||
// setCurrentPage(1);
|
||||
refetch()
|
||||
}}
|
||||
/>
|
||||
{/* <Button bgColor={'#EEEEEE'} pl={3} pr={3}><IoMdAdd /> <Text>Add</Text></Button> */}
|
||||
|
||||
@@ -123,7 +123,8 @@ const JobType = () => {
|
||||
value={searchTerm}
|
||||
onChange={(value) => {
|
||||
setSearchTerm(value);
|
||||
setCurrentPage(1);
|
||||
// setCurrentPage(1);
|
||||
refetch()
|
||||
}}
|
||||
/>
|
||||
{/* <Button bgColor={'#EEEEEE'} pl={3} pr={3}><IoMdAdd /> <Text>Add</Text></Button> */}
|
||||
|
||||
@@ -126,7 +126,8 @@ const WorkspaceMode = () => {
|
||||
value={searchTerm}
|
||||
onChange={(value) => {
|
||||
setSearchTerm(value);
|
||||
setCurrentPage(1);
|
||||
// setCurrentPage(1);
|
||||
refetch()
|
||||
}}
|
||||
/>
|
||||
{/* <Button bgColor={'#EEEEEE'} pl={3} pr={3}><IoMdAdd /> <Text>Add</Text></Button> */}
|
||||
|
||||
@@ -1,26 +1,84 @@
|
||||
import { createApi } from "@reduxjs/toolkit/query";
|
||||
import { createApi } from "@reduxjs/toolkit/query/react";
|
||||
import { baseQueryWithReauth } from "./apiSlice";
|
||||
|
||||
export const manageJobs = createApi({
|
||||
reducerPath: "manageJobs",
|
||||
baseQuery: baseQueryWithReauth, // Use enhanced baseQuery with error handling
|
||||
endpoints: (builder) => ({
|
||||
|
||||
|
||||
|
||||
getPosts: builder.query<Post[], void>({ query: () => "/posts" }),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}),
|
||||
});
|
||||
|
||||
export const { } = manageJobs;
|
||||
|
||||
export type Post = {
|
||||
export interface JobStatusData {
|
||||
id: number;
|
||||
job_title: string;
|
||||
workspace_mode_xid: number;
|
||||
industry_xid: number;
|
||||
department_xid: number;
|
||||
company_name: string;
|
||||
ctc_currency_symbol: string;
|
||||
ctc_amount: string;
|
||||
experience: string;
|
||||
job_location: string;
|
||||
country_xid: number;
|
||||
job_type_xid: number;
|
||||
skill_description: string;
|
||||
job_description: string;
|
||||
job_image: string | null;
|
||||
industry: {
|
||||
id: number;
|
||||
title: string;
|
||||
body: string;
|
||||
};
|
||||
en_name: string;
|
||||
};
|
||||
department: {
|
||||
id: number;
|
||||
en_name: string;
|
||||
};
|
||||
workspace: {
|
||||
id: number;
|
||||
en_name: string;
|
||||
};
|
||||
country: {
|
||||
id: number;
|
||||
en_name: string;
|
||||
};
|
||||
job_type: {
|
||||
id: number;
|
||||
en_name: string;
|
||||
};
|
||||
}
|
||||
|
||||
interface ApiResponse {
|
||||
status: string;
|
||||
status_code: number;
|
||||
message: string;
|
||||
data: {
|
||||
current_page: number,
|
||||
last_page: number,
|
||||
total: number,
|
||||
from: number,
|
||||
per_page: number,
|
||||
to: number,
|
||||
data: JobStatusData[];
|
||||
};
|
||||
}
|
||||
|
||||
export interface CountryEdit {
|
||||
status: string;
|
||||
status_code: number;
|
||||
message: string;
|
||||
data: JobStatusData[];
|
||||
}
|
||||
|
||||
|
||||
export type PostJobStatus = {
|
||||
title: string
|
||||
};
|
||||
|
||||
export const manageJobs = createApi({
|
||||
reducerPath: "manageJobs",
|
||||
baseQuery: baseQueryWithReauth, // Use enhanced baseQuery with error handling
|
||||
endpoints: (builder) => ({
|
||||
getManageJobs: builder.query<ApiResponse, number>({
|
||||
query: (page = 1) => `/manage-jobs-list?page=${page}`,
|
||||
}),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}),
|
||||
});
|
||||
|
||||
export const { useGetManageJobsQuery } = manageJobs;
|
||||
|
||||
82
src/Redux/Service/manage.post.service.ts
Normal file
82
src/Redux/Service/manage.post.service.ts
Normal file
@@ -0,0 +1,82 @@
|
||||
import { createApi } from "@reduxjs/toolkit/query/react";
|
||||
import { baseQueryWithReauth } from "./apiSlice";
|
||||
|
||||
export interface JobStatusData {
|
||||
id: number;
|
||||
is_active: string;
|
||||
created_at:string,
|
||||
job_status_translation:{
|
||||
job_status_xid: number,
|
||||
title:string,
|
||||
language_xid:number
|
||||
}[],
|
||||
}
|
||||
|
||||
interface ApiResponse {
|
||||
status: string;
|
||||
status_code: number;
|
||||
message: string;
|
||||
data: {
|
||||
current_page: number,
|
||||
last_page: number,
|
||||
total: number,
|
||||
from: number,
|
||||
per_page: number,
|
||||
to: number,
|
||||
data: JobStatusData[];
|
||||
};
|
||||
}
|
||||
|
||||
export interface CountryEdit {
|
||||
status: string;
|
||||
status_code: number;
|
||||
message: string;
|
||||
data: JobStatusData[];
|
||||
}
|
||||
|
||||
|
||||
export type PostJobStatus = {
|
||||
title: string
|
||||
};
|
||||
|
||||
|
||||
export const managePosts = createApi({
|
||||
reducerPath: "managePosts",
|
||||
baseQuery: baseQueryWithReauth, // Use enhanced baseQuery with error handling
|
||||
endpoints: (builder) => ({
|
||||
// createJobStatusPost: builder.mutation<PostJobStatus, Partial<PostJobStatus>>({
|
||||
// query: (data) => ({
|
||||
// url: "/job-status-store",
|
||||
// method: "POST",
|
||||
// body: data,
|
||||
// }),
|
||||
// }),
|
||||
// 🔹 GET: Fetch all posts
|
||||
getManagePosts: builder.query<ApiResponse, number>({
|
||||
query: (page = 1) => `/manage-post-list?page=${page}`,
|
||||
}),
|
||||
|
||||
postStatusToggle: builder.mutation({
|
||||
query: ({ id, is_active }) => ({
|
||||
url: `/manage-post-status`,
|
||||
method: "POST",
|
||||
body: { id, is_active },
|
||||
}),
|
||||
}),
|
||||
|
||||
// deleteFaqPost: builder.mutation<{ status: string; message: string }, { id: number }>({
|
||||
// query: ({ id }) => ({
|
||||
// url: `/faq-delete`,
|
||||
// method: "POST",
|
||||
// body: { id },
|
||||
// }),
|
||||
// }),
|
||||
|
||||
}),
|
||||
});
|
||||
|
||||
export const {
|
||||
useGetManagePostsQuery,
|
||||
usePostStatusToggleMutation,
|
||||
// useDeleteFaqPostMutation
|
||||
} = managePosts;
|
||||
@@ -1,26 +0,0 @@
|
||||
import { createApi } from "@reduxjs/toolkit/query";
|
||||
import { baseQueryWithReauth } from "./apiSlice";
|
||||
|
||||
export const managePosts = createApi({
|
||||
reducerPath: "managePosts",
|
||||
baseQuery: baseQueryWithReauth, // Use enhanced baseQuery with error handling
|
||||
endpoints: (builder) => ({
|
||||
|
||||
|
||||
|
||||
getPosts: builder.query<Post[], void>({ query: () => "/posts" }),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}),
|
||||
});
|
||||
|
||||
export const { } = managePosts;
|
||||
|
||||
export type Post = {
|
||||
id: number;
|
||||
title: string;
|
||||
body: string;
|
||||
};
|
||||
@@ -4,7 +4,6 @@ import authReducer from "./Service/authSlice";
|
||||
import { registerUser } from "./Service/register.user.service";
|
||||
import { deactivatedAccounts } from "./Service/deactivated.account.service";
|
||||
import { faqs } from "./Service/faqs.service";
|
||||
import { managePosts } from "./Service/manage.posts.service";
|
||||
import { manageSubAdmin } from "./Service/manage.subadmin.service";
|
||||
import { manageJobs } from "./Service/manage.jobs.service";
|
||||
import { manageGroups } from "./Service/manage.groups.service";
|
||||
@@ -23,6 +22,7 @@ import { countryMaster } from "./Service/country.master";
|
||||
import { departmentMaster } from "./Service/department.master";
|
||||
import { workspaceMode } from "./Service/workspace.mode";
|
||||
import { jobStatus } from "./Service/job.status";
|
||||
import { managePosts } from "./Service/manage.post.service";
|
||||
|
||||
export const store = configureStore({
|
||||
reducer: {
|
||||
@@ -30,7 +30,6 @@ export const store = configureStore({
|
||||
[registerUser.reducerPath]: registerUser.reducer,
|
||||
[deactivatedAccounts.reducerPath]: deactivatedAccounts.reducer,
|
||||
[faqs.reducerPath]: faqs.reducer,
|
||||
[managePosts.reducerPath]: managePosts.reducer,
|
||||
[manageSubAdmin.reducerPath]: manageSubAdmin.reducer,
|
||||
[manageJobs.reducerPath]: manageJobs.reducer,
|
||||
[manageGroups.reducerPath]: manageGroups.reducer,
|
||||
@@ -49,13 +48,13 @@ export const store = configureStore({
|
||||
[departmentMaster.reducerPath]: departmentMaster.reducer,
|
||||
[workspaceMode.reducerPath]: workspaceMode.reducer,
|
||||
[jobStatus.reducerPath]: jobStatus.reducer,
|
||||
[managePosts.reducerPath]: managePosts.reducer,
|
||||
auth: authReducer,
|
||||
},
|
||||
middleware: (getDefaultMiddleware) =>
|
||||
getDefaultMiddleware().concat(
|
||||
dashboard.middleware,
|
||||
dashboard.middleware,
|
||||
deactivatedAccounts.middleware,
|
||||
managePosts.middleware,
|
||||
faqs.middleware,
|
||||
manageSubAdmin.middleware,
|
||||
manageJobs.middleware,
|
||||
@@ -75,7 +74,8 @@ export const store = configureStore({
|
||||
departmentMaster.middleware,
|
||||
workspaceMode.middleware,
|
||||
jobStatus.middleware,
|
||||
),
|
||||
managePosts.middleware,
|
||||
),
|
||||
});
|
||||
|
||||
export type RootState = ReturnType<typeof store.getState>;
|
||||
|
||||
Reference in New Issue
Block a user