switch btn
This commit is contained in:
@@ -51,7 +51,7 @@ const CustomBreadcrumb = () => {
|
||||
};
|
||||
|
||||
const breadcrumbs = generateBreadcrumbs(pathParts);
|
||||
console.log(breadcrumbs);
|
||||
// console.log(breadcrumbs);
|
||||
|
||||
return (
|
||||
<Box
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// SwitchButton.js
|
||||
import { Box, Switch, Text } from '@chakra-ui/react';
|
||||
import { Box, Text } from '@chakra-ui/react';
|
||||
import React from 'react';
|
||||
|
||||
const SwitchButton = ({ isSwitchOn, setIsSwitchOn }) => {
|
||||
@@ -9,19 +8,41 @@ const SwitchButton = ({ isSwitchOn, setIsSwitchOn }) => {
|
||||
|
||||
return (
|
||||
<Box display="flex" alignItems="center">
|
||||
<Switch
|
||||
size="lg"
|
||||
isChecked={isSwitchOn}
|
||||
onChange={switch_onChange_handle}
|
||||
sx={{
|
||||
".chakra-switch__track": {
|
||||
backgroundColor: isSwitchOn ? "#707070" : "#4CCD8D",
|
||||
},
|
||||
<Box
|
||||
as="button"
|
||||
display="flex"
|
||||
alignItems="center"
|
||||
justifyContent={isSwitchOn ? "flex-end" : "flex-start"}
|
||||
width="100px"
|
||||
height="40px"
|
||||
borderRadius="20px"
|
||||
backgroundColor={isSwitchOn ? "#707070" : "#4CCD8D"}
|
||||
onClick={switch_onChange_handle}
|
||||
position="relative"
|
||||
transition="background-color 0.2s"
|
||||
_before={{
|
||||
content: '""',
|
||||
position: "absolute",
|
||||
width: "40px",
|
||||
height: "40px",
|
||||
borderRadius: "50%",
|
||||
backgroundColor: "#FFF",
|
||||
boxShadow: "0 2px 4px rgba(0, 0, 0, 0.2)",
|
||||
transform: isSwitchOn ? "translateX(60px)" : "translateX(0)",
|
||||
transition: "transform 0.2s",
|
||||
}}
|
||||
/>
|
||||
<Text ml={4} className={isSwitchOn ? 'mont' : 'year'}>
|
||||
{isSwitchOn ? 'Active' : 'Inactive'}
|
||||
</Text>
|
||||
>
|
||||
<Text
|
||||
color="#FFF"
|
||||
fontWeight="bold"
|
||||
zIndex={1}
|
||||
position="absolute"
|
||||
left={isSwitchOn ? "10px" : "auto"}
|
||||
right={isSwitchOn ? "auto" : "10px"}
|
||||
>
|
||||
{isSwitchOn ? 'Active' : 'Inactive'}
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -11,6 +11,7 @@ import { useNavigate } from "react-router-dom";
|
||||
import FormField from "../../../Components/FormField";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import FormInputMain from "../../../Components/FormInputMain";
|
||||
import SwitchButton from "../../../Components/SwitchButton";
|
||||
|
||||
export const addInvestmentType = yup.object().shape({
|
||||
investmentName: yup.string().required("Investment name is required"),
|
||||
@@ -32,6 +33,7 @@ const AddInvestmentType = () => {
|
||||
const [bannerImageData, setBannerImageData] = useState(null);
|
||||
const { investmentType, setInvestmentType } = useContext(GlobalStateContext);
|
||||
const [selectedBannerImageData, setSelectedBannerImageData] = useState(null);
|
||||
const [isSwitchOn, setIsSwitchOn] = useState(false);
|
||||
|
||||
const [otherImageData, setOtherImageData] = useState(null);
|
||||
const [selectedOtherImageData, setSelectedOtherImageData] = useState(null);
|
||||
@@ -157,6 +159,7 @@ const AddInvestmentType = () => {
|
||||
|
||||
return (
|
||||
<Box {...OPACITY_ON_LOAD} overflowY={"scroll"} height={"100vh"} pb={14}>
|
||||
<SwitchButton isSwitchOn={isSwitchOn} setIsSwitchOn={setIsSwitchOn} />
|
||||
<FormInputMain
|
||||
groupedFields={groupedFields}
|
||||
control={control}
|
||||
|
||||
@@ -37,6 +37,7 @@ import ToastBox from "../../../Components/ToastBox";
|
||||
import { debounce } from "./AddInvestmentType";
|
||||
import DataTable from "../../../Components/DataTable/DataTable";
|
||||
import SwitchButton from "../../../Components/SwitchButton";
|
||||
import { useGetInvestmentTypeMasterQuery } from "../../../Services/investment.type.service";
|
||||
|
||||
const formatDate = (date) => new Date(date).toLocaleDateString(); // Simple date formatter
|
||||
|
||||
@@ -53,6 +54,15 @@ const InvestmentType = () => {
|
||||
const [mouseEnteredId, setMouseEnteredId] = useState("");
|
||||
const [isSwitchOn, setIsSwitchOn] = useState(false);
|
||||
|
||||
|
||||
const {
|
||||
data,
|
||||
error,
|
||||
isLoading: isInvsmentTypeLoading,
|
||||
} = useGetInvestmentTypeMasterQuery({ page: 1, size: 10 });
|
||||
|
||||
console.log(data);
|
||||
|
||||
useEffect(() => {
|
||||
// Simulate loading
|
||||
const timer = setTimeout(() => {
|
||||
@@ -72,7 +82,7 @@ const InvestmentType = () => {
|
||||
"Action",
|
||||
];
|
||||
|
||||
const handleUpdateStatus = debounce((id) => {
|
||||
const handleUpdateStatus = debounce((id) => {
|
||||
setInvestmentType((prevInvestmentType) =>
|
||||
prevInvestmentType.map((investmentType) =>
|
||||
investmentType.id === id
|
||||
|
||||
@@ -44,6 +44,7 @@ const Sponser = () => {
|
||||
|
||||
const [pageSize, setPageSize] = useState(TABLE_PAGINATION?.size);
|
||||
const [currentPage, setCurrentPage] = useState(1);
|
||||
|
||||
const {
|
||||
data: sponsors,
|
||||
error,
|
||||
@@ -261,18 +262,15 @@ const Sponser = () => {
|
||||
),
|
||||
}));
|
||||
|
||||
const handleDelete = async() => {
|
||||
const handleDelete = async () => {
|
||||
console.log(actionId);
|
||||
setIsLoading(true);
|
||||
try {
|
||||
const response = await deleteSponser(actionId)
|
||||
const response = await deleteSponser(actionId);
|
||||
console.log(response);
|
||||
setIsLoading(false);
|
||||
setDeleteAlert(false)
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
|
||||
setIsLoading(false);
|
||||
setDeleteAlert(false);
|
||||
} catch (error) {}
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -304,12 +302,11 @@ const Sponser = () => {
|
||||
<Link to={"/sponser/add-sponser"}>
|
||||
<Button
|
||||
leftIcon={<AddIcon />}
|
||||
colorScheme={"forestGreen"}
|
||||
colorScheme={"green"}
|
||||
rounded={"sm"}
|
||||
size={"sm"}
|
||||
fontSize={'xs'}
|
||||
>
|
||||
Add Sposnsor
|
||||
Add
|
||||
</Button>
|
||||
</Link>
|
||||
</HStack>
|
||||
@@ -332,7 +329,7 @@ const Sponser = () => {
|
||||
<CustomAlertDialog
|
||||
onClose={() => setDeleteAlert(false)}
|
||||
isOpen={deleteAlert}
|
||||
message={"Are you sure you want o delete sponers?"}
|
||||
message={"Are you sure you want to delete sponers?"}
|
||||
alertHandler={handleDelete}
|
||||
isLoading={isLoading}
|
||||
/>
|
||||
|
||||
@@ -24,7 +24,7 @@ import ViewInvestorDetails from "../Pages/Investor_Management/InvestorDetails/Vi
|
||||
import ExchangeRate from "../Pages/Master/ExchangeRate/ExchangeRate";
|
||||
import AddInvestmentType from "../Pages/Master/InvestmentType/AddInvestmentType";
|
||||
import EditInvestmentType from "../Pages/Master/InvestmentType/EditInvestmentType";
|
||||
import InvestmentType from "../Pages/Master/InvestmentType/InvestmentType";
|
||||
// import InvestmentType from "../Pages/Master/InvestmentType/InvestmentTypeOld";
|
||||
import ViewInvestmentType from "../Pages/Master/InvestmentType/ViewInvestmentType";
|
||||
import AddSponser from "../Pages/Master/Sponser/AddSponser";
|
||||
import EditSponser from "../Pages/Master/Sponser/EditSponser";
|
||||
@@ -35,6 +35,7 @@ import ViewHistory from "../Pages/WithDrawal/DrawalView/ViewHistory";
|
||||
import DepositRequest from "../Pages/Deposit/DepositRequest";
|
||||
import DepositHistory from "../Pages/Deposit/DepositViewHistory/DepositHistory";
|
||||
import Academy from "../Pages/Admin/ManageAcademy/Academy";
|
||||
import InvestmentType from "../Pages/Master/InvestmentType/InvestmentType";
|
||||
|
||||
export const RouteLink = [
|
||||
// =============[ Tanami ]================
|
||||
|
||||
@@ -7,16 +7,35 @@ const baseUrl = import.meta.env.VITE_API_BASE_URL + "/api";
|
||||
export const investmentType = createApi({
|
||||
reducerPath: "investmentType",
|
||||
baseQuery: fetchBaseQuery({ baseUrl }),
|
||||
tagTypes: [],
|
||||
tagTypes: ["getInvestmentType"],
|
||||
endpoints: (builder) => ({
|
||||
getInvestmentTypes: builder.query({
|
||||
query: () => '/getInvestmentTypes',
|
||||
|
||||
|
||||
|
||||
getInvestmentTypeMaster: builder.query({
|
||||
query: ({ page, size }) =>
|
||||
`/investmentType/admin/?page=${page}&size=${size}`,
|
||||
providesTags: ["getInvestmentType"],
|
||||
}),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
getInvestmentTypeMasterActive: builder.query({
|
||||
query: () => "/investmentType/admin/active",
|
||||
}),
|
||||
|
||||
getInvestmentTypeById: builder.query({
|
||||
query: (id) => `/getInvestmentType/${id}`,
|
||||
query: (id) => ({ url: `/investmentType/admin/${id}` }),
|
||||
providesTags: ["getInvestmentType"],
|
||||
}),
|
||||
}),
|
||||
});
|
||||
|
||||
// Export hooks for usage in functional components
|
||||
export const { useGetInvestmentTypesQuery, useGetInvestmentTypeByIdQuery } = investmentType;
|
||||
export const {
|
||||
useGetInvestmentTypeMasterQuery,
|
||||
useGetInvestmentTypeByIdQuery,
|
||||
useGetInvestmentTypeMasterActiveQuery,
|
||||
} = investmentType;
|
||||
|
||||
@@ -10,7 +10,7 @@ export const investorDetails = createApi({
|
||||
tagTypes: [],
|
||||
endpoints: (builder) => ({
|
||||
getInvestors: builder.query({
|
||||
query: () => '/getInvestors',
|
||||
query: () => "/getInvestors",
|
||||
}),
|
||||
getInvestorById: builder.query({
|
||||
query: (id) => `/getInvestor/${id}`,
|
||||
@@ -19,4 +19,5 @@ export const investorDetails = createApi({
|
||||
});
|
||||
|
||||
// Export hooks for usage in functional components
|
||||
export const { useGetInvestorsQuery, useGetInvestorByIdQuery } = investorDetails;
|
||||
export const { useGetInvestorsQuery, useGetInvestorByIdQuery } =
|
||||
investorDetails;
|
||||
|
||||
@@ -14,14 +14,22 @@ export const sponserMaster = createApi({
|
||||
baseQuery: fetchBaseQuery({ baseUrl: baseUrl }),
|
||||
tagTypes: ["getSponser"],
|
||||
endpoints: (builder) => ({
|
||||
|
||||
|
||||
|
||||
|
||||
getSponserMaster: builder.query({
|
||||
query: ({ page, size }) => `/sponsor/admin?page=${page}&size=${size}`,
|
||||
providesTags: ["getSponser"],
|
||||
}),
|
||||
|
||||
|
||||
|
||||
|
||||
getSponserMasterActive: builder.query({
|
||||
query: () => "/sponsor/admin/active",
|
||||
}),
|
||||
|
||||
getSponserById: builder.query({
|
||||
query: (id) => ({ url: `/sponsor/admin/${id}` }),
|
||||
providesTags: ["getSponser"],
|
||||
|
||||
Reference in New Issue
Block a user