Added env.testing / Completed Agency master
This commit is contained in:
5
.env.testing
Normal file
5
.env.testing
Normal file
@@ -0,0 +1,5 @@
|
||||
VITE_API_URL='https://ssa.betadelivery.com/testing/apia/'
|
||||
VITE_USER_NAME="Admin"
|
||||
VITE_PASSWORD="71%@L%es^bUX94`J9XT*@bh,._WWM{$%^^&&"
|
||||
VITE_APP_NAME=MyViteApp
|
||||
VITE_IMG_TEMPLATES='https://ssa.betadelivery.com/storage/app/public/uploads/post_templates/'
|
||||
@@ -82,7 +82,7 @@ define(['./workbox-54d0af47'], (function (workbox) { 'use strict';
|
||||
"revision": "3ca0b8505b4bec776b69afdba2768812"
|
||||
}, {
|
||||
"url": "index.html",
|
||||
"revision": "0.9manovjiico"
|
||||
"revision": "0.n8f1c1adqh8"
|
||||
}], {});
|
||||
workbox.cleanupOutdatedCaches();
|
||||
workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), {
|
||||
|
||||
4777
package-lock.json
generated
4777
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -30,7 +30,7 @@
|
||||
"vite-plugin-pwa": "^0.21.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@chakra-ui/cli": "^3.2.3",
|
||||
"@chakra-ui/cli": "^2.4.1",
|
||||
"@eslint/js": "^9.17.0",
|
||||
"@types/js-cookie": "^3.0.6",
|
||||
"@types/react": "^18.3.18",
|
||||
|
||||
@@ -182,10 +182,10 @@ const Login = () => {
|
||||
</Button>
|
||||
|
||||
{/* <ForgetPassword /> */}
|
||||
<Box textAlign={"right"}>
|
||||
<Box textAlign={"center"} mt={4}>
|
||||
<Link
|
||||
to={'/forgot-password'}
|
||||
style={{ color: "black", fontSize: "18px" }}
|
||||
style={{ color: "black", fontSize: "16px" }}
|
||||
>
|
||||
Forgot Password
|
||||
</Link>
|
||||
|
||||
@@ -95,7 +95,7 @@ import { Field, Input, Stack, Textarea } from "@chakra-ui/react";
|
||||
import Edit from "../../../components/ActionIcons/Edit";
|
||||
import { useUpdateFaqMutation } from "../../../Redux/Service/faqs.service";
|
||||
import { useEffect, useState } from "react";
|
||||
import { toaster } from "../../../components/ui/toaster";
|
||||
import { Toaster, toaster } from "../../../components/ui/toaster";
|
||||
|
||||
interface RowData {
|
||||
id: number;
|
||||
@@ -228,6 +228,7 @@ function EditDetails({ rowData, refetch }: {rowData: RowData, refetch: VoidFunct
|
||||
|
||||
<DialogCloseTrigger color="black" onClick={() => setIsOpen(false)} />
|
||||
</DialogContent>
|
||||
<Toaster />
|
||||
</DialogRoot>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import Delete from "../../../components/ActionIcons/Delete";
|
||||
import { useEffect, useState } from "react";
|
||||
import { FaqData, useDeleteFaqPostMutation, useFaqToggleMutation, useGetFaqQuery } from "../../../Redux/Service/faqs.service";
|
||||
import SearchComponent from "../../../components/SearchComponent";
|
||||
import NoData from "../../../components/NoData";
|
||||
|
||||
|
||||
// table data
|
||||
@@ -50,7 +51,7 @@ const tableHeadRow = [
|
||||
// ];
|
||||
|
||||
const FAQ = () => {
|
||||
const { data, refetch } = useGetFaqQuery()
|
||||
const { data, refetch, isLoading } = useGetFaqQuery()
|
||||
const [localData, setLocalData] = useState<any[]>([]);
|
||||
const [faqToggle] = useFaqToggleMutation()
|
||||
const [deleteFaqPost] = useDeleteFaqPostMutation()
|
||||
@@ -133,6 +134,12 @@ const FAQ = () => {
|
||||
),
|
||||
}));
|
||||
|
||||
// if (!isLoading && !data?.data) {
|
||||
// return (
|
||||
// <NoData />
|
||||
// )
|
||||
// }
|
||||
|
||||
return (
|
||||
|
||||
<MainFrame>
|
||||
@@ -170,7 +177,6 @@ const FAQ = () => {
|
||||
/>
|
||||
</InputGroup> */}
|
||||
<SearchComponent
|
||||
// placeholder="Search FAQs..."
|
||||
value={searchTerm}
|
||||
onChange={setSearchTerm}
|
||||
/>
|
||||
@@ -178,13 +184,15 @@ const FAQ = () => {
|
||||
<FaqAddModel refetch={refetch} />
|
||||
</HStack>
|
||||
</HStack>
|
||||
<DataTable
|
||||
{!isLoading && !data?.data ? (
|
||||
<NoData />
|
||||
) : <DataTable
|
||||
sortableColumns={["Name"]}
|
||||
tableHeadRow={tableHeadRow}
|
||||
data={managepost}
|
||||
paginationData={data?.data}
|
||||
refetch={refetch}
|
||||
/>
|
||||
/>}
|
||||
</Box>
|
||||
</MainFrame>
|
||||
)
|
||||
|
||||
@@ -12,7 +12,7 @@ import { Box, Field, Input, Stack, Text, Textarea } from "@chakra-ui/react";
|
||||
import { IoMdAdd } from "react-icons/io";
|
||||
import { Button } from "../../../components/ui/button";
|
||||
import { useState } from "react";
|
||||
import { toaster } from "../../../components/ui/toaster";
|
||||
import { Toaster, toaster } from "../../../components/ui/toaster";
|
||||
import { useCreateFaqPostMutation } from "../../../Redux/Service/faqs.service";
|
||||
|
||||
function FaqAddModel({ refetch }: { refetch: VoidFunction }) {
|
||||
@@ -166,6 +166,7 @@ function FaqAddModel({ refetch }: { refetch: VoidFunction }) {
|
||||
|
||||
<DialogCloseTrigger color="black" onClick={() => setIsOpen(false)} />
|
||||
</DialogContent>
|
||||
<Toaster />
|
||||
</DialogRoot>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
import { Box, HStack, Input, Text } from "@chakra-ui/react";
|
||||
import { Box, HStack, Text } from "@chakra-ui/react";
|
||||
import MainFrame from "../../../components/MainFrame"
|
||||
import { InputGroup } from "../../../components/ui/input-group";
|
||||
import { LuSearch } from "react-icons/lu";
|
||||
import DataTable from "../../../components/DataTable";
|
||||
import { Switch } from "../../../components/ui/switch";
|
||||
import EditAgencyMaster from "./EditAgencyMaster";
|
||||
import ViewAgencyAddModel from "./ViewAgencyAddModel";
|
||||
// import EditAgencyMaster from "./EditAgencyMaster";
|
||||
// import ViewAgencyAddModel from "./ViewAgencyAddModel";
|
||||
import ViewAgencyMaster from "./ViewAgencyMaster";
|
||||
import {useAgencyMasterToggleMutation, useGetAgencyMasterQuery } from "../../../Redux/Service/agency.master.module.service";
|
||||
import { useAgencyMasterToggleMutation, useGetAgencyMasterQuery } from "../../../Redux/Service/agency.master.module.service";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
import SearchComponent from "../../../components/SearchComponent";
|
||||
|
||||
// table data
|
||||
|
||||
@@ -52,12 +50,7 @@ const AgencyMaster = () => {
|
||||
const { data, refetch } = useGetAgencyMasterQuery()
|
||||
const [agencyMasterToggle] = useAgencyMasterToggleMutation()
|
||||
const [localData, setLocalData] = useState<any[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
if (data?.data?.data) {
|
||||
setLocalData(data?.data.data);
|
||||
}
|
||||
}, [data]);
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
|
||||
const handleToggle = async (agencyId: string, currentStatus: number) => {
|
||||
const newStatus = currentStatus ? 0 : 1;
|
||||
@@ -79,7 +72,11 @@ const AgencyMaster = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const managepost = localData?.map((agency: any, index: number) => ({
|
||||
const filteredData = localData?.filter((agency) =>
|
||||
agency?.name.toLowerCase().includes(searchTerm.toLowerCase())
|
||||
);
|
||||
|
||||
const managepost = filteredData?.map((agency: any, index: number) => ({
|
||||
'id': agency.id,
|
||||
"Sr. No": index + 1,
|
||||
"Agency Name": agency.name,
|
||||
@@ -92,14 +89,14 @@ const AgencyMaster = () => {
|
||||
"is_active": agency.is_active,
|
||||
"Action": (
|
||||
<HStack justifyContent="center">
|
||||
<ViewAgencyMaster agency={localData} id={agency.id}/>
|
||||
<EditAgencyMaster />
|
||||
<ViewAgencyMaster agency={localData} id={agency.id} />
|
||||
{/* <EditAgencyMaster editData={{ id: agency.id, name: agency.name, domain_name: agency.domain_name, gst_number: agency.gst_number, rc_number: agency.rc_number, rc_status: agency.rc_status, registered_office: agency.registered_office, state: agency.state }} refetch={refetch} /> */}
|
||||
<Box>
|
||||
<Switch
|
||||
colorPalette={"teal"}
|
||||
size={"xs"}
|
||||
onChange={() => handleToggle(agency.id, agency.is_active ?? 0)}
|
||||
checked={agency.is_active}
|
||||
onChange={() => handleToggle(agency.id.toString(), Number(agency.is_active))}
|
||||
checked={Boolean(Number(agency.is_active))}
|
||||
/>
|
||||
</Box>
|
||||
</HStack>
|
||||
@@ -107,11 +104,17 @@ const AgencyMaster = () => {
|
||||
}));
|
||||
|
||||
useEffect(() => {
|
||||
console.log("Fetched data:", data);
|
||||
console.log("Local data:", localData);
|
||||
console.log("Managepost data:", managepost);
|
||||
if (data?.data?.data) {
|
||||
setLocalData(data?.data?.data);
|
||||
}
|
||||
}, [data, localData, managepost]);
|
||||
|
||||
// useEffect(() => {
|
||||
// console.log("Fetched data:", data);
|
||||
// console.log("Local data:", localData);
|
||||
// console.log("Managepost data:", managepost);
|
||||
// }, [data, localData, managepost]);
|
||||
|
||||
return (
|
||||
|
||||
<MainFrame>
|
||||
@@ -128,7 +131,7 @@ const AgencyMaster = () => {
|
||||
</Text>
|
||||
|
||||
<HStack >
|
||||
<InputGroup
|
||||
{/* <InputGroup
|
||||
startElement={
|
||||
<LuSearch fontSize={"xs"} style={{ position: 'relative', left: '10px' }} />
|
||||
}
|
||||
@@ -147,16 +150,19 @@ const AgencyMaster = () => {
|
||||
bgColor={'#EEEEEE'}
|
||||
ps={8}
|
||||
/>
|
||||
</InputGroup>
|
||||
{/* <Button bgColor={'#EEEEEE'} pl={3} pr={3}><IoMdAdd /> <Text>Add</Text></Button> */}
|
||||
<ViewAgencyAddModel />
|
||||
</InputGroup> */}
|
||||
<SearchComponent
|
||||
value={searchTerm}
|
||||
onChange={setSearchTerm}
|
||||
/>
|
||||
{/* <ViewAgencyAddModel refetch={refetch} /> */}
|
||||
</HStack>
|
||||
</HStack>
|
||||
<DataTable
|
||||
sortableColumns={["Name", "Registration Date "]}
|
||||
tableHeadRow={tableHeadRow}
|
||||
data={managepost || []}
|
||||
paginationData={data?.data}
|
||||
paginationData={data?.data.data}
|
||||
refetch={refetch}
|
||||
/>
|
||||
</Box>
|
||||
|
||||
@@ -9,14 +9,116 @@ import {
|
||||
DialogTitle,
|
||||
DialogTrigger,
|
||||
} from "../../../components/ui/dialog";
|
||||
import { Field, Input, Span, Stack } from "@chakra-ui/react";
|
||||
import { Field, Input, Stack } from "@chakra-ui/react";
|
||||
import Edit from "../../../components/ActionIcons/Edit";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useUpdateAgencyMasterMutation } from "../../../Redux/Service/agency.master.module.service";
|
||||
import { Toaster, toaster } from "../../../components/ui/toaster";
|
||||
|
||||
interface Organization {
|
||||
id: number;
|
||||
raid?: string;
|
||||
name: string;
|
||||
auth_signatory?: string;
|
||||
state: string;
|
||||
district?: string;
|
||||
rc_number: number;
|
||||
contact_details?: string;
|
||||
registered_office: string;
|
||||
branch_office?: string;
|
||||
registered_email?: string;
|
||||
other_email?: string;
|
||||
registered_contact?: string;
|
||||
website?: string;
|
||||
domain_name: string;
|
||||
staff_domain_name?: string;
|
||||
gst_number: string;
|
||||
rc_status?: "Active" | "Inactive"; // Assuming it's a status with limited values
|
||||
}
|
||||
|
||||
|
||||
function EditAgencyMaster({ editData, refetch }: { editData: Organization, refetch: VoidFunction }) {
|
||||
|
||||
const [formData, setFormData] = useState(editData);
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
const [updateAgencyMaster] = useUpdateAgencyMasterMutation()
|
||||
|
||||
useEffect(() => {
|
||||
setFormData(editData);
|
||||
}, [editData]);
|
||||
|
||||
const handleOpenModal = () => {
|
||||
setIsOpen(true);
|
||||
};
|
||||
|
||||
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const { name, value } = e.target;
|
||||
setFormData((prev: any) => ({
|
||||
...prev,
|
||||
[name]: value,
|
||||
}));
|
||||
}
|
||||
|
||||
const handleSubmit = async () => {
|
||||
// console.log("Updated Data:", formData);
|
||||
if (!formData.name.trim() ||
|
||||
!formData.rc_number ||
|
||||
!formData.state.trim() ||
|
||||
!formData.registered_office.trim() ||
|
||||
!formData.domain_name.trim() ||
|
||||
!formData.gst_number.trim()) {
|
||||
// console.log("Validation failed: Some fields are empty.");
|
||||
toaster.create({
|
||||
title: "Error",
|
||||
description: "Input fields cannot be empty",
|
||||
type: "error",
|
||||
});
|
||||
return;
|
||||
}
|
||||
setIsOpen(false);
|
||||
// Handle API call or further processing here
|
||||
const payload = {
|
||||
id: formData?.id,
|
||||
name: formData?.name,
|
||||
state: formData?.state,
|
||||
rc_number: formData?.rc_number,
|
||||
registered_office: formData?.registered_office,
|
||||
domain_name: formData?.domain_name,
|
||||
gst_number:formData?.gst_number,
|
||||
};
|
||||
|
||||
try {
|
||||
const response = await updateAgencyMaster(payload).unwrap();
|
||||
if (response?.status === "success") {
|
||||
toaster.create({
|
||||
title: "Success",
|
||||
description: "Data updated successfully",
|
||||
type: "success",
|
||||
});
|
||||
refetch()
|
||||
setIsOpen(false);
|
||||
} else {
|
||||
toaster.create({
|
||||
title: "Error",
|
||||
description: "Failed to update",
|
||||
type: "error",
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error updating template:", error);
|
||||
toaster.create({
|
||||
title: "Error",
|
||||
description: "Something went wrong.",
|
||||
type: "error",
|
||||
});
|
||||
// alert("Failed to update template");
|
||||
}
|
||||
};
|
||||
|
||||
function EditAgencyMaster() {
|
||||
return (
|
||||
<DialogRoot placement="center">
|
||||
<DialogRoot placement="center" open={isOpen} onOpenChange={({ open }) => setIsOpen(open)}>
|
||||
<DialogTrigger asChild>
|
||||
<Span><Edit /></Span>
|
||||
<Button bg="transparent" color={"black"} h={"18px"} onClick={handleOpenModal}><Edit /></Button>
|
||||
</DialogTrigger>
|
||||
|
||||
<DialogContent
|
||||
@@ -42,92 +144,105 @@ function EditAgencyMaster() {
|
||||
Agency name
|
||||
</Field.Label>
|
||||
<Input
|
||||
value="Lorem Ipsum"
|
||||
name="name"
|
||||
value={formData?.name}
|
||||
bgColor="#EEEEEE"
|
||||
color="black"
|
||||
border="none"
|
||||
pl={1}
|
||||
fontSize="12px"
|
||||
height="30px"
|
||||
onChange={handleChange}
|
||||
/>
|
||||
|
||||
<Field.Label color="black" pt={1} fontSize="12px">
|
||||
RC No.
|
||||
</Field.Label>
|
||||
<Input
|
||||
value="Lorem Ipsum"
|
||||
name='rc_number'
|
||||
value={formData.rc_number}
|
||||
bgColor="#EEEEEE"
|
||||
color="black"
|
||||
border="none"
|
||||
pl={1}
|
||||
fontSize="12px"
|
||||
height="30px"
|
||||
onChange={handleChange}
|
||||
/>
|
||||
|
||||
<Field.Label color="black" pt={1} fontSize="12px">
|
||||
State
|
||||
</Field.Label>
|
||||
<Input
|
||||
value="Lorem Ipsum"
|
||||
name="state"
|
||||
value={formData.state}
|
||||
bgColor="#EEEEEE"
|
||||
color="black"
|
||||
border="none"
|
||||
pl={1}
|
||||
fontSize="12px"
|
||||
height="30px"
|
||||
onChange={handleChange}
|
||||
/>
|
||||
|
||||
<Field.Label color="black" pt={1} fontSize="12px">
|
||||
Registered Office Address
|
||||
</Field.Label>
|
||||
<Input
|
||||
value="Active"
|
||||
name="registered_office"
|
||||
value={formData.registered_office}
|
||||
bgColor="#EEEEEE"
|
||||
color="black"
|
||||
border="none"
|
||||
pl={1}
|
||||
fontSize="12px"
|
||||
height="30px"
|
||||
onChange={handleChange}
|
||||
/>
|
||||
|
||||
<Field.Label color="black" pt={1} fontSize="12px">
|
||||
Website/Domain
|
||||
</Field.Label>
|
||||
<Input
|
||||
value="Lorem Ipsum"
|
||||
name="domain_name"
|
||||
value={formData.domain_name}
|
||||
bgColor="#EEEEEE"
|
||||
color="black"
|
||||
border="none"
|
||||
pl={1}
|
||||
fontSize="12px"
|
||||
height="30px"
|
||||
onChange={handleChange}
|
||||
/>
|
||||
|
||||
<Field.Label color="black" pt={1} fontSize="12px">
|
||||
GST no.
|
||||
</Field.Label>
|
||||
<Input
|
||||
value="Lorem Ipsum"
|
||||
name="gst_number"
|
||||
value={formData.gst_number}
|
||||
bgColor="#EEEEEE"
|
||||
color="black"
|
||||
border="none"
|
||||
pl={1}
|
||||
fontSize="12px"
|
||||
height="30px"
|
||||
onChange={handleChange}
|
||||
/>
|
||||
|
||||
<Field.Label color="black" pt={1} fontSize="12px">
|
||||
Action
|
||||
{/* <Field.Label color="black" pt={1} fontSize="12px">
|
||||
RC Status
|
||||
</Field.Label>
|
||||
<Input
|
||||
value="Lorem Ipsum"
|
||||
value={formData.rc_status}
|
||||
bgColor="#EEEEEE"
|
||||
color="black"
|
||||
border="none"
|
||||
pl={1}
|
||||
fontSize="12px"
|
||||
height="30px"
|
||||
/>
|
||||
onChange={handleChange}
|
||||
/> */}
|
||||
</Field.Root>
|
||||
</Stack>
|
||||
</DialogBody>
|
||||
@@ -138,13 +253,15 @@ function EditAgencyMaster() {
|
||||
color={"#fff"}
|
||||
fontSize="12px"
|
||||
height="30px"
|
||||
onClick={handleSubmit}
|
||||
>
|
||||
Save
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
|
||||
<DialogCloseTrigger color="black" />
|
||||
<DialogCloseTrigger color="black" onClick={() => setIsOpen(false)} />
|
||||
</DialogContent>
|
||||
<Toaster />
|
||||
</DialogRoot>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,30 +2,99 @@ import { DialogBody, DialogCloseTrigger, DialogContent, DialogFooter, DialogHead
|
||||
import { Field, Input, Stack, Text } from "@chakra-ui/react"
|
||||
import { IoMdAdd } from "react-icons/io"
|
||||
import { Button } from "../../../components/ui/button"
|
||||
import { AgencyPost, useCreateAgencyMasterPostMutation } from "../../../Redux/Service/agency.master.module.service"
|
||||
import { useState } from "react"
|
||||
import { Toaster, toaster } from "../../../components/ui/toaster"
|
||||
|
||||
function ViewAgencyAddModel({ refetch }: { refetch: VoidFunction }) {
|
||||
const [formData, setFormData] = useState<AgencyPost>({
|
||||
name: "",
|
||||
rc_number: "",
|
||||
state: "",
|
||||
registered_office: "",
|
||||
domain_name: "",
|
||||
gst_number: "",
|
||||
});
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
const [createAgencyMasterPost] = useCreateAgencyMasterPostMutation()
|
||||
|
||||
const handleOpenModal = () => {
|
||||
setIsOpen(true); // Open modal when clicking "Add"
|
||||
};
|
||||
|
||||
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const { name, value } = e.target;
|
||||
setFormData((prev: any) => ({
|
||||
...prev,
|
||||
[name]: value,
|
||||
}));
|
||||
}
|
||||
|
||||
const handleSubmit = async () => {
|
||||
console.log("New Data:", formData);
|
||||
const requiredFields: (keyof AgencyPost)[] = ["name", "rc_number", "state", "registered_office", "domain_name", "gst_number"];
|
||||
const isEmptyField = requiredFields.some(field => !formData[field]?.trim());
|
||||
|
||||
if (isEmptyField) {
|
||||
console.log("Validation failed: Some fields are empty.");
|
||||
toaster.create({
|
||||
title: "Error",
|
||||
description: "All required fields must be filled.",
|
||||
type: "error",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const payload = {
|
||||
name: formData.name
|
||||
};
|
||||
|
||||
try {
|
||||
const response = await createAgencyMasterPost(payload).unwrap();
|
||||
if (response) {
|
||||
toaster.create({
|
||||
title: "Success",
|
||||
description: "Added successfully",
|
||||
type: "success",
|
||||
});
|
||||
refetch()
|
||||
setIsOpen(false);
|
||||
} else {
|
||||
toaster.create({
|
||||
title: "Error",
|
||||
description: "Failed to add data.",
|
||||
type: "error",
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error updating template:", error);
|
||||
toaster.create({
|
||||
title: "Error",
|
||||
description: "Something went wrong",
|
||||
type: "error",
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
function ViewAgencyAddModel() {
|
||||
return (
|
||||
|
||||
<DialogRoot placement="center">
|
||||
<DialogRoot placement="center" open={isOpen} onOpenChange={({ open }) => setIsOpen(open)}>
|
||||
<DialogTrigger asChild>
|
||||
{/* <Button bg={"transparent"} size="sm">
|
||||
<MdOutlineRemoveRedEye style={{ cursor: "pointer", fontSize: "16px" }} />
|
||||
</Button> */}
|
||||
<Button px={5} size={"xs"} bg={"#02A0A0"}>
|
||||
<IoMdAdd /> <Text >Add</Text>
|
||||
<Button px={5} size={"xs"} bg={"#02A0A0"} onClick={handleOpenModal}>
|
||||
<IoMdAdd /> <Text >Add</Text>
|
||||
</Button>
|
||||
|
||||
</DialogTrigger>
|
||||
|
||||
<DialogContent
|
||||
bg={"#fff"}
|
||||
// w={{ lg: "60%", md: "230px" }}
|
||||
w={{ base: '90%', md: '400px' }}
|
||||
height={'80vh'}
|
||||
overflow={'scroll'}
|
||||
overflowX="hidden"
|
||||
p={3} // Reduced padding
|
||||
bgSize={'md'}
|
||||
bg={"#fff"}
|
||||
// w={{ lg: "60%", md: "230px" }}
|
||||
w={{ base: '90%', md: '400px' }}
|
||||
height={'80vh'}
|
||||
overflow={'scroll'}
|
||||
overflowX="hidden"
|
||||
p={3} // Reduced padding
|
||||
bgSize={'md'}
|
||||
>
|
||||
<DialogHeader bg="white" >
|
||||
<DialogTitle alignSelf="center" color="black" fontSize="14px">Add</DialogTitle>
|
||||
@@ -36,38 +105,97 @@ function ViewAgencyAddModel() {
|
||||
|
||||
<Field.Root>
|
||||
<Field.Label color="black" pt={1} fontSize="12px">Agency Name</Field.Label>
|
||||
<Input placeholder="" bgColor="#EEEEEE" color="black" border="none" pl={1} fontSize="12px" height="30px" />
|
||||
<Input
|
||||
name="name"
|
||||
value={formData.name}
|
||||
bgColor="#EEEEEE"
|
||||
color="black"
|
||||
border="none"
|
||||
pl={1}
|
||||
fontSize="12px"
|
||||
height="30px"
|
||||
onChange={handleChange}
|
||||
/>
|
||||
|
||||
<Field.Label color="black" pt={1} fontSize="12px">RC No.</Field.Label>
|
||||
<Input placeholder="" bgColor="#EEEEEE" color="black" border="none" pl={1} fontSize="12px" height="30px" />
|
||||
<Input
|
||||
name='rc_number'
|
||||
value={formData.rc_number}
|
||||
bgColor="#EEEEEE"
|
||||
color="black"
|
||||
border="none"
|
||||
pl={1}
|
||||
fontSize="12px"
|
||||
height="30px"
|
||||
onChange={handleChange}
|
||||
/>
|
||||
|
||||
<Field.Label color="black" pt={1} fontSize="12px">State</Field.Label>
|
||||
<Input placeholder="" bgColor="#EEEEEE" color="black" border="none" pl={1} fontSize="12px" height="30px" />
|
||||
<Input
|
||||
name="state"
|
||||
value={formData.state}
|
||||
bgColor="#EEEEEE"
|
||||
color="black"
|
||||
border="none"
|
||||
pl={1}
|
||||
fontSize="12px"
|
||||
height="30px"
|
||||
onChange={handleChange}
|
||||
/>
|
||||
|
||||
<Field.Label color="black" pt={1} fontSize="12px">Registered Office Address</Field.Label>
|
||||
<Input placeholder="" bgColor="#EEEEEE" color="black" border="none" pl={1} fontSize="12px" height="30px" />
|
||||
<Input
|
||||
name="registered_office"
|
||||
value={formData.registered_office}
|
||||
bgColor="#EEEEEE"
|
||||
color="black"
|
||||
border="none"
|
||||
pl={1}
|
||||
fontSize="12px"
|
||||
height="30px"
|
||||
onChange={handleChange}
|
||||
/>
|
||||
|
||||
<Field.Label color="black" pt={1} fontSize="12px">Website/Domain</Field.Label>
|
||||
<Input placeholder="" bgColor="#EEEEEE" color="black" border="none" pl={1} fontSize="12px" height="30px" />
|
||||
<Input
|
||||
name="domain_name"
|
||||
value={formData.domain_name}
|
||||
bgColor="#EEEEEE"
|
||||
color="black"
|
||||
border="none"
|
||||
pl={1}
|
||||
fontSize="12px"
|
||||
height="30px"
|
||||
onChange={handleChange}
|
||||
/>
|
||||
|
||||
<Field.Label color="black" pt={1} fontSize="12px">GST no.</Field.Label>
|
||||
<Input placeholder="" bgColor="#EEEEEE" color="black" border="none" pl={1} fontSize="12px" height="30px" />
|
||||
|
||||
<Field.Label color="black" pt={1} fontSize="12px">Action</Field.Label>
|
||||
<Input placeholder="" bgColor="#EEEEEE" color="black" border="none" pl={1} fontSize="12px" height="30px" />
|
||||
|
||||
<Input
|
||||
name="gst_number"
|
||||
value={formData.gst_number}
|
||||
bgColor="#EEEEEE"
|
||||
color="black"
|
||||
border="none"
|
||||
pl={1}
|
||||
fontSize="12px"
|
||||
height="30px"
|
||||
onChange={handleChange}
|
||||
/>
|
||||
|
||||
{/* <Field.Label color="black" pt={1} fontSize="12px">Action</Field.Label>
|
||||
<Input placeholder="" bgColor="#EEEEEE" color="black" border="none" pl={1} fontSize="12px" height="30px" /> */}
|
||||
</Field.Root>
|
||||
</Stack>
|
||||
</DialogBody>
|
||||
<DialogFooter display="flex" justifyContent="center" pt={"2"}>
|
||||
<Button w="100%" bg="#02A0A0" color={"#fff"}>
|
||||
<Button w="100%" bg="#02A0A0" color={"#fff"} onClick={handleSubmit}>
|
||||
Save
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
|
||||
<DialogCloseTrigger color="black" />
|
||||
<DialogCloseTrigger color="black" onClick={() => setIsOpen(false)} />
|
||||
</DialogContent>
|
||||
<Toaster />
|
||||
</DialogRoot >
|
||||
|
||||
)
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { Box, HStack, Image, Input, Text } from "@chakra-ui/react";
|
||||
import { Box, HStack, Image, Text } from "@chakra-ui/react";
|
||||
import MainFrame from "../../../components/MainFrame"
|
||||
import { InputGroup } from "../../../components/ui/input-group";
|
||||
import { LuSearch } from "react-icons/lu";
|
||||
import DataTable from "../../../components/DataTable";
|
||||
import { Switch } from "../../../components/ui/switch";
|
||||
// import img from "../../../assets/waterfall.jpg"
|
||||
@@ -10,6 +8,7 @@ import TemplateAddModel from "./TemplateAddModel";
|
||||
import EditTemplateModel from "./EditTemplateModel";
|
||||
import { Template, useGetTemplateMasterQuery, useTemplateMasterToggleMutation } from "../../../Redux/Service/template.master.service";
|
||||
import { useEffect, useState } from "react";
|
||||
import SearchComponent from "../../../components/SearchComponent";
|
||||
|
||||
const APIURL = import.meta.env.VITE_IMG_TEMPLATES
|
||||
|
||||
@@ -48,7 +47,8 @@ const tableHeadRow = [
|
||||
const TemplateMaster = () => {
|
||||
const { data, refetch } = useGetTemplateMasterQuery()
|
||||
const [localData, setLocalData] = useState<any[]>([]);
|
||||
const [templateMasterToggle] = useTemplateMasterToggleMutation()
|
||||
const [templateMasterToggle] = useTemplateMasterToggleMutation();
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
console.log('DATA', data?.data.data);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -77,7 +77,11 @@ const TemplateMaster = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const managepost = localData?.map((agency: Template, index: number) => ({
|
||||
const filteredData = localData?.filter((agency) =>
|
||||
agency.post_template_translate[0].title.toLowerCase().includes(searchTerm.toLowerCase())
|
||||
);
|
||||
|
||||
const managepost = filteredData?.map((agency: Template, index: number) => ({
|
||||
'id': agency.id,
|
||||
"Sr. No": index + 1,
|
||||
"Title": agency.post_template_translate.length > 0
|
||||
@@ -85,7 +89,7 @@ const TemplateMaster = () => {
|
||||
: "N/A",
|
||||
"Images": (
|
||||
// <Image w={50} src={img} />
|
||||
<HStack >
|
||||
<HStack key={agency.id}>
|
||||
{agency.post_template_image.map((img) => (
|
||||
<Image rounded={'lg'} w={100} h={50} src={`${APIURL}${img.image_name}`} />
|
||||
))}
|
||||
@@ -125,7 +129,7 @@ const TemplateMaster = () => {
|
||||
</Text>
|
||||
|
||||
<HStack >
|
||||
<InputGroup
|
||||
{/* <InputGroup
|
||||
startElement={
|
||||
<LuSearch fontSize={"xs"} style={{ position: 'relative', left: '10px' }} />
|
||||
}
|
||||
@@ -144,16 +148,19 @@ const TemplateMaster = () => {
|
||||
bgColor={'#EEEEEE'}
|
||||
ps={8}
|
||||
/>
|
||||
</InputGroup>
|
||||
{/* <Button bgColor={'#EEEEEE'} pl={3} pr={3}><IoMdAdd /> <Text>Add</Text></Button> */}
|
||||
<TemplateAddModel refetch={refetch}/>
|
||||
</InputGroup> */}
|
||||
<SearchComponent
|
||||
value={searchTerm}
|
||||
onChange={setSearchTerm}
|
||||
/>
|
||||
<TemplateAddModel refetch={refetch} />
|
||||
</HStack>
|
||||
</HStack>
|
||||
<DataTable
|
||||
sortableColumns={["Name", "Registration Date "]}
|
||||
tableHeadRow={tableHeadRow}
|
||||
data={managepost}
|
||||
paginationData={data?.data}
|
||||
paginationData={data?.data.data}
|
||||
refetch={refetch}
|
||||
/>
|
||||
</Box>
|
||||
|
||||
@@ -10,7 +10,7 @@ export interface Agency {
|
||||
domain_name: string;
|
||||
gst_number: string;
|
||||
is_active: boolean,
|
||||
registered_office:string,
|
||||
registered_office: string,
|
||||
}
|
||||
|
||||
export interface AgencyData {
|
||||
@@ -36,15 +36,43 @@ export interface UpdatePrivacyPolicyPayload {
|
||||
is_active: boolean,
|
||||
}
|
||||
|
||||
export interface AgencyPost {
|
||||
raid?: string;
|
||||
name: string;
|
||||
auth_signatory?: string;
|
||||
state: string;
|
||||
district?: string;
|
||||
rc_number: string;
|
||||
contact_details?: string;
|
||||
registered_office: string;
|
||||
branch_office?: string;
|
||||
registered_email?: string;
|
||||
other_email?: string;
|
||||
registered_contact?: string;
|
||||
website?: string;
|
||||
domain_name: string;
|
||||
staff_domain_name?: string;
|
||||
gst_number: string;
|
||||
rc_status?: "Active" | "Inactive"; // Assuming it's a status with limited values
|
||||
}
|
||||
|
||||
|
||||
export const agencyMasterModule = createApi({
|
||||
reducerPath: "agencyMasterModule",
|
||||
baseQuery: baseQueryWithReauth, // Use enhanced baseQuery with error handling
|
||||
endpoints: (builder) => ({
|
||||
|
||||
createAgencyMasterPost: builder.mutation<AgencyPost, Partial<AgencyPost>>({
|
||||
query: (data) => ({
|
||||
url: "/agency-store",
|
||||
method: "POST",
|
||||
body: data,
|
||||
}),
|
||||
}),
|
||||
|
||||
|
||||
getAgencyMaster: builder.query<AgencyResponse, void>({ query: () => "/agency-master" }),
|
||||
getAgencyMaster: builder.query<AgencyResponse, void>({
|
||||
query: () => "/agency-master"
|
||||
}),
|
||||
|
||||
agencyMasterToggle: builder.mutation({
|
||||
query: ({ id, is_active }) => ({
|
||||
@@ -54,7 +82,20 @@ export const agencyMasterModule = createApi({
|
||||
}),
|
||||
}),
|
||||
|
||||
updateAgencyMaster: builder.mutation({
|
||||
query: (updatedData) => ({
|
||||
url: "/agency-update",
|
||||
method: "POST",
|
||||
body: updatedData,
|
||||
}),
|
||||
}),
|
||||
|
||||
}),
|
||||
});
|
||||
|
||||
export const { useGetAgencyMasterQuery, useAgencyMasterToggleMutation } = agencyMasterModule;
|
||||
export const {
|
||||
useCreateAgencyMasterPostMutation,
|
||||
useGetAgencyMasterQuery,
|
||||
useAgencyMasterToggleMutation,
|
||||
useUpdateAgencyMasterMutation,
|
||||
} = agencyMasterModule;
|
||||
|
||||
@@ -1,29 +1,15 @@
|
||||
|
||||
import { Text } from '@chakra-ui/react';
|
||||
import { Center, Heading, Stack, Text } from '@chakra-ui/react';
|
||||
|
||||
import { ReactNode } from 'react';
|
||||
|
||||
interface NoDataProps {
|
||||
children: ReactNode;
|
||||
data: any;
|
||||
error: any;
|
||||
isLoading: boolean;
|
||||
}
|
||||
|
||||
const NoData = ({ children, data, error, isLoading }: NoDataProps) => {
|
||||
if (isLoading) {
|
||||
return <p>Loading...</p>; // Show a loading spinner or skeleton
|
||||
}
|
||||
|
||||
if (error) {
|
||||
return <Text>Something went wrong, Try again later.</Text>;
|
||||
}
|
||||
|
||||
if (!data || (Array.isArray(data) && data.length === 0)) {
|
||||
return <Text>No data found</Text>;
|
||||
}
|
||||
|
||||
return children;
|
||||
const NoData = () => {
|
||||
return (
|
||||
<Center h="80vh" textAlign="center">
|
||||
<Stack gap={6}>
|
||||
<Heading fontSize="xl">No data found</Heading>
|
||||
<Text fontSize="sm">Please add new data</Text>
|
||||
</Stack>
|
||||
</Center>
|
||||
)
|
||||
};
|
||||
|
||||
export default NoData;
|
||||
Reference in New Issue
Block a user