update 24-06-2024
This commit is contained in:
11
src/Pages/Master/ExchangeRate/ExchangeRate.jsx
Normal file
11
src/Pages/Master/ExchangeRate/ExchangeRate.jsx
Normal file
@@ -0,0 +1,11 @@
|
||||
import { Box } from '@chakra-ui/react'
|
||||
import React from 'react'
|
||||
import { OPACITY_ON_LOAD } from '../../../Layout/animations'
|
||||
|
||||
const ExchangeRate = () => {
|
||||
return (
|
||||
<Box {...OPACITY_ON_LOAD} bg={"green.200"} overflowY={"scroll"} height={"100vh"}></Box>
|
||||
)
|
||||
}
|
||||
|
||||
export default ExchangeRate
|
||||
227
src/Pages/Master/Sponser/AddSponser.jsx
Normal file
227
src/Pages/Master/Sponser/AddSponser.jsx
Normal file
@@ -0,0 +1,227 @@
|
||||
import React, { useContext } from "react";
|
||||
import { OPACITY_ON_LOAD } from "../../../Layout/animations";
|
||||
import {
|
||||
Box,
|
||||
Divider,
|
||||
FormControl,
|
||||
FormLabel,
|
||||
Heading,
|
||||
Input,
|
||||
Select,
|
||||
Textarea,
|
||||
Button,
|
||||
Text,
|
||||
} from "@chakra-ui/react";
|
||||
import { useForm, Controller } from "react-hook-form";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import * as yup from "yup";
|
||||
import { WarningTwoIcon } from "@chakra-ui/icons";
|
||||
import { TiWarning } from "react-icons/ti";
|
||||
import GlobalStateContext from "../../../Contexts/GlobalStateContext";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import FormField from "../../../Components/FormField";
|
||||
|
||||
const schema = yup.object().shape({
|
||||
sponserName: yup.string().required("Sponser name is required"),
|
||||
mobileNo: yup.string().required("Mobile no is required"),
|
||||
sponserAddress: yup.string().required("Sponser address is required"),
|
||||
accountHolderName: yup.string().required("Account Holder's Name is required"),
|
||||
bankName: yup.string().required("Bank Name is required"),
|
||||
accountNumber: yup.string().required("Account Number is required"),
|
||||
bankBranch: yup.string().required("Bank Branch is required"),
|
||||
branchAddress: yup.string().required("Branch Address is required"),
|
||||
ifscCode: yup.string().required("IFSC Code is required"),
|
||||
swiftCode: yup.string().required("SWIFT/BIC Code is required"),
|
||||
routingNumber: yup.string().required("Routing Number is required"),
|
||||
iban: yup.string().required("IBAN is required"),
|
||||
accountType: yup.string().required("Account Type is required"),
|
||||
bankPhoneNumber: yup.string().required("Bank Phone Number is required"),
|
||||
bankEmail: yup.string().email("Invalid email format"),
|
||||
});
|
||||
|
||||
|
||||
|
||||
const AddSponser = () => {
|
||||
const navigate = useNavigate()
|
||||
const { sponser, setSponser } = useContext(GlobalStateContext);
|
||||
const {
|
||||
control,
|
||||
handleSubmit,
|
||||
formState: { errors },
|
||||
} = useForm({
|
||||
resolver: yupResolver(schema),
|
||||
});
|
||||
|
||||
console.log(errors);
|
||||
|
||||
const onSubmit = (data) => {
|
||||
setSponser([{...data, status: true}, ...sponser]);
|
||||
navigate('/sponser');
|
||||
};
|
||||
|
||||
return (
|
||||
<Box {...OPACITY_ON_LOAD} overflowY={"scroll"} height={"100vh"} pb={14}>
|
||||
<form onSubmit={handleSubmit(onSubmit)}>
|
||||
<Heading as="h6" size="xs" mt={4}>
|
||||
Personal Details
|
||||
</Heading>
|
||||
<Box display={"flex"} gap={0}>
|
||||
{Array(2).fill(
|
||||
<Box
|
||||
width={"50%"}
|
||||
p={5}
|
||||
display={"flex"}
|
||||
flexDirection={"column"}
|
||||
gap={4}
|
||||
>
|
||||
<FormField
|
||||
label="Sponser name"
|
||||
name="sponserName"
|
||||
control={control}
|
||||
errors={errors}
|
||||
isRequired={true}
|
||||
/>
|
||||
<FormField
|
||||
label="Mobile no"
|
||||
name="mobileNo"
|
||||
type="tel"
|
||||
control={control}
|
||||
errors={errors}
|
||||
isRequired={true}
|
||||
/>
|
||||
<FormField
|
||||
label="Sponser address"
|
||||
name="sponserAddress"
|
||||
type="textarea"
|
||||
control={control}
|
||||
errors={errors}
|
||||
isRequired={true}
|
||||
/>
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
|
||||
<Divider />
|
||||
|
||||
<Heading as="h6" size="xs" mt={4}>
|
||||
Bank Details
|
||||
</Heading>
|
||||
<Box display={"flex"} gap={0}>
|
||||
{Array(2).fill(
|
||||
<Box
|
||||
width={"50%"}
|
||||
p={5}
|
||||
display={"flex"}
|
||||
flexDirection={"column"}
|
||||
gap={4}
|
||||
>
|
||||
<FormField
|
||||
label="Account Holder's Name"
|
||||
name="accountHolderName"
|
||||
control={control}
|
||||
errors={errors}
|
||||
isRequired={true}
|
||||
/>
|
||||
<FormField
|
||||
label="Bank Name"
|
||||
name="bankName"
|
||||
control={control}
|
||||
errors={errors}
|
||||
isRequired={true}
|
||||
/>
|
||||
<FormField
|
||||
label="Account Number"
|
||||
name="accountNumber"
|
||||
control={control}
|
||||
errors={errors}
|
||||
isRequired={true}
|
||||
/>
|
||||
<FormField
|
||||
label="Bank Branch"
|
||||
name="bankBranch"
|
||||
control={control}
|
||||
errors={errors}
|
||||
isRequired={true}
|
||||
/>
|
||||
<FormField
|
||||
label="Branch Address"
|
||||
name="branchAddress"
|
||||
control={control}
|
||||
errors={errors}
|
||||
isRequired={true}
|
||||
/>
|
||||
<FormField
|
||||
label="IFSC Code"
|
||||
name="ifscCode"
|
||||
control={control}
|
||||
errors={errors}
|
||||
isRequired={true}
|
||||
/>
|
||||
<FormField
|
||||
label="SWIFT/BIC Code"
|
||||
name="swiftCode"
|
||||
control={control}
|
||||
errors={errors}
|
||||
isRequired={true}
|
||||
/>
|
||||
<FormField
|
||||
label="Routing Number"
|
||||
name="routingNumber"
|
||||
control={control}
|
||||
errors={errors}
|
||||
isRequired={true}
|
||||
/>
|
||||
<FormField
|
||||
label="IBAN"
|
||||
name="iban"
|
||||
control={control}
|
||||
errors={errors}
|
||||
isRequired={true}
|
||||
/>
|
||||
<FormField
|
||||
label="Type of Account"
|
||||
name="accountType"
|
||||
control={control}
|
||||
errors={errors}
|
||||
isRequired={true}
|
||||
component={
|
||||
<Select size={"sm"}>
|
||||
<option value="savings">Savings</option>
|
||||
<option value="checking">Checking</option>
|
||||
<option value="business">Business</option>
|
||||
</Select>
|
||||
}
|
||||
/>
|
||||
<FormField
|
||||
label="Bank Phone Number"
|
||||
name="bankPhoneNumber"
|
||||
control={control}
|
||||
errors={errors}
|
||||
isRequired={true}
|
||||
/>
|
||||
<FormField
|
||||
label="Bank Email (optional)"
|
||||
name="bankEmail"
|
||||
control={control}
|
||||
errors={errors}
|
||||
/>
|
||||
|
||||
{/* <Button size={"sm"} rounded={"sm"} type="submit" colorScheme="green">
|
||||
Submit
|
||||
</Button> */}
|
||||
</Box>
|
||||
)}
|
||||
|
||||
</Box>
|
||||
|
||||
<Box display={'flex'} justifyContent={"flex-end"} p={4}>
|
||||
<Button size={"sm"} width={"50%"} rounded={"sm"} type="submit" colorScheme="green">
|
||||
Submit
|
||||
</Button>
|
||||
</Box>
|
||||
</form>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default AddSponser;
|
||||
226
src/Pages/Master/Sponser/Sponsers.jsx
Normal file
226
src/Pages/Master/Sponser/Sponsers.jsx
Normal file
@@ -0,0 +1,226 @@
|
||||
import {
|
||||
Avatar,
|
||||
Badge,
|
||||
Box,
|
||||
Button,
|
||||
HStack,
|
||||
Input,
|
||||
Menu,
|
||||
MenuButton,
|
||||
MenuItem,
|
||||
MenuList,
|
||||
Portal,
|
||||
Select,
|
||||
Switch,
|
||||
Tag,
|
||||
Text,
|
||||
} from "@chakra-ui/react";
|
||||
import React, { useContext, useEffect, useState } from "react";
|
||||
import { OPACITY_ON_LOAD } from "../../../Layout/animations";
|
||||
import DataTable from "../../../Components/DataTable/DataTable";
|
||||
import { HiDotsVertical } from "react-icons/hi";
|
||||
import { Link, Link as RouterLink } from "react-router-dom";
|
||||
import { AddIcon, EmailIcon } from "@chakra-ui/icons";
|
||||
import Pagination from "../../../Components/Pagination";
|
||||
import GlobalStateContext from "../../../Contexts/GlobalStateContext";
|
||||
import CustomAlertDialog from "../../../Components/CustomAlertDialog";
|
||||
|
||||
const formatDate = (date) => new Date(date).toLocaleDateString(); // Simple date formatter
|
||||
|
||||
const Sponser = () => {
|
||||
const { sponser, setSponser } = useContext(GlobalStateContext);
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [deleteAlert, setDeleteAlert] = useState(false);
|
||||
const [actionId, setActionId] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
// Simulate loading
|
||||
const timer = setTimeout(() => {
|
||||
setIsLoading(false);
|
||||
}, 1500);
|
||||
|
||||
// Cleanup the timer on component unmount
|
||||
return () => clearTimeout(timer);
|
||||
}, []);
|
||||
|
||||
// ====================================================[Table Setup]================================================================
|
||||
const tableHeadRow = [
|
||||
"Sponser name",
|
||||
"Address",
|
||||
"Mobile no",
|
||||
"Status",
|
||||
"Created At",
|
||||
];
|
||||
|
||||
const handleUpdateStatus = (id) => {
|
||||
console.log(`Status updated for id: ${id}`);
|
||||
// Add your status update logic here
|
||||
};
|
||||
|
||||
// ====================================================[Table Filter]================================================================
|
||||
const filteredData = sponser.filter((item) => {
|
||||
// Filter by name (case insensitive)
|
||||
const name = item.sponserName;
|
||||
const searchLower = searchTerm.toLowerCase();
|
||||
const nameMatches = name.toLowerCase().includes(searchLower);
|
||||
|
||||
// Filter by status
|
||||
// const status = item.status;
|
||||
// const statusLower = status ? "active" : "inactive";
|
||||
|
||||
// const statusMatches =
|
||||
// statusFilter === "all" ||
|
||||
// (statusFilter === "active" && status === true) ||
|
||||
// (statusFilter === "inactive" && status === false);
|
||||
|
||||
return nameMatches;
|
||||
});
|
||||
|
||||
const extractedArray = filteredData?.map((item) => ({
|
||||
"Sponser name": (
|
||||
<Text
|
||||
as={"span"}
|
||||
color={"gray.600"}
|
||||
className="d-flex align-items-center fw-bold web-text-small"
|
||||
>
|
||||
{item.sponserName}
|
||||
</Text>
|
||||
),
|
||||
Address: (
|
||||
<Box w={350} isTruncated={true}>
|
||||
<Text as={"span"} color={"teal.900"}>
|
||||
{item.sponserAddress}
|
||||
</Text>
|
||||
</Box>
|
||||
),
|
||||
"Mobile no": (
|
||||
<Box w={"auto"} isTruncated={true}>
|
||||
<Text as={"span"} color={"teal.900"}>
|
||||
{item.mobileNo}
|
||||
</Text>
|
||||
</Box>
|
||||
),
|
||||
Status:
|
||||
// <Switch
|
||||
// size={"sm"}
|
||||
// colorScheme="teal"
|
||||
// onChange={() => handleUpdateStatus(item.id)}
|
||||
// isChecked={item.status}
|
||||
// />
|
||||
|
||||
item?.status ? (
|
||||
<Badge variant={"outline"} colorScheme="green">
|
||||
Passed
|
||||
</Badge>
|
||||
) : (
|
||||
<Badge variant={"outline"} colorScheme="red">
|
||||
Not passes
|
||||
</Badge>
|
||||
),
|
||||
"Created At": (
|
||||
<span className="d-flex justify-content-between align-items-center">
|
||||
<Text as={"span"} color={"gray.600"} className=" fw-bold">
|
||||
{formatDate(item.createdAt)}
|
||||
</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 handleDelete = () => {
|
||||
const updatedSponsors = sponser.filter((sponsor) => sponsor.id !== actionId);
|
||||
|
||||
setTimeout(() => {
|
||||
setSponser(updatedSponsors);
|
||||
setDeleteAlert(false);
|
||||
setIsLoading(false);
|
||||
}, 100);
|
||||
setIsLoading(true);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<Box {...OPACITY_ON_LOAD} overflowY={"scroll"} height={"100vh"}>
|
||||
<Box bg="white.500">
|
||||
<HStack
|
||||
display={"flex"}
|
||||
justifyContent={"space-between"}
|
||||
ps={1}
|
||||
pe={1}
|
||||
pb={4}
|
||||
pt={4}
|
||||
spacing="24px"
|
||||
>
|
||||
<Input
|
||||
type="search"
|
||||
width={300}
|
||||
placeholder="Search..."
|
||||
size="sm"
|
||||
rounded="sm"
|
||||
value={searchTerm}
|
||||
onChange={(e) => setSearchTerm(e.target.value)}
|
||||
/>
|
||||
|
||||
<HStack display={"flex"} alignItems={"center"}>
|
||||
<Pagination totalItems={10} />
|
||||
|
||||
<Link to={"/sponser/add-sponser"}>
|
||||
<Button
|
||||
leftIcon={<AddIcon />}
|
||||
colorScheme={"green"}
|
||||
rounded={"sm"}
|
||||
size={"sm"}
|
||||
>
|
||||
Add sponsers
|
||||
</Button>
|
||||
</Link>
|
||||
</HStack>
|
||||
</HStack>
|
||||
</Box>
|
||||
|
||||
<DataTable
|
||||
emptyMessage={`We don't have any Sponers `}
|
||||
tableHeadRow={tableHeadRow}
|
||||
data={extractedArray}
|
||||
isLoading={isLoading}
|
||||
// totalPages={10}
|
||||
/>
|
||||
|
||||
<CustomAlertDialog
|
||||
onClose={()=> setDeleteAlert(false)}
|
||||
isOpen={deleteAlert}
|
||||
message={"Are you sure you want to delete sponers?"}
|
||||
alertHandler={handleDelete}
|
||||
isLoading={isLoading}
|
||||
/>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default Sponser;
|
||||
@@ -1,10 +1,9 @@
|
||||
import { Box, Image, Text } from '@chakra-ui/react'
|
||||
import noInternet from "../assets/Error.svg"
|
||||
import noInternet from "../assets/noInternet.jpg"
|
||||
|
||||
const NoInternetScreen = () => {
|
||||
return (
|
||||
<Box
|
||||
w={'100vw'}
|
||||
h={'100vh'}
|
||||
display={'flex'}
|
||||
justifyContent={'center'}
|
||||
@@ -13,7 +12,7 @@ const NoInternetScreen = () => {
|
||||
gap={5}
|
||||
>
|
||||
<Image src={noInternet} w={300} />
|
||||
<Text color={'blue.800'} as={'span'} className='fw-bold'>No Internet !</Text>
|
||||
{/* <Text color={'blue.800'} as={'span'} className='fw-bold'>No Internet !</Text> */}
|
||||
</Box>
|
||||
|
||||
)
|
||||
|
||||
@@ -1,7 +1,19 @@
|
||||
|
||||
import { Box, Image } from "@chakra-ui/react"
|
||||
import error from "../assets/Error.svg"
|
||||
const NotFound = () => {
|
||||
return (
|
||||
<div>NotFound</div>
|
||||
|
||||
<Box
|
||||
h={'100vh'}
|
||||
display={'flex'}
|
||||
justifyContent={'center'}
|
||||
alignItems={'center'}
|
||||
flexDirection={'column'}
|
||||
gap={5}
|
||||
>
|
||||
<Image src={error} w={300} />
|
||||
{/* <Text color={'blue.800'} as={'span'} className='fw-bold'>No Internet !</Text> */}
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ import CommunityBannerCard from "./CommunityBannerCard";
|
||||
import Header from "../../Components/Header";
|
||||
import { TABLE_PAGINATION } from "../../Constants/Paginations";
|
||||
import ToastBox from "../../Components/ToastBox";
|
||||
import TabularView from "../../Components/TabularView/TabularView";
|
||||
import TabularView from "../../../Components/TabularView/TabularView";
|
||||
const API_URL = import.meta.env.VITE_API_BASE_URL;
|
||||
|
||||
const Community = () => {
|
||||
Reference in New Issue
Block a user