Toast updated successfully
This commit is contained in:
@@ -14,9 +14,10 @@ import { Switch } from "../../components/ui/switch";
|
||||
import ViewDailog from "./ViewDailog";
|
||||
import { useGetManagePostsQuery, usePostStatusToggleMutation } from "../../Redux/Service/manage.post.service";
|
||||
import { useEffect, useState } from "react";
|
||||
import { toaster } from "../../components/ui/toaster";
|
||||
import { Toaster, toaster } from "../../components/ui/toaster";
|
||||
import { FaVideo } from "react-icons/fa";
|
||||
import SearchComponent from "../../components/SearchComponent";
|
||||
import { delay } from "../../components/Utils";
|
||||
// import Delete from "../../components/ActionIcons/Delete";
|
||||
// import ViewDailog from './ViewDailog'
|
||||
|
||||
@@ -96,6 +97,12 @@ const ManagePost = () => {
|
||||
);
|
||||
try {
|
||||
await postStatusToggle({ id: agencyId, is_active: newStatus }).unwrap();
|
||||
toaster.create({
|
||||
title: "Success",
|
||||
description: "Status updated successfully",
|
||||
type: "success",
|
||||
});
|
||||
await delay(500);
|
||||
refetch()
|
||||
} catch (error) {
|
||||
console.error("Error updating:", error);
|
||||
@@ -149,27 +156,27 @@ const ManagePost = () => {
|
||||
h={50}
|
||||
src={`${APIURL}${agency.images[0].image_name}`}
|
||||
/>
|
||||
<Text fontSize="xs" color={'lightgray'}>
|
||||
<Text fontSize="xs" color={'lightgray'}>
|
||||
{`${Number(agency.images.length) > 1 ? '+' + (Number(agency.images.length) - 1) : ''}`}
|
||||
</Text>
|
||||
</Text>
|
||||
</HStack>
|
||||
) : (
|
||||
<HStack>
|
||||
<Box
|
||||
rounded={"lg"}
|
||||
w={100}
|
||||
h={50}
|
||||
bg="gray.200"
|
||||
display="flex"
|
||||
alignItems="center"
|
||||
justifyContent="center"
|
||||
>
|
||||
<Icon as={FaVideo} color="gray.500" />
|
||||
</Box>
|
||||
<Text fontSize="xs" color={'lightgray'}>
|
||||
{`${Number(agency.images.length) > 1 ? '+' + (Number(agency.images.length) - 1) : ''}`}
|
||||
</Text>
|
||||
</HStack>
|
||||
<HStack>
|
||||
<Box
|
||||
rounded={"lg"}
|
||||
w={100}
|
||||
h={50}
|
||||
bg="gray.200"
|
||||
display="flex"
|
||||
alignItems="center"
|
||||
justifyContent="center"
|
||||
>
|
||||
<Icon as={FaVideo} color="gray.500" />
|
||||
</Box>
|
||||
<Text fontSize="xs" color={'lightgray'}>
|
||||
{`${Number(agency.images.length) > 1 ? '+' + (Number(agency.images.length) - 1) : ''}`}
|
||||
</Text>
|
||||
</HStack>
|
||||
) : ''
|
||||
// <Image rounded={"lg"} w={100} h={50} src={img} />
|
||||
),
|
||||
@@ -237,6 +244,7 @@ const ManagePost = () => {
|
||||
onPageChange={handlePageChange}
|
||||
/>
|
||||
</Box>
|
||||
<Toaster />
|
||||
</MainFrame>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -30,6 +30,7 @@ function EditTemplateModel({ id, localData, refetch }: { id: number, localData:
|
||||
const [subTitle, setSubTitle] = useState("");
|
||||
const [userType, setUserType] = useState<number | "">("");
|
||||
const [images, setImages] = useState<(File | string)[]>([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
// const [objectURLs, setObjectURLs] = useState<string[]>([]); // Store object URLs separately
|
||||
// const [updateTemplateMaster] = useUpdateTemplateMasterMutation()
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
@@ -104,6 +105,8 @@ function EditTemplateModel({ id, localData, refetch }: { id: number, localData:
|
||||
return;
|
||||
}
|
||||
|
||||
setLoading(true);
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("id", `${id}`);
|
||||
formData.append("principle_type_xid", `${userType}`);
|
||||
@@ -128,9 +131,11 @@ function EditTemplateModel({ id, localData, refetch }: { id: number, localData:
|
||||
});
|
||||
}
|
||||
setIsOpen(false);
|
||||
setLoading(false);
|
||||
refetch()
|
||||
} catch (error: any) {
|
||||
console.error("Error updating template:", error);
|
||||
setLoading(false);
|
||||
toaster.create({
|
||||
title: "Error",
|
||||
description: `${error.response?.data?.message || "Please try again later."}`,
|
||||
@@ -299,7 +304,7 @@ function EditTemplateModel({ id, localData, refetch }: { id: number, localData:
|
||||
|
||||
</DialogBody>
|
||||
<DialogFooter display="flex" justifyContent="center" pt={"2"}>
|
||||
<Button w="100%" bg="#02A0A0" color={"#fff"} onClick={handleSubmit}>
|
||||
<Button w="100%" bg="#02A0A0" color={"#fff"} onClick={handleSubmit} disabled={loading}>
|
||||
Save
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
|
||||
@@ -17,6 +17,7 @@ function TemplateAddModel({ refetch }: { refetch: VoidFunction }) {
|
||||
const [images, setImages] = useState<(File | string)[]>([]);
|
||||
// const [createTemplatePost] = useCreateTemplatePostMutation()
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const token = localStorage.getItem("token");
|
||||
|
||||
useEffect(() => {
|
||||
@@ -85,6 +86,7 @@ function TemplateAddModel({ refetch }: { refetch: VoidFunction }) {
|
||||
// image_name: images.filter((img) => typeof img === "string"), // Send only Base64 strings
|
||||
// };
|
||||
|
||||
setIsLoading(true);
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("principle_type_xid", `${userType}`);
|
||||
@@ -119,6 +121,7 @@ function TemplateAddModel({ refetch }: { refetch: VoidFunction }) {
|
||||
setUserType("");
|
||||
setImages([]);
|
||||
setIsOpen(false)
|
||||
setIsLoading(false);
|
||||
} catch (error: any) {
|
||||
console.error("Error creating template:", error);
|
||||
// alert("Failed to create template");
|
||||
@@ -244,7 +247,7 @@ function TemplateAddModel({ refetch }: { refetch: VoidFunction }) {
|
||||
|
||||
</DialogBody>
|
||||
<DialogFooter display="flex" justifyContent="center" pt={"2"}>
|
||||
<Button w="100%" bg="#02A0A0" color={"#fff"} onClick={handleSubmit}>
|
||||
<Button w="100%" bg="#02A0A0" color={"#fff"} onClick={handleSubmit} disabled={isLoading}>
|
||||
Save
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
|
||||
Reference in New Issue
Block a user