Sponsor page and Add investment page

This commit is contained in:
rockyeverlast
2024-06-21 20:32:14 +05:30
parent 24aa441388
commit ae356f2f81
9 changed files with 1089 additions and 30 deletions

View File

@@ -1,20 +1,34 @@
import React from "react";
import { Table, TableContainer, Tbody, Td, Th, Thead, Tr, Skeleton, TableCaption, Tfoot } from "@chakra-ui/react";
import {
Table,
TableContainer,
Tbody,
Td,
Th,
Thead,
Tr,
Skeleton,
TableCaption,
Tfoot,
} from "@chakra-ui/react";
import EmptySearchList from "../EmptySearchList";
const DataTable = ({ data, isLoading, tableHeadRow, emptyMessage }) => {
const columnWidth = data && data[0] ? `${(100 / Object.keys(data[0]).length).toFixed(2)}%` : "auto";
const columnWidth =
data && data[0]
? `${(100 / Object.keys(data[0]).length).toFixed(2)}%`
: "auto";
return (
<TableContainer overflowX={"hidden"} className="h-auto mb-3 w-100">
{data?.length === 0 ? (
<EmptySearchList message={emptyMessage} />
) : (
<Table size="sm">
<TableCaption>Rubix v1.0.0</TableCaption>
<Thead backgroundColor="purple.50">
<Table size="sm">
<TableCaption>Tanami v1.0.0</TableCaption>
<Thead backgroundColor="rgba(0, 65, 24, 0.04)">
<Tr>
{tableHeadRow.map((heading, index) => (
<Th key={index} p={3} w={columnWidth}>
<Th key={index} p={3} w={"auto"} color={"#004118"}>
{isLoading ? <Skeleton height="20px" /> : heading}
{/* {heading} */}
</Th>
@@ -26,7 +40,15 @@ const DataTable = ({ data, isLoading, tableHeadRow, emptyMessage }) => {
? Array.from({ length: 12 }).map((_, index) => (
<Tr key={index}>
{tableHeadRow.map((_, i) => (
<Td key={i} style={{ whiteSpace: "nowrap", textOverflow: "ellipsis" }} className="web-text-small" w={columnWidth}>
<Td
key={i}
style={{
whiteSpace: "nowrap",
textOverflow: "ellipsis",
}}
className="web-text-small"
w={columnWidth}
>
<Skeleton height="20px" mb={1} mt={1} />
</Td>
))}
@@ -35,7 +57,15 @@ const DataTable = ({ data, isLoading, tableHeadRow, emptyMessage }) => {
: data?.map((item, index) => (
<Tr key={index}>
{tableHeadRow.map((heading, i) => (
<Td color={"gray.600"} key={i} style={{ whiteSpace: "nowrap", textOverflow: "ellipsis" }} className="web-text-small" >
<Td
color={"gray.600"}
key={i}
style={{
whiteSpace: "nowrap",
textOverflow: "ellipsis",
}}
className="web-text-small"
>
{item[heading]}
</Td>
))}

View File

@@ -65,8 +65,8 @@ const DashboardLayout = () => {
switch (path) {
case "/":
return "👋🏻 Hi, Admin";
case "/investment":
return "Investment";
case "/investment":
return "Sponsor";
case "/blogs-articles":
return "Blogs and Articles";
case "/videos":
@@ -116,9 +116,6 @@ const DashboardLayout = () => {
}
};
return (
<Box
style={{
@@ -132,7 +129,6 @@ const DashboardLayout = () => {
}}
className="d-flex"
pe={0.5}
>
<aside
className="h-100 position-relative sideBar pe-1"
@@ -142,12 +138,16 @@ const DashboardLayout = () => {
width: isDrawerOpen || openDrawerClick ? 225 : 70,
transition: "width 0.3s ease-in-out", // Smooth transition for width change
overflow: "hidden", // Hide overflow to prevent content overflow during transition
backgroundColor:"#0041180A",
backgroundColor: "#0041180A",
// backgroundColor: "#002F0F",
}}
>
<div
className={`d-flex ${isDrawerOpen || openDrawerClick ? "justify-content-start" : "justify-content-center"} p-3 pt-3 pb-4 position-relative `}
className={`d-flex ${
isDrawerOpen || openDrawerClick
? "justify-content-start"
: "justify-content-center"
} p-3 pt-3 pb-4 position-relative `}
height={"10%"}
>
{isDrawerOpen || openDrawerClick ? (
@@ -171,7 +171,7 @@ const DashboardLayout = () => {
<div
className="ps-2 scroll-bar "
style={{ height: "80%", overflowY: "scroll", overflowX:"hidden" }}
style={{ height: "80%", overflowY: "scroll", overflowX: "hidden" }}
>
{nav.map(({ title, path, Icon }, index) => (
<Box
@@ -215,7 +215,10 @@ const DashboardLayout = () => {
</span>
</NavLink>
) : (
<span className="web-text-xxsmall fw-600 mt-1 text-secondary fw-bold">
<span
className="web-text-xxsmall fw-600 mt-1 text-secondary fw-bold"
// style={{ textDecoration: "underline" }}
>
{title}
</span>
)}
@@ -285,7 +288,7 @@ const DashboardLayout = () => {
</aside>
<main
className={`h-100 ${path === "/" ? "ps-0" : "ps-3" } `}
className={`h-100 ${path === "/" ? "ps-0" : "ps-3"} `}
style={{
width: `calc(100% - ${isDrawerOpen || openDrawerClick ? 225 : 70}px)`,
transition: "width 0.3s ease-in-out",
@@ -320,7 +323,7 @@ const DashboardLayout = () => {
<span className="fs-5">{getTitle()}</span>
</header> */}
<HeaderMain logOutHandler={logOutHandler} icon title={getTitle()}/>
<HeaderMain logOutHandler={logOutHandler} icon title={getTitle()} />
<AppContent />
</main>

View File

@@ -0,0 +1,16 @@
import { Box, Input } from "@chakra-ui/react";
import React from "react";
import { OPACITY_ON_LOAD } from "../../Layout/animations";
const AssetClan = () => {
return (
<Box
{...OPACITY_ON_LOAD}
bg={"green.100"}
overflowY={"scroll"}
height={"100vh"}
></Box>
);
};
export default AssetClan;

View File

@@ -0,0 +1,16 @@
import { Box, Input } from "@chakra-ui/react";
import React from "react";
import { OPACITY_ON_LOAD } from "../../Layout/animations";
const ExchangeRate = () => {
return (
<Box
{...OPACITY_ON_LOAD}
bg={"green.100"}
overflowY={"scroll"}
height={"100vh"}
></Box>
);
};
export default ExchangeRate;

View File

@@ -0,0 +1,437 @@
import {
Box,
FormControl,
FormHelperText,
FormLabel,
Input,
Text,
Stack,
Textarea,
Heading,
Button,
useToast,
Divider,
Image,
Select,
} from "@chakra-ui/react";
import React, { useState } from "react";
import fallbackImage from "../../assets/fallBackImage.png";
import fallbackImageLarge from "../../assets/ultp-fallback-img.webp";
import { TiWarning } from "react-icons/ti";
import { motion } from "framer-motion";
import { OPACITY_ON_LOAD } from "../../Layout/animations";
import { yupResolver } from "@hookform/resolvers/yup";
import { Controller, useForm } from "react-hook-form";
import { investmentSchema } from "../../Validations/Validations";
import { useCreateBlogMutation } from "../../Services/api.service";
import { useNavigate } from "react-router-dom";
import Loader01 from "../../Components/Loaders/Loader01";
import ReactQuill from "react-quill";
import "react-quill/dist/quill.snow.css";
import ChipSelector from "../../Components/ChipSelector/ChipSelector";
import Header from "../../Components/Header";
import ToastBox from "../../Components/ToastBox";
const AddInvestment = () => {
const toast = useToast();
const navigate = useNavigate();
const [createBlog] = useCreateBlogMutation(); // Invoke the hook to get the mutation function
const [isLoading, setIsLoading] = useState(false);
const [selectedImage, setSelectedImage] = useState(fallbackImage);
const [selectedImageLarge, setSelectedImageLarge] =
useState(fallbackImageLarge);
const [largeImageData, setLargeImageData] = useState(null);
const [smallImageData, setSmallImageData] = useState(null);
const [chips, setChips] = useState([]);
const [value, setValue] = useState("");
const [metaDescription, setMetaDescription] = useState("");
const [investments, setInvestments] = useState([]);
const [status, setStatus] = useState("available");
const [statusAr, setStatusAr] = useState("available");
const handleDescriptionChange = (e) => {
setMetaDescription(e.target.value);
};
const {
control,
register,
handleSubmit,
reset,
setValue: setYupFormValue,
formState: { errors },
} = useForm({
resolver: yupResolver(investmentSchema),
});
const handleInputChange = (e, field) => {
setYupFormValue(field, e.target.value);
setYupFormValue(`${field}_ar`, e.target.value);
};
const handleArabicInputChange = (e, field) => {
setYupFormValue(field, e.target.value);
setYupFormValue(field.replace("_ar", ""), e.target.value);
};
const handleStatusChange = (e) => {
setStatus(e.target.value);
setStatusAr(e.target.value);
};
const handleStatusArChange = (e) => {
setStatusAr(e.target.value);
setStatus(e.target.value);
};
const onSubmit = (data) => {
const newInvestment = {
name: data.name,
address: data.address,
mobile: data.mobile,
bankDetails: data.bankDetails,
bankAccount: data.bankAccount,
status: data.status,
};
setInvestments([...investments, newInvestment]);
reset();
navigate("/investment");
};
return (
<Box
{...OPACITY_ON_LOAD}
overflowY={"scroll"}
height={"100vh"}
display={"flex"}
flexDirection={"column"}
>
<Header title={"Add Investment"} />
<form onSubmit={handleSubmit(onSubmit)}>
<Box display={"flex"}>
<Box className="col-6 pt-4 p-4">
<Box>
<FormControl isRequired className="mb-3">
<FormLabel className="web-text-large fw-bold rubix-text-dark">
Name
</FormLabel>
<Input
{...register("name")}
placeholder="Enter Name"
className="web-text-medium"
size="sm"
maxLength={90}
onChange={(e) => handleInputChange(e, "name")}
/>
<FormHelperText className="web-text-small">
Maximum characters must be 100 characters.
</FormHelperText>
{errors.name && (
<span className="text-danger web-text-small fw-bold ps-2 d-flex align-items-center gap-1 mt-1">
<TiWarning className="fw-bold fs-5 " />{" "}
{errors.name.message}
</span>
)}
</FormControl>
<FormControl isRequired className="mb-3">
<FormLabel className="web-text-large fw-bold rubix-text-dark">
Address
</FormLabel>
<Textarea
rows={2}
{...register("address")}
placeholder="Enter Address"
className="web-text-medium"
size="sm"
onChange={(e) => handleInputChange(e, "address")}
/>
<FormHelperText className="web-text-small">
Maximum characters must be 100 characters.
</FormHelperText>
{errors.address && (
<span className="text-danger web-text-small fw-bold ps-2 d-flex align-items-center gap-1 mt-1">
<TiWarning className="fw-bold fs-5 " />{" "}
{errors.address.message}
</span>
)}
</FormControl>
<FormControl isRequired className="mb-3">
<FormLabel className="web-text-large fw-bold rubix-text-dark">
Mobile
</FormLabel>
<Input
{...register("mobile")}
placeholder="Enter Mobile"
className="web-text-medium"
size="sm"
maxLength={90}
onChange={(e) => handleInputChange(e, "mobile")}
/>
<FormHelperText className="web-text-small">
Maximum characters must be 100 characters.
</FormHelperText>
{errors.mobile && (
<span className="text-danger web-text-small fw-bold ps-2 d-flex align-items-center gap-1 mt-1">
<TiWarning className="fw-bold fs-5 " />{" "}
{errors.mobile.message}
</span>
)}
</FormControl>
<FormControl isRequired className="mb-3">
<FormLabel className="web-text-large fw-bold rubix-text-dark">
Bank details
</FormLabel>
<Input
{...register("bankDetails")}
placeholder="Enter Bank details"
className="web-text-medium"
size="sm"
maxLength={90}
onChange={(e) => handleInputChange(e, "bankDetails")}
/>
<FormHelperText className="web-text-small">
Maximum characters must be 100 characters.
</FormHelperText>
{errors.bankDetails && (
<span className="text-danger web-text-small fw-bold ps-2 d-flex align-items-center gap-1 mt-1">
<TiWarning className="fw-bold fs-5 " />{" "}
{errors.bankDetails.message}
</span>
)}
</FormControl>
<FormControl isRequired className="mb-3">
<FormLabel className="web-text-large fw-bold rubix-text-dark">
Bank account
</FormLabel>
<Input
{...register("bankAccount")}
placeholder="Enter Bank account"
className="web-text-medium"
size="sm"
maxLength={90}
onChange={(e) => handleInputChange(e, "bankAccount")}
/>
<FormHelperText className="web-text-small">
Maximum characters must be 100 characters.
</FormHelperText>
{errors.bankAccount && (
<span className="text-danger web-text-small fw-bold ps-2 d-flex align-items-center gap-1 mt-1">
<TiWarning className="fw-bold fs-5 " />{" "}
{errors.bankAccount.message}
</span>
)}
</FormControl>
<FormControl isRequired id="status" mb={3}>
<FormLabel className="web-text-large fw-bold rubix-text-dark">
Status
</FormLabel>
<Select
name="status"
className="web-text-medium"
size="sm"
required
value={status}
onChange={handleStatusChange}
>
<option disabled value="select">
Select
</option>
<option value="available">Available</option>
<option value="upcoming">Upcoming</option>
<option value="closed">Closed</option>
</Select>
{errors.status && (
<span className="text-danger web-text-small fw-bold ps-2 d-flex align-items-center gap-1 mt-1">
<TiWarning className="fw-bold fs-5 " />{" "}
{errors.status.message}
</span>
)}
</FormControl>
</Box>
</Box>
{/* Arabic input */}
<Box className="col-6 pt-4 p-4">
<FormControl isRequired className="mb-3">
<FormLabel className="web-text-large fw-bold rubix-text-dark">
Name (Arabic)
</FormLabel>
<Input
{...register("name_ar")}
placeholder="Enter Name (Arabic)"
className="web-text-medium"
size="sm"
maxLength={90}
onChange={(e) => handleArabicInputChange(e, "name_ar")}
/>
<FormHelperText className="web-text-small">
Maximum characters must be 100 characters.
</FormHelperText>
{errors.name_ar && (
<span className="text-danger web-text-small fw-bold ps-2 d-flex align-items-center gap-1 mt-1">
<TiWarning className="fw-bold fs-5 " />{" "}
{errors.name_ar.message}
</span>
)}
</FormControl>
<FormControl isRequired className="mb-3">
<FormLabel className="web-text-large fw-bold rubix-text-dark">
Address (Arabic)
</FormLabel>
<Textarea
rows={2}
{...register("address_ar")}
placeholder="Enter Address (Arabic)"
className="web-text-medium"
size="sm"
onChange={(e) => handleArabicInputChange(e, "address_ar")}
/>
<FormHelperText className="web-text-small">
Maximum characters must be 100 characters.
</FormHelperText>
{errors.address_ar && (
<span className="text-danger web-text-small fw-bold ps-2 d-flex align-items-center gap-1 mt-1">
<TiWarning className="fw-bold fs-5 " />{" "}
{errors.address_ar.message}
</span>
)}
</FormControl>
<FormControl isRequired className="mb-3">
<FormLabel className="web-text-large fw-bold rubix-text-dark">
Mobile (Arabic)
</FormLabel>
<Input
{...register("mobile_ar")}
placeholder="Enter Mobile (Arabic)"
className="web-text-medium"
size="sm"
maxLength={90}
onChange={(e) => handleArabicInputChange(e, "mobile_ar")}
/>
<FormHelperText className="web-text-small">
Maximum characters must be 100 characters.
</FormHelperText>
{errors.mobile_ar && (
<span className="text-danger web-text-small fw-bold ps-2 d-flex align-items-center gap-1 mt-1">
<TiWarning className="fw-bold fs-5 " />{" "}
{errors.mobile_ar.message}
</span>
)}
</FormControl>
<FormControl isRequired className="mb-3">
<FormLabel className="web-text-large fw-bold rubix-text-dark">
Bank details (Arabic)
</FormLabel>
<Input
{...register("bankDetails_ar")}
placeholder="Enter Bank details (Arabic)"
className="web-text-medium"
size="sm"
maxLength={90}
onChange={(e) => handleArabicInputChange(e, "bankDetails_ar")}
/>
<FormHelperText className="web-text-small">
Maximum characters must be 100 characters.
</FormHelperText>
{errors.bankDetails_ar && (
<span className="text-danger web-text-small fw-bold ps-2 d-flex align-items-center gap-1 mt-1">
<TiWarning className="fw-bold fs-5 " />{" "}
{errors.bankDetails_ar.message}
</span>
)}
</FormControl>
<FormControl isRequired className="mb-3">
<FormLabel className="web-text-large fw-bold rubix-text-dark">
Bank account (Arabic)
</FormLabel>
<Input
{...register("bankAccount_ar")}
placeholder="Enter Bank account (Arabic)"
className="web-text-medium"
size="sm"
maxLength={90}
onChange={(e) => handleArabicInputChange(e, "bankAccount_ar")}
/>
<FormHelperText className="web-text-small">
Maximum characters must be 100 characters.
</FormHelperText>
{errors.bankAccount_ar && (
<span className="text-danger web-text-small fw-bold ps-2 d-flex align-items-center gap-1 mt-1">
<TiWarning className="fw-bold fs-5 " />{" "}
{errors.bankAccount_ar.message}
</span>
)}
</FormControl>
<FormControl isRequired id="status_ar" mb={3}>
<FormLabel className="web-text-large fw-bold rubix-text-dark">
Status (Arabic)
</FormLabel>
<Select
name="status_ar"
className="web-text-medium"
size="sm"
required
value={statusAr}
onChange={handleStatusArChange}
>
<option disabled value="select">
Select
</option>
<option value="available">Available</option>
<option value="upcoming">Upcoming</option>
<option value="closed">Closed</option>
</Select>
{errors.status_ar && (
<span className="text-danger web-text-small fw-bold ps-2 d-flex align-items-center gap-1 mt-1">
<TiWarning className="fw-bold fs-5 " />{" "}
{errors.status_ar.message}
</span>
)}
</FormControl>
<Box className=" d-flex justify-content-end p-4 m-4">
<Button
isLoading={isLoading}
spinner={<Loader01 />}
color={"whitesmoke"}
backgroundColor={"#004118"}
_hover={{
backgroundColor: "#005d22",
}}
type="submit"
size="sm"
rounded={"sm"}
>
New Investment
</Button>
</Box>
</Box>
</Box>
</form>
</Box>
);
};
export default AddInvestment;

View File

@@ -1,11 +1,532 @@
import { Box } from '@chakra-ui/react'
import React from 'react'
import { OPACITY_ON_LOAD } from '../../Layout/animations'
import React, { useRef, useState } from "react";
import {
Avatar,
Box,
Link,
Tag,
Text,
WrapItem,
Tooltip,
Divider,
Stack,
HStack,
Input,
Button,
Select,
Image,
Menu,
MenuButton,
MenuList,
MenuItem,
Switch,
Portal,
useDisclosure,
AlertDialog,
AlertDialogOverlay,
AlertDialogContent,
AlertDialogHeader,
AlertDialogCloseButton,
AlertDialogBody,
AlertDialogFooter,
useToast,
Skeleton,
VStack,
Badge,
} from "@chakra-ui/react";
import { AddIcon } from "@chakra-ui/icons";
import DataTable from "../../Components/DataTable/DataTable";
import { OPACITY_ON_LOAD } from "../../Layout/animations";
import { Link as RouterLink } from "react-router-dom";
import {
useDeleteBlogMutation,
useDeleteCommunityMutation,
useGetBlogQuery,
useGetCommunityBannerQuery,
useGetCommunityByIdQuery,
useGetCommunityQuery,
useUpdateBlogStatusMutation,
useUpdateCommunityStatusMutation,
} from "../../Services/api.service";
import { HiDotsVertical } from "react-icons/hi";
import { formatDate } from "../../Components/Functions/UTCConvertor";
import CustomAlertDialog from "../../Components/CustomAlertDialog";
import Header from "../../Components/Header";
import ToastBox from "../../Components/ToastBox";
import TabularView from "../../Components/TabularView/TabularView";
import { TABLE_PAGINATION } from "../../Constants/Paginations";
const API_URL = import.meta.env.VITE_API_BASE_URL;
const Investment = ({ investments = [] }) => {
// ====================================================[Hooks]===================================================================
const toast = useToast();
const [pageSize, setPageSize] = useState(TABLE_PAGINATION?.size);
const [currentPage, setCurrentPage] = useState(1);
const [deleteAlert, setDeleteAlert] = useState(false);
const [actionId, setActionId] = useState(null);
const [deleteIsLoading, setDeleteIsLoading] = useState(false);
const [searchTerm, setSearchTerm] = useState("");
const [statusFilter, setStatusFilter] = useState("all");
// const blog = useGetBlogQuery({ page: currentPage, size: pageSize });
// const [deleteBlog] = useDeleteBlogMutation();
// const [updateBlogStatus] = useUpdateBlogStatusMutation();
// ====================================================[Functions]===================================================================
const staticData = [
{
id: 1,
name: "EcoTech Innovations",
address: "Baharain",
mobile: "Available",
bank_details: "+ $ 25.500",
bank_account: "100",
status: "Available",
},
{
id: 2,
name: "Solaris Ventures",
address: "Kuwait",
mobile: "Upcoming",
bank_details: "+ $ 20.500",
bank_account: "50",
status: "Upcoming",
},
];
const handleDelete = async (id) => {
setDeleteIsLoading(true);
// Simulate deletion
setTimeout(() => {
setDeleteIsLoading(false);
setDeleteAlert(false);
toast({
title: "Deleted",
description: `Item with id ${id} has been deleted.`,
status: "success",
duration: 3000,
isClosable: true,
});
}, 1000);
};
const handleUpdateStatus = async (id) => {
// Simulate status update
toast({
title: "Updated",
description: `Status for item with id ${id} has been updated.`,
status: "success",
duration: 3000,
isClosable: true,
});
};
const filteredData = staticData.filter((item) => {
const nameMatches = item.name
.toLowerCase()
.includes(searchTerm.toLowerCase());
const statusMatches =
statusFilter === "all" ||
(statusFilter === "active" && item.active_blog) ||
(statusFilter === "inactive" && !item.active_blog);
return nameMatches && statusMatches;
});
const tableHeadRow = [
"S/N",
"Name",
"Address",
"Mobile",
"Active",
"Bank Details",
"Bank Account",
"Status",
];
const extractedArray = filteredData.map((item, index) => ({
"S/N": (
<RouterLink className="d-flex align-items-center gap-2 pointer">
<span className="d-flex flex-column" style={{ width: "auto" }}>
<Text
as={"span"}
color={"gray.600"}
className="d-flex fw-bold align-items-center web-text-small"
>
{index + 1}.
</Text>
</span>
</RouterLink>
),
Name: (
<Tooltip
className="rounded-2 web-text-xsmall"
width={"fit-content"}
placement="top"
hasArrow
bg="blue.200"
>
<Box display={"flex"} alignItems={"center"} w={"auto"}>
<Text as={"span"} isTruncated={true}>
{item.name}
</Text>
</Box>
</Tooltip>
),
Address: (
<Box
display={"flex"}
flexWrap={"wrap"}
gap={1}
alignItems={"center"}
w={"auto"}
>
<Text as={"span"} isTruncated={true}>
{item.address}
</Text>
</Box>
),
Mobile: (
<Box display={"flex"} alignItems={"center"} w={"auto"}>
<Text as={"span"} isTruncated={true}>
{item.mobile}
</Text>
</Box>
),
Active: (
<Switch
size={"sm"}
colorScheme="teal"
onChange={() => handleUpdateStatus(item.id)}
isChecked={item.active_blog}
/>
),
"Bank Details": (
<Box display={"flex"} alignItems={"center"} w={"auto"}>
<Text as={"span"} isTruncated={true}>
{item.bank_details}
</Text>
</Box>
),
"Bank Account": (
<Box display={"flex"} alignItems={"center"} w={"auto"}>
<Text as={"span"} isTruncated={true}>
{item.bank_account}
</Text>
</Box>
),
Status: (
<span className="d-flex justify-content-between align-items-center">
<Text as={"span"} color={"gray.600"}>
{item.status}
</Text>
<Menu>
<MenuButton className="link p-1 rounded-1">
<HiDotsVertical className="rubix-text-dark fs-6" />
</MenuButton>
<Portal>
<MenuList minWidth="80px">
<RouterLink to={`edit/${item.id}`}>
<MenuItem className="web-text-medium">Edit</MenuItem>
</RouterLink>
<RouterLink to={`view/${item.id}`}>
<MenuItem className="web-text-medium">View</MenuItem>
</RouterLink>
<MenuItem
onClick={() => {
setActionId(item.id);
setDeleteAlert(true);
}}
className="web-text-medium"
>
Delete
</MenuItem>
</MenuList>
</Portal>
</Menu>
</span>
),
}));
const Investment = () => {
return (
<Box {...OPACITY_ON_LOAD} bg={"green.100"} overflowY={"scroll"} height={"100vh"}></Box>
)
}
<>
<TabularView
title={""}
btnTitle={"Add Investment"}
link={"/investment/add-investment"}
apiData={{
isLoading: false,
data: { totalItems: investments.length, totalPages: 1 },
}}
tableHeadRow={tableHeadRow}
extractedArray={extractedArray}
searchTerm={searchTerm}
setSearchTerm={setSearchTerm}
statusFilter={statusFilter}
setStatusFilter={setStatusFilter}
pageSize={pageSize}
setPageSize={setPageSize}
currentPage={currentPage}
setCurrentPage={setCurrentPage}
totalItems={investments.length}
totalPages={1}
noDataTitle={"Investments"}
/>
<CustomAlertDialog
onClose={() => setDeleteAlert(false)}
isOpen={deleteAlert}
alertHandler={() => handleDelete(actionId)}
message={"Are you sure you want to delete this item?"}
isLoading={deleteIsLoading}
/>
</>
);
export default Investment
// const handleDelete = async (communityId) => {
// try {
// // Trigger the mutation
// setDeleteIsLoading(true);
// await deleteBlog(communityId)
// .then((response) => {
// // Handle the response here
// // // console.log("Mutation response:", response?.data?.statusCode);
// // // console.log("Mutation response:", response?.data?.message);
// if (response?.data?.statusCode === 201) {
// setDeleteIsLoading(false);
// setDeleteAlert(false);
// }
// })
// .catch((error) => {
// // // console.error("Error creating community:", error);
// setDeleteIsLoading(false);
// setDeleteAlert(false);
// });
// } catch (error) {
// // Handle errors
// // // console.error("Error deleting community:", error);
// }
// };
// const handleUpdateStatus = async (id) => {
// try {
// // Trigger the mutation
// await updateBlogStatus({ id })
// .then((response) => {
// if (response?.data?.statusCode === 201) {
// toast({
// render: () => (
// <ToastBox
// status={"success"}
// message={response?.data?.message}
// />
// ),
// });
// }
// })
// .catch((error) => {
// // // console.log(error);
// });
// } catch (error) {
// // Handle errors
// // // console.error("Error updating community status:", error);
// }
// };
// // ====================================================[Table Filter]================================================================
// const filteredData = blog?.data?.data?.rows?.filter((item) => {
// // Filter by name (case insensitive)
// const name = item.author_name;
// const searchLower = searchTerm.toLowerCase();
// const nameMatches = name.toLowerCase().includes(searchLower);
// // Filter by status
// const status = item.active_blog;
// const statusMatches =
// statusFilter === "all" ||
// (statusFilter === "active" && status === true) ||
// (statusFilter === "inactive" && status === false);
// return nameMatches && statusMatches;
// });
// // ====================================================[Table Setup]================================================================
// const tableHeadRow = [
// "S/N",
// // "Discription",
// "InvestorName",
// "Country",
// "InvestedAmount",
// "USDAmount",
// ];
// const extractedArray = filteredData?.map((item, index) => {
// return {
// "S/N": (
// <RouterLink
// // to={`view/${item.id}`}
// className="d-flex align-items-center gap-2 pointer"
// >
// {/* <Avatar
// size="sm"
// name="Default"
// src={`${API_URL}/${item.profile_image}`}
// /> */}
// <span className="d-flex flex-column">
// <Text
// as={"span"}
// color={"gray.600"}
// className="d-flex fw-bold align-items-center web-text-small"
// >
// {/* {item?.author_name} */}
// 1.
// </Text>
// {/* <span className="d-flex align-items-center web-text-xsmall text-secondary">
// {item?.author_designation}
// </span> */}
// </span>
// </RouterLink>
// ),
// // Discription: (
// // <Tooltip
// // className="rounded-2 web-text-xsmall"
// // width={"fit-content"}
// // placement="top"
// // hasArrow
// // label={item?.meta_description}
// // bg="blue.200"
// // >
// // <Box display={"flex"} alignItems={"center"} w={200}>
// // <Text as={"span"} isTruncated={true}>
// // {item?.meta_description}
// // </Text>
// // </Box>
// // </Tooltip>
// // ),
// InvestorName: (
// <Tooltip
// className="rounded-2 web-text-xsmall"
// width={"fit-content"}
// placement="top"
// hasArrow
// // label={item?.summary}
// bg="blue.200"
// >
// <Box display={"flex"} alignItems={"center"} w={400}>
// <Text as={"span"} isTruncated={true}>
// {/* {item?.summary} */}
// Faisal
// </Text>
// </Box>
// </Tooltip>
// ),
// Country: (
// <Box
// display={"flex"}
// flexWrap={"wrap"}
// gap={1}
// alignItems={"center"}
// w={200}
// >
// {/* {item?.tags?.map(({ id, tag }) => (
// <Badge
// rounded={"full"}
// key={id}
// variant="solid"
// fontWeight={"normal"}
// size={"sm"}
// ps={3}
// pe={3}
// pt={0.5}
// pb={0.5}
// backgroundColor={"#565263"}
// >
// {tag}
// </Badge>
// ))} */}
// <Text as={"span"} isTruncated={true}>
// Baharain
// </Text>
// </Box>
// ),
// InvestedAmount: (
// // <Switch
// // size={"sm"}
// // colorScheme="teal"
// // onChange={() => handleUpdateStatus(item.id)}
// // isChecked={item.active_blog}
// // />
// <Box display={"flex"} alignItems={"center"} w={400}>
// <Text as={"span"} isTruncated={true}>
// 60000
// </Text>
// </Box>
// ),
// USDAmount: (
// <span className="d-flex justify-content-between align-items-center">
// <Text as={"span"} color={"gray.600"} className=" fw-bold">
// {/* {formatDate(item?.createdAt)} */}
// 3000
// </Text>
// <Menu>
// <MenuButton className="link p-1 rounded-1">
// <HiDotsVertical className="rubix-text-dark fs-6" />
// </MenuButton>
// <Portal>
// <MenuList minWidth="80px">
// <RouterLink to={`edit/${item.id}`}>
// <MenuItem className="web-text-medium">Edit</MenuItem>
// </RouterLink>
// <RouterLink to={`view/${item.id}`}>
// <MenuItem className="web-text-medium">View</MenuItem>
// </RouterLink>
// <MenuItem
// onClick={() => {
// setActionId(item.id);
// setDeleteAlert(true);
// }}
// className="web-text-medium"
// >
// Delete
// </MenuItem>
// </MenuList>
// </Portal>
// </Menu>
// </span>
// ),
// };
// });
// return (
// <>
// <TabularView
// title={"Investments"}
// btnTitle={"Create"}
// link={"/blogs-articles/add-blog"}
// apiData={blog}
// tableHeadRow={tableHeadRow}
// extractedArray={extractedArray}
// searchTerm={searchTerm}
// setSearchTerm={setSearchTerm}
// statusFilter={statusFilter}
// setStatusFilter={setStatusFilter}
// pageSize={pageSize}
// setPageSize={setPageSize}
// currentPage={currentPage}
// setCurrentPage={setCurrentPage}
// totalItems={blog?.data?.data?.totalItems}
// totalPages={blog?.data?.data?.totalPages}
// noDataTitle={"Investments"}
// />
// <CustomAlertDialog
// onClose={() => setDeleteAlert(false)}
// isOpen={deleteAlert}
// alertHandler={() => handleDelete(actionId)}
// message={"Are you sure you want to delete blogs?"}
// isLoading={deleteIsLoading}
// />
// </>
// );
};
export default Investment;

View File

@@ -13,6 +13,8 @@ import { GrDocumentVerified } from "react-icons/gr";
import { FaQuestionCircle } from "react-icons/fa";
import { MdOutlineSettingsApplications } from "react-icons/md";
import { MdOutlineUnsubscribe } from "react-icons/md";
import { MdCurrencyExchange } from "react-icons/md";
import { RiFundsLine } from "react-icons/ri";
export const nav = [
// {
@@ -21,15 +23,25 @@ export const nav = [
// Icon: FiHome,
// },
{
title: "MAIN MENU",
title: "MASTER",
path: null,
},
{
title: "Investment",
title: "Sponsor view",
path: "/investment",
Icon: HiOutlineNewspaper,
},
// {
// title: "Excahnge Rate",
// path: "/exchange-rate",
// Icon: MdCurrencyExchange,
// },
// {
// title: "Asset Clan",
// path: "/asset-clan",
// Icon: RiFundsLine,
// },
// {
// title: "Banners",
// path: "/banner",
// Icon: AiOutlineIdcard,

View File

@@ -75,6 +75,9 @@ import EditPartner from "../Pages/Partners/EditPartners";
import newsLetter from "../Pages/NewLetter/NewsLetter";
import NewsLetter from "../Pages/NewLetter/NewsLetter";
import Investment from "../Pages/Investment/Investment";
import ExchangeRate from "../Pages/ExchangeRate/ExchangeRate";
import AssetClan from "../Pages/AssetClan/AssetClan";
import AddInvestment from "../Pages/Investment/AddInvestment";
export const RouteLink = [
{ path: "/", Component: WelcomePage },
@@ -206,7 +209,14 @@ export const RouteLink = [
// =============[ Tanami ]================
// ===========Master================
// ===========Investment==============
{ path: "/investment", Component: Investment },
{ path: "/investment/add-investment", Component: AddInvestment },
{ path: "/investment", Component: Investment },
{ path: "/exchange-rate", Component: ExchangeRate },
{ path: "/asset-clan", Component: AssetClan },

View File

@@ -795,3 +795,17 @@ export const addFaq = Yup.object().shape({
// }
// })
});
// Tanami Schema
export const investmentSchema = Yup.object().shape({
name: Yup.string().required("Name is required"),
address: Yup.string().required("Type is required"),
mobile: Yup.string().required("Total Fund is required"),
bankDetails: Yup.string().required("Total Investor is required"),
bankAccount: Yup.string().required("Predicted Income is required"),
status: Yup.string()
.oneOf(["available", "upcoming", "closed"], "Invalid status")
.required("Status is required"),
});