Bug fixes and updates
This commit is contained in:
@@ -113,6 +113,7 @@ const AgencyMaster = () => {
|
||||
Action: (
|
||||
<HStack justifyContent="center">
|
||||
<ViewAgencyMaster agency={localData} id={agency.id} />
|
||||
{/* <EditAgencyMaster editData={agency} refetch={refetch} /> */}
|
||||
<Box>
|
||||
<Switch
|
||||
colorPalette={"teal"}
|
||||
|
||||
@@ -15,34 +15,47 @@ 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;
|
||||
// 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
|
||||
// }
|
||||
|
||||
type AgencyFormData = {
|
||||
id: string;
|
||||
name: string;
|
||||
auth_signatory?: string;
|
||||
state: string;
|
||||
district?: string;
|
||||
rc_number: number;
|
||||
contact_details?: string;
|
||||
rc_number: 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 }) {
|
||||
|
||||
function EditAgencyMaster<T extends AgencyFormData>({ editData, refetch }: { editData: T, refetch: VoidFunction }) {
|
||||
|
||||
const [formData, setFormData] = useState(editData);
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
const [updateAgencyMaster] = useUpdateAgencyMasterMutation()
|
||||
|
||||
console.log("Edit Data", editData);
|
||||
|
||||
useEffect(() => {
|
||||
setFormData(editData);
|
||||
}, [editData]);
|
||||
@@ -104,11 +117,11 @@ function EditAgencyMaster({ editData, refetch }: { editData: Organization, refet
|
||||
type: "error",
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
console.error("Error updating template:", error);
|
||||
toaster.create({
|
||||
title: "Error",
|
||||
description: "Something went wrong.",
|
||||
description: `${error.data.message || "Failed to update"}`,
|
||||
type: "error",
|
||||
});
|
||||
// alert("Failed to update template");
|
||||
|
||||
@@ -6,7 +6,7 @@ import DataTable from "../../../components/DataTable";
|
||||
import { Switch } from "../../../components/ui/switch";
|
||||
import JobAddModel from "./JobAddModel";
|
||||
import EditJobeModel from "./EditJobModel";
|
||||
import { JobTypeData, useGetJobTypeQuery } from "../../../Redux/Service/job.type.service";
|
||||
import { JobTypeData, useGetJobTypeQuery, useJobTypeToggleMutation } from "../../../Redux/Service/job.type.service";
|
||||
import { useEffect, useState } from "react";
|
||||
import SearchComponent from "../../../components/SearchComponent";
|
||||
|
||||
@@ -41,7 +41,7 @@ const JobType = () => {
|
||||
const { data, refetch } = useGetJobTypeQuery(currentPage)
|
||||
const [localData, setLocalData] = useState<any[]>([]);
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
// const [templateMasterToggle] = useTemplateMasterToggleMutation()
|
||||
const [jobTypeToggle] = useJobTypeToggleMutation()
|
||||
console.log('DATA', data?.data.data);
|
||||
|
||||
|
||||
@@ -61,25 +61,25 @@ const JobType = () => {
|
||||
return title;
|
||||
});
|
||||
|
||||
// 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 templateMasterToggle({ id: agencyId, is_active: newStatus }).unwrap();
|
||||
// refetch()
|
||||
// } catch (error) {
|
||||
// console.error("Error updating privacy policy:", error);
|
||||
// setLocalData((prevData) =>
|
||||
// prevData.map((agency) =>
|
||||
// agency.id === agencyId ? { ...agency, is_active: currentStatus } : agency
|
||||
// )
|
||||
// );
|
||||
// }
|
||||
// };
|
||||
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 jobTypeToggle({ id: agencyId, is_active: newStatus }).unwrap();
|
||||
refetch()
|
||||
} catch (error) {
|
||||
console.error("Error updating privacy policy:", error);
|
||||
setLocalData((prevData) =>
|
||||
prevData.map((agency) =>
|
||||
agency.id === agencyId ? { ...agency, is_active: currentStatus } : agency
|
||||
)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const managepost = filteredData?.map((agency: JobTypeData, index: number) => ({
|
||||
@@ -94,7 +94,7 @@ const JobType = () => {
|
||||
<Switch
|
||||
colorPalette={'teal'}
|
||||
size={"xs"}
|
||||
// onChange={() => handleToggle(agency.id, Number(agency.is_active))}
|
||||
onChange={() => handleToggle(agency.id.toString(), Number(agency.is_active))}
|
||||
checked={Boolean(Number(agency.is_active))}
|
||||
/>
|
||||
</Box>
|
||||
|
||||
Reference in New Issue
Block a user