Faq data fetch fixed
This commit is contained in:
1
.env
1
.env
@@ -2,5 +2,6 @@ VITE_API_URL='https://ssa.betadelivery.com/apia/v1'
|
||||
# VITE_API_URL='http://192.16.50.44/seo-backend/apia/v1'
|
||||
VITE_USER_NAME="Admin"
|
||||
VITE_PASSWORD="71%@L%es^bUX94`J9XT*@bh,._WWM{$%^^&&"
|
||||
# VITE_PASSWORD="71%@L%es^bUX94`J9XT*%4&^%tUU^%Q^ffgt"
|
||||
VITE_APP_NAME=MyViteApp
|
||||
VITE_IMG_TEMPLATES='https://ssa.betadelivery.com/storage/app/public/uploads/post_templates/'
|
||||
10
.env.testing
10
.env.testing
@@ -1,5 +1,5 @@
|
||||
VITE_API_URL='https://ssa.betadelivery.com/testing/apia/'
|
||||
VITE_USER_NAME="Admin"
|
||||
VITE_PASSWORD="71%@L%es^bUX94`J9XT*@bh,._WWM{$%^^&&"
|
||||
VITE_APP_NAME=MyViteApp
|
||||
VITE_IMG_TEMPLATES='https://ssa.betadelivery.com/storage/app/public/uploads/post_templates/'
|
||||
# VITE_API_URL='https://ssa.betadelivery.com/testing/apia/'
|
||||
# VITE_USER_NAME="Admin"
|
||||
# VITE_PASSWORD="71%@L%es^bUX94`J9XT*@bh,._WWM{$%^^&&"
|
||||
# VITE_APP_NAME=MyViteApp
|
||||
# VITE_IMG_TEMPLATES='https://ssa.betadelivery.com/storage/app/public/uploads/post_templates/'
|
||||
|
||||
@@ -82,7 +82,7 @@ define(['./workbox-54d0af47'], (function (workbox) { 'use strict';
|
||||
"revision": "3ca0b8505b4bec776b69afdba2768812"
|
||||
}, {
|
||||
"url": "index.html",
|
||||
"revision": "0.f0vgku9v39o"
|
||||
"revision": "0.cuug5u5p6eo"
|
||||
}], {});
|
||||
workbox.cleanupOutdatedCaches();
|
||||
workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), {
|
||||
|
||||
@@ -46,7 +46,8 @@ const Login = () => {
|
||||
// Encode Basic Auth Credentials
|
||||
const username = import.meta.env.VITE_USER_NAME || ""; // Replace with actual username
|
||||
const password = import.meta.env.VITE_PASSWORD || ""; // Replace with actual password
|
||||
const basicAuth = `${username} : ${password}`; // Encode to Base64
|
||||
const credentials = `${username}:${password}`; // Encode to Base64
|
||||
const basicAuth = btoa(credentials);
|
||||
|
||||
try {
|
||||
const res = await axios.post(
|
||||
@@ -77,18 +78,22 @@ const Login = () => {
|
||||
console.log(res);
|
||||
console.log("====================================");
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('error', error);
|
||||
} catch (error: any) {
|
||||
console.log('error', error?.response);
|
||||
|
||||
if (error) {
|
||||
if (axios.isAxiosError(error) && error.response) {
|
||||
toaster.create({
|
||||
title: error.response.data?.message,
|
||||
// title: "Something Went Wrong",
|
||||
type: "info",
|
||||
});
|
||||
} else {
|
||||
toaster.create({
|
||||
// title: error?.response?.data?.message,
|
||||
title: "Something Went Wrong",
|
||||
type: "info",
|
||||
})
|
||||
// console.log("Login failed", error?.response?.data?.message);
|
||||
setIsLoading(false);
|
||||
});
|
||||
}
|
||||
setIsLoading(false);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -60,11 +60,11 @@ const FAQ = () => {
|
||||
const [deleteModal, setDeleteModal] = useState(false)
|
||||
const [selectedFaqId, setSelectedFaqId] = useState<number | null>(null);
|
||||
|
||||
// console.log('DATA', data?.data);
|
||||
console.log('DATA', data?.data.data);
|
||||
|
||||
useEffect(() => {
|
||||
if (data?.data) {
|
||||
setLocalData(data?.data);
|
||||
if (data) {
|
||||
setLocalData(data?.data.data);
|
||||
}
|
||||
}, [data]);
|
||||
|
||||
@@ -114,48 +114,53 @@ const FAQ = () => {
|
||||
|
||||
|
||||
const filteredData = localData?.filter((agency) =>
|
||||
agency.question.toLowerCase().includes(searchTerm.toLowerCase())
|
||||
);
|
||||
agency.translations.map((translation: any) => translation.question.toLowerCase()).some((question: string) =>
|
||||
question.includes(searchTerm.toLowerCase())
|
||||
))
|
||||
|
||||
const managepost = filteredData?.map((agency: FaqData, index: number) => ({
|
||||
'id': agency.id,
|
||||
"Sr. No": index + 1,
|
||||
"Question": agency.question,
|
||||
"Answer": agency.answer,
|
||||
console.log("filteredData", filteredData);
|
||||
|
||||
|
||||
"Action": (
|
||||
<HStack justifyContent="center">
|
||||
<EditDetails rowData={{ id: agency.id, question: agency.question, answer: agency.answer }} refetch={refetch} />
|
||||
const managepost = filteredData?.map((agency: FaqData, index: number) =>
|
||||
agency.translations.map((translation: any) => ({
|
||||
'id': agency.id,
|
||||
"Sr. No": index + 1,
|
||||
"Question": translation.question,
|
||||
"Answer": translation.answer,
|
||||
|
||||
<AlertDailog
|
||||
isOpen={deleteModal}
|
||||
AltertTiggerIcon={() => <Delete onClick={() => {
|
||||
setSelectedFaqId(agency.id);
|
||||
setDeleteModal(true)
|
||||
}} />}
|
||||
alertText="Delete FAQ"
|
||||
alertIcon={<Image src={"DeleteIcon"} h={"39px"} />}
|
||||
alertCaption="are you sure you want to delete ?"
|
||||
onClose={() => setDeleteModal(false)}
|
||||
onConfirm={() => {
|
||||
// console.log("Deleting FAQ with ID:", selectedFaqId); // Correct ID
|
||||
if (selectedFaqId) {
|
||||
setDeleteModal(false);
|
||||
handleDeleteFaq(selectedFaqId);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<Box>
|
||||
<Switch
|
||||
colorPalette={'teal'}
|
||||
size={"xs"}
|
||||
onChange={() => handleToggle(agency.id.toString(), Number(agency.is_active))}
|
||||
checked={Boolean(Number(agency.is_active))}
|
||||
"Action": (
|
||||
<HStack justifyContent="center">
|
||||
<EditDetails rowData={{ id: agency.id, question: translation.question, answer: translation.answer }} refetch={refetch} />
|
||||
|
||||
<AlertDailog
|
||||
isOpen={deleteModal}
|
||||
AltertTiggerIcon={() => <Delete onClick={() => {
|
||||
setSelectedFaqId(agency.id);
|
||||
setDeleteModal(true)
|
||||
}} />}
|
||||
alertText="Delete FAQ"
|
||||
alertIcon={<Image src={"DeleteIcon"} h={"39px"} />}
|
||||
alertCaption="are you sure you want to delete ?"
|
||||
onClose={() => setDeleteModal(false)}
|
||||
onConfirm={() => {
|
||||
// console.log("Deleting FAQ with ID:", selectedFaqId); // Correct ID
|
||||
if (selectedFaqId) {
|
||||
setDeleteModal(false);
|
||||
handleDeleteFaq(selectedFaqId);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</Box>
|
||||
</HStack>
|
||||
),
|
||||
}));
|
||||
<Box>
|
||||
<Switch
|
||||
colorPalette={'teal'}
|
||||
size={"xs"}
|
||||
onChange={() => handleToggle(agency.id.toString(), Number(agency.is_active))}
|
||||
checked={Boolean(Number(agency.is_active))}
|
||||
/>
|
||||
</Box>
|
||||
</HStack>
|
||||
),
|
||||
})))
|
||||
|
||||
// if (!isLoading && !data?.data) {
|
||||
// return (
|
||||
|
||||
@@ -1,27 +1,26 @@
|
||||
import { createApi } from "@reduxjs/toolkit/query/react";
|
||||
import { baseQueryWithReauth } from "./apiSlice";
|
||||
|
||||
interface Faq {
|
||||
export interface FaqData {
|
||||
id: number;
|
||||
principal_type_xid: number;
|
||||
is_active: string;
|
||||
}
|
||||
|
||||
export interface FaqData {
|
||||
id: number;
|
||||
faqs_xid: number;
|
||||
language_master_xid: number;
|
||||
question: string;
|
||||
answer: string;
|
||||
is_active: string;
|
||||
faq: Faq;
|
||||
translations:{
|
||||
id: string,
|
||||
faqs_xid: number,
|
||||
language_master_xid: number,
|
||||
question: string,
|
||||
answer: string,
|
||||
}[]
|
||||
}
|
||||
|
||||
interface ApiResponse {
|
||||
status: string;
|
||||
status_code: number;
|
||||
message: string;
|
||||
data: FaqData[];
|
||||
data: {
|
||||
data: FaqData[];
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user