From f2d101ef16ac0b611467f8817037613d8dafc669 Mon Sep 17 00:00:00 2001 From: rockyeverlast Date: Thu, 3 Jul 2025 16:08:52 +0530 Subject: [PATCH] Bug fixes --- .../AgencyMaster/AgencyMaster.tsx | 66 +++++++++++-------- .../MasterModule/Country/CountryAddModel.tsx | 32 ++++++--- .../TemplateMaster/EditTemplateModel.tsx | 18 ++--- .../TemplateMaster/TemplateAddModel.tsx | 18 +++-- .../TemplateMaster/TemplateMaster.tsx | 4 +- .../WorkspaceMode/WorkspaceMode.tsx | 4 +- src/Redux/Service/template.master.service.ts | 1 + src/Redux/Service/workspace.mode.ts | 2 +- src/components/DataTable.tsx | 2 +- 9 files changed, 95 insertions(+), 52 deletions(-) diff --git a/src/Pages/MasterModule/AgencyMaster/AgencyMaster.tsx b/src/Pages/MasterModule/AgencyMaster/AgencyMaster.tsx index c0a82ce..defaf14 100644 --- a/src/Pages/MasterModule/AgencyMaster/AgencyMaster.tsx +++ b/src/Pages/MasterModule/AgencyMaster/AgencyMaster.tsx @@ -78,35 +78,47 @@ const AgencyMaster = () => { }; const filteredData = localData?.filter((agency) => - agency?.name.toLowerCase().includes(searchTerm.toLowerCase()) + agency?.name.toLowerCase().includes(searchTerm.toLowerCase()) || + agency?.rc_number.toLowerCase().includes(searchTerm.toLowerCase()) || + agency?.state.toLowerCase().includes(searchTerm.toLowerCase()) || + agency?.registered_office.toLowerCase().includes(searchTerm.toLowerCase()) || + agency?.domain_name.toLowerCase().includes(searchTerm.toLowerCase()) || + agency?.gst_number.toLowerCase().includes(searchTerm.toLowerCase()) ); - const managepost = filteredData?.map((agency: any, index: number) => ({ - 'id': agency.id, - "Sr. No": (currentPage - 1) * (data?.data.per_page ?? 0) + index + 1, - "Agency Name": agency.name, - "RC no.": agency.rc_number, - "State": agency.state, - "RC Status": agency.rc_status, - "Registered Office Address": agency.registered_office, - "Website/Domain": agency.domain_name, - "GST no.": agency.gst_number, - "is_active": agency.is_active, - "Action": ( - - - {/* */} - - handleToggle(agency.id.toString(), Number(agency.is_active))} - checked={Boolean(Number(agency.is_active))} - /> - - - ), - })); + const activeCount = filteredData?.filter((a: any) => a.is_active === 1).length ?? 0; + + const managepost = filteredData?.map((agency: any, index: number) => { + const isOnlyActive = activeCount === 1 && agency.is_active === 1; + + return { + id: agency.id, + "Sr. No": (currentPage - 1) * (data?.data.per_page ?? 0) + index + 1, + "Agency Name": agency.name, + "RC no.": agency.rc_number, + "State": agency.state, + "RC Status": agency.rc_status, + "Registered Office Address": agency.registered_office, + "Website/Domain": agency.domain_name, + "GST no.": agency.gst_number, + "is_active": agency.is_active, + Action: ( + + + + handleToggle(agency.id.toString(), Number(agency.is_active))} + checked={Boolean(Number(agency.is_active))} + disabled={isOnlyActive} + /> + + + ), + }; + }); + useEffect(() => { if (data?.data?.data) { diff --git a/src/Pages/MasterModule/Country/CountryAddModel.tsx b/src/Pages/MasterModule/Country/CountryAddModel.tsx index b2a7834..3f0dc77 100644 --- a/src/Pages/MasterModule/Country/CountryAddModel.tsx +++ b/src/Pages/MasterModule/Country/CountryAddModel.tsx @@ -2,7 +2,7 @@ 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 { useState } from "react"; +import { useEffect, useState } from "react"; import { PostCountry, useCreateCountryPostMutation } from "../../../Redux/Service/country.master"; import { Toaster, toaster } from "../../../components/ui/toaster"; @@ -19,12 +19,26 @@ function CountryAddModel() { currency_symbol: '', }); + useEffect(() => { + if (!isOpen) { + setCountryName({ + en_name: '', + country_code: '', + phonecode: '', + capital: '', + currency: '', + currency_name: '', + currency_symbol: '', + }); + } + }, [isOpen]); + const handleOpenModal = () => { setIsOpen(true); // Open modal when clicking "Add" }; const handleSubmit = async () => { - if (countryName.en_name === "") { + if (countryName.en_name === "" || countryName.country_code === "" || countryName.phonecode === "" || countryName.capital === "" || countryName.currency === "" || countryName.currency_name === "" || countryName.currency_symbol === "") { toaster.create({ title: "Error", description: "Input fields cannot be empty", @@ -98,7 +112,7 @@ function CountryAddModel() { Country Country Code Phone Code Capital Currency Currency name Currency Symbol ([]); // Store object URLs separately // const [updateTemplateMaster] = useUpdateTemplateMasterMutation() const [isOpen, setIsOpen] = useState(false); - const [selectedTemplate, setSelectedTemplate] = useState