mirror of
https://github.com/WDI-Ideas/rubix-admin-panel.git
synced 2026-04-27 19:25:51 +00:00
optimize
This commit is contained in:
@@ -36,8 +36,9 @@ import fallbackImage from "../../assets/ultp-fallback-img.webp";
|
||||
import Header from "../../Components/Header";
|
||||
import CommunityBannerCard from "../../Pages/Community/CommunityBannerCard";
|
||||
import BannerMainCard from "./BannerMainCard";
|
||||
import ToastBox from "../ToastBox";
|
||||
|
||||
const BannerEdit = ({isLoading, data, updateBanner, navigateTo}) => {
|
||||
const BannerEdit = ({isLoading, data, updateBanner, navigateTo, refetch}) => {
|
||||
const { id } = useParams();
|
||||
const toast = useToast();
|
||||
const navigate = useNavigate();
|
||||
@@ -117,11 +118,11 @@ const BannerEdit = ({isLoading, data, updateBanner, navigateTo}) => {
|
||||
if (response?.data?.statusCode === 200) {
|
||||
setIsLoadingEdit(false);
|
||||
toast({
|
||||
title: response?.data?.message,
|
||||
status: "success",
|
||||
duration: 1000,
|
||||
isClosable: true,
|
||||
render: () => (
|
||||
<ToastBox status={"success"} message={response?.data?.message} />
|
||||
),
|
||||
});
|
||||
refetch()
|
||||
navigate(navigateTo);
|
||||
// setDeleteAlert(false);
|
||||
}
|
||||
|
||||
@@ -5,10 +5,10 @@ import { useGetBuildBannerByIdQuery, useUpdateBuildBannerMutation } from '../../
|
||||
|
||||
const BannerBuildEdit = () => {
|
||||
const { id } = useParams();
|
||||
const { data, error, isLoading } = useGetBuildBannerByIdQuery(id);
|
||||
const { data, error, isLoading, refetch } = useGetBuildBannerByIdQuery(id);
|
||||
const [updateBuildBanner] = useUpdateBuildBannerMutation();
|
||||
|
||||
return (<BannerEdit navigateTo={'/banner/build'} isLoading={isLoading} data={data} updateBanner={updateBuildBanner} />
|
||||
return (<BannerEdit refetch={refetch} navigateTo={'/banner/build'} isLoading={isLoading} data={data} updateBanner={updateBuildBanner} />
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -7,12 +7,11 @@ import BannerEdit from "../../../Components/Banner/BannerEdit";
|
||||
|
||||
const BannerComunityEditPage = () => {
|
||||
const { id } = useParams();
|
||||
const { data, error, isLoading } = useGetCommunityBannerByIdQuery(id);
|
||||
const { data, error, isLoading, refetch } = useGetCommunityBannerByIdQuery(id);
|
||||
const [updateCommunityBanner] = useUpdateCommunityBannerMutation();
|
||||
console.log(data);
|
||||
|
||||
|
||||
return <BannerEdit navigateTo={'/banner/banner-community'} isLoading={isLoading} data={data} updateBanner={updateCommunityBanner} />
|
||||
return <BannerEdit refetch={refetch} navigateTo={'/banner/banner-community'} isLoading={isLoading} data={data} updateBanner={updateCommunityBanner} />
|
||||
};
|
||||
|
||||
export default BannerComunityEditPage;
|
||||
|
||||
@@ -5,10 +5,10 @@ import { useParams } from 'react-router-dom';
|
||||
|
||||
const BannerLearnEdit = () => {
|
||||
const { id } = useParams();
|
||||
const { data, error, isLoading } = useGetLearnBannerByIdQuery(id);
|
||||
const { data, error, isLoading, refetch} = useGetLearnBannerByIdQuery(id);
|
||||
const [updateLearnBanner] = useUpdateLearnBannerMutation();
|
||||
return (
|
||||
<BannerEdit navigateTo="/banner/learn" isLoading={isLoading} data={data} updateBanner={updateLearnBanner} />
|
||||
<BannerEdit refetch={refetch} navigateTo="/banner/learn" isLoading={isLoading} data={data} updateBanner={updateLearnBanner} />
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -5,10 +5,10 @@ import { useGetEcoBannerByIdQuery, useGetNewsBannerByIdQuery, useUpdateEcoBanner
|
||||
|
||||
const EcoBannerEdit = () => {
|
||||
const { id } = useParams();
|
||||
const { data, error, isLoading } = useGetEcoBannerByIdQuery(id);
|
||||
const { data, error, isLoading, refetch } = useGetEcoBannerByIdQuery(id);
|
||||
const [updateNewsBanner] = useUpdateEcoBannerMutation();
|
||||
return (
|
||||
<BannerEdit navigateTo="/banner/eco" isLoading={isLoading} data={data} updateBanner={updateNewsBanner} />
|
||||
<BannerEdit refetch={refetch} navigateTo="/banner/eco" isLoading={isLoading} data={data} updateBanner={updateNewsBanner} />
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -5,10 +5,13 @@ import { useParams } from 'react-router-dom';
|
||||
|
||||
const BannerHomeEdit = () => {
|
||||
const { id } = useParams();
|
||||
const { data, error, isLoading } = useGetHomeBannerByIdQuery(id);
|
||||
const { data, error, isLoading, refetch } = useGetHomeBannerByIdQuery(id);
|
||||
const [updateLearnBanner] = useUpdateHomeBannerMutation();
|
||||
// useEffect(() => {
|
||||
// refetch();
|
||||
// }, [id, refetch]);
|
||||
return (
|
||||
<BannerEdit navigateTo="/banner/home" isLoading={isLoading} data={data} updateBanner={updateLearnBanner} />
|
||||
<BannerEdit refetch={refetch} navigateTo="/banner/home" isLoading={isLoading} data={data} updateBanner={updateLearnBanner} />
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ const EditNews = () => {
|
||||
|
||||
await updateNews({ id: id, data: form })
|
||||
.then((response) => {
|
||||
if (response?.data?.statusCode === 201) {
|
||||
if (response?.data?.statusCode === 200) {
|
||||
setIsLoadingEdit(false);
|
||||
|
||||
toast({
|
||||
|
||||
Reference in New Issue
Block a user