diff --git a/src/Pages/Admin/Contact.jsx b/src/Pages/Admin/Contact.jsx
index d83021b..e2fe28c 100644
--- a/src/Pages/Admin/Contact.jsx
+++ b/src/Pages/Admin/Contact.jsx
@@ -1,4 +1,4 @@
-import React, { useContext, useState } from "react";
+import React, { useContext, useEffect, useState } from "react";
import {
Box,
Divider,
@@ -20,11 +20,12 @@ import GlobalStateContext from "../../Contexts/GlobalStateContext";
import { OPACITY_ON_LOAD } from "../../Layout/animations";
import FormInputMain from "../../Components/FormInputMain";
import { useGetContactQuery } from "../../Services/contact.service";
+import FullscreenLoaders from "../../Components/Loaders/FullscreenLoaders";
export const addSponser = yup.object().shape({
phoneNumber: yup.string().required("Phone Number is required"),
- emailAddress: yup.string().required("E-mail ID is required"),
- websiteUrl: yup.string().required("Website URL is required"),
+ emailAddress: yup.string().required("E-mail ID is required"),
+ websiteUrl: yup.string().required("Website URL is required"),
});
export function debounce(func, delay) {
@@ -37,11 +38,12 @@ export function debounce(func, delay) {
const Contact = () => {
const navigate = useNavigate();
+ const [form, setForm] = useState({});
- const { sponser, setSponser } = useContext(GlobalStateContext);
+ // const { sponser, setSponser } = useContext(GlobalStateContext);
const {
control,
-
+ reset,
handleSubmit,
formState: { errors },
} = useForm({
@@ -50,7 +52,6 @@ const Contact = () => {
console.log(errors);
-
const {
data: contact,
isLoading: contactLoading,
@@ -59,30 +60,47 @@ const Contact = () => {
console.log(contact?.data);
+ useEffect(() => {
+ if (contact) {
+ reset({
+ phoneNumber: contact.phoneNumber,
+ emailAddress: contact.emailAddress,
+ websiteUrl: contact.websiteUrl,
+ });
+ }
+ }, [contact, reset]);
+
+ if (contactLoading) {
+ return ;
+ }
+
const formFields = [
{
label: "Phone Number",
- placeHolder:" ",
+ placeHolder: " ",
name: "phoneNumber",
type: "text",
isRequired: true,
section: "Add Details",
+ defaultValue: contact?.phoneNumber || "",
},
{
- label: "E-mail ID ",
+ label: "E-mail ID",
name: "emailAddress",
- placeHolder:" ",
+ placeHolder: " ",
type: "text",
isRequired: true,
section: "Add Details",
+ defaultValue: contact?.emailAddress || "",
},
{
label: "Website URL",
name: "websiteUrl",
- placeHolder:" ",
+ placeHolder: " ",
type: "text",
isRequired: true,
section: "Add Details",
+ defaultValue: contact?.websiteUrl || "",
},
];
@@ -96,16 +114,10 @@ const Contact = () => {
}, {});
const onSubmit = (data) => {
- setSponser([
- {
- ...data,
- status: true,
- id: uuidv4(),
- createdAt: new Date().toISOString(),
- },
- ...sponser,
- ]);
- navigate("/sponser");
+ if (!Object.keys(errors).length) {
+ setForm(data);
+ setAlert(true);
+ }
};
return (
diff --git a/src/Pages/Master/InvestmentType/InvestmentType.jsx b/src/Pages/Master/InvestmentType/InvestmentType.jsx
index 4e32d95..314e0e4 100644
--- a/src/Pages/Master/InvestmentType/InvestmentType.jsx
+++ b/src/Pages/Master/InvestmentType/InvestmentType.jsx
@@ -1,15 +1,27 @@
-import {Badge,Box,Button,HStack,Input,Text,Tooltip,useToast,} from "@chakra-ui/react";
+import {
+ Badge,
+ Box,
+ Button,
+ HStack,
+ Input,
+ Text,
+ Tooltip,
+ useToast,
+} from "@chakra-ui/react";
import React, { useContext, useEffect, useState } from "react";
import { OPACITY_ON_LOAD } from "../../../Layout/animations";
import { Link, Link as RouterLink, useNavigate } from "react-router-dom";
-import {AddIcon,DeleteIcon,EditIcon,ViewIcon,} from "@chakra-ui/icons";
+import { AddIcon, DeleteIcon, EditIcon, ViewIcon } from "@chakra-ui/icons";
import Pagination from "../../../Components/Pagination";
import GlobalStateContext from "../../../Contexts/GlobalStateContext";
import CustomAlertDialog from "../../../Components/CustomAlertDialog";
import ToastBox from "../../../Components/ToastBox";
import { debounce } from "./AddInvestmentType";
import NormalTable from "../../../Components/DataTable/NormalTable";
-import {useDeleteInvestmentTypeMutation, useGetInvestmentTypesQuery,} from "../../../Services/investment.type.service";
+import {
+ useDeleteInvestmentTypeMutation,
+ useGetInvestmentTypesQuery,
+} from "../../../Services/investment.type.service";
import { TABLE_PAGINATION } from "../../../Constants/Paginations";
const formatDate = (date) => new Date(date).toLocaleDateString(); // Simple date formatter
@@ -28,19 +40,23 @@ const InvestmentType = () => {
const [mouseEnteredId, setMouseEnteredId] = useState("");
const [isSwitchOn, setIsSwitchOn] = useState(false);
const { investmentType, setInvestmentType, slideFromRight } =
- useContext(GlobalStateContext);
+ useContext(GlobalStateContext);
const [deleteInvestmentType] = useDeleteInvestmentTypeMutation();
- // =========================== [Use State] =============================
- const [pageSize, setPageSize] = useState(TABLE_PAGINATION?.size);
- const [currentPage, setCurrentPage] = useState(TABLE_PAGINATION?.page);
-
- const {data: investmentTypes,isLoading: investmentTypesLoading,error,} = useGetInvestmentTypesQuery({ page: currentPage, size: pageSize });
+ // =========================== [Use State] =============================
+ const [pageSize, setPageSize] = useState(TABLE_PAGINATION?.size);
+ const [currentPage, setCurrentPage] = useState(TABLE_PAGINATION?.page);
+
+ const {
+ data: investmentTypes,
+ isLoading: investmentTypesLoading,
+ error,
+ } = useGetInvestmentTypesQuery({ page: currentPage, size: pageSize });
console.log(investmentTypes?.data?.rows);
- // ========= [Toggle ToastBox] =======
+ // ========= [Toggle ToastBox] =======
// const handleUpdateStatus = debounce((id) => {
// setInvestmentType((prevInvestmentType) =>
@@ -65,10 +81,9 @@ const InvestmentType = () => {
return nameMatches;
});
+ // ==================================================== [Table Setup] ================================================================
- // ==================================================== [Table Setup] ================================================================
-
- const tableHeadRow = [
+ const tableHeadRow = [
// "Sr.no",
"Investment Type",
"Description",
@@ -101,20 +116,22 @@ const InvestmentType = () => {
),
Description: (
-
- {item.note}
-
+
+
+ {item.note}
+
+
+
),
Status: (
@@ -229,7 +246,6 @@ const InvestmentType = () => {
pt={4}
spacing="24px"
>
-
{/* ======================= [Search Input] ======================== */}
{
/>
-
{/* ====================[Pagination]===================== */}
-
-
+
{/* ===================== [Add Button] ===================== */}
@@ -258,7 +279,7 @@ const InvestmentType = () => {
colorScheme={"forestGreen"}
rounded={"sm"}
size={"sm"}
- fontSize={'xs'}
+ fontSize={"xs"}
>
Add Investment Type