fix the fonts import ,also fix the infinit scroll

This commit is contained in:
Saeed AB 2025-09-22 15:09:25 +03:30
parent f42a12c25c
commit f1114e71ec
8 changed files with 38 additions and 42 deletions

View File

@ -1,5 +1,5 @@
@import url(/font/fontiran.css);
@import "tailwindcss"; @import "tailwindcss";
@import url(/font/iranfont.css);
@theme { @theme {
/* Teal color scale */ /* Teal color scale */

View File

@ -346,10 +346,10 @@ export function DigitalInnovationPage() {
}; };
const loadMore = useCallback(() => { const loadMore = useCallback(() => {
if (!loadingMore && hasMore && !loading) { if (hasMore && !loading) {
setCurrentPage((prev) => prev + 1); setCurrentPage((prev) => prev + 1);
} }
}, [loadingMore, hasMore, loading]); }, [hasMore, loading]);
useEffect(() => { useEffect(() => {
fetchTable(true); fetchTable(true);
@ -367,12 +367,12 @@ export function DigitalInnovationPage() {
const scrollContainer = document.querySelector(".overflow-auto"); const scrollContainer = document.querySelector(".overflow-auto");
const handleScroll = () => { const handleScroll = () => {
if (!scrollContainer || !hasMore || loadingMore) return; if (!scrollContainer || !hasMore) return;
const { scrollTop, scrollHeight, clientHeight } = scrollContainer; const { scrollTop, scrollHeight, clientHeight } = scrollContainer;
const scrollPercentage = (scrollTop + clientHeight) / scrollHeight; const scrollPercentage = (scrollTop + clientHeight) / scrollHeight;
if (scrollPercentage >= 0.9) { if (scrollPercentage == 1) {
loadMore(); loadMore();
} }
}; };

View File

@ -351,10 +351,10 @@ export function GreenInnovationPage() {
}; };
const loadMore = useCallback(() => { const loadMore = useCallback(() => {
if (!loadingMore && hasMore && !loading) { if (hasMore && !loading) {
setCurrentPage((prev) => prev + 1); setCurrentPage((prev) => prev + 1);
} }
}, [loadingMore, hasMore, loading]); }, [hasMore, loading]);
useEffect(() => { useEffect(() => {
fetchProjects(true); fetchProjects(true);
@ -375,12 +375,12 @@ export function GreenInnovationPage() {
const scrollContainer = document.querySelector(".overflow-auto"); const scrollContainer = document.querySelector(".overflow-auto");
const handleScroll = () => { const handleScroll = () => {
if (!scrollContainer || !hasMore || loadingMore) return; if (!scrollContainer || !hasMore) return;
const { scrollTop, scrollHeight, clientHeight } = scrollContainer; const { scrollTop, scrollHeight, clientHeight } = scrollContainer;
const scrollPercentage = (scrollTop + clientHeight) / scrollHeight; const scrollPercentage = (scrollTop + clientHeight) / scrollHeight;
if (scrollPercentage >= 0.9) { if (scrollPercentage == 1) {
loadMore(); loadMore();
} }
}; };

View File

@ -411,10 +411,10 @@ export function InnovationBuiltInsidePage() {
}; };
const loadMore = useCallback(() => { const loadMore = useCallback(() => {
if (!loadingMore && hasMore && !loading) { if (hasMore && !loading) {
setCurrentPage((prev) => prev + 1); setCurrentPage((prev) => prev + 1);
} }
}, [loadingMore, hasMore, loading]); }, [hasMore, loading]);
useEffect(() => { useEffect(() => {
fetchProjects(true); fetchProjects(true);
@ -434,12 +434,12 @@ export function InnovationBuiltInsidePage() {
const scrollContainer = document.querySelector(".overflow-auto"); const scrollContainer = document.querySelector(".overflow-auto");
const handleScroll = () => { const handleScroll = () => {
if (!scrollContainer || !hasMore || loadingMore) return; if (!scrollContainer || !hasMore) return;
const { scrollTop, scrollHeight, clientHeight } = scrollContainer; const { scrollTop, scrollHeight, clientHeight } = scrollContainer;
const scrollPercentage = (scrollTop + clientHeight) / scrollHeight; const scrollPercentage = (scrollTop + clientHeight) / scrollHeight;
if (scrollPercentage >= 0.9) { if (scrollPercentage == 1) {
loadMore(); loadMore();
} }
}; };

View File

@ -341,10 +341,10 @@ export function ManageIdeasTechPage() {
}; };
const loadMore = useCallback(() => { const loadMore = useCallback(() => {
if (!loadingMore && hasMore && !loading) { if (hasMore && !loading) {
setCurrentPage((prev) => prev + 1); setCurrentPage((prev) => prev + 1);
} }
}, [loadingMore, hasMore, loading]); }, [hasMore, loading]);
useEffect(() => { useEffect(() => {
fetchProjects(true); fetchProjects(true);
@ -362,13 +362,13 @@ export function ManageIdeasTechPage() {
const scrollContainer = document.querySelector(".overflow-auto"); const scrollContainer = document.querySelector(".overflow-auto");
const handleScroll = () => { const handleScroll = () => {
if (!scrollContainer || !hasMore || loadingMore) return; if (!scrollContainer || !hasMore) return;
const { scrollTop, scrollHeight, clientHeight } = scrollContainer; const { scrollTop, scrollHeight, clientHeight } = scrollContainer;
const scrollPercentage = (scrollTop + clientHeight) / scrollHeight; const scrollPercentage = (scrollTop + clientHeight) / scrollHeight;
// Trigger load more when scrolled to 90% of the container // Trigger load more when scrolled to 90% of the container
if (scrollPercentage >= 0.9) { if (scrollPercentage == 1) {
loadMore(); loadMore();
} }
}; };

View File

@ -321,10 +321,10 @@ export function ProcessInnovationPage() {
}; };
const loadMore = useCallback(() => { const loadMore = useCallback(() => {
if (!loadingMore && hasMore && !loading) { if (hasMore && !loading) {
setCurrentPage((prev) => prev + 1); setCurrentPage((prev) => prev + 1);
} }
}, [loadingMore, hasMore, loading]); }, [hasMore, loading]);
useEffect(() => { useEffect(() => {
fetchProjects(true); fetchProjects(true);
@ -345,12 +345,12 @@ export function ProcessInnovationPage() {
const scrollContainer = document.querySelector(".overflow-auto"); const scrollContainer = document.querySelector(".overflow-auto");
const handleScroll = () => { const handleScroll = () => {
if (!scrollContainer || !hasMore || loadingMore) return; if (!scrollContainer || !hasMore) return;
const { scrollTop, scrollHeight, clientHeight } = scrollContainer; const { scrollTop, scrollHeight, clientHeight } = scrollContainer;
const scrollPercentage = (scrollTop + clientHeight) / scrollHeight; const scrollPercentage = (scrollTop + clientHeight) / scrollHeight;
if (scrollPercentage >= 0.9) { if (scrollPercentage == 1) {
loadMore(); loadMore();
} }
}; };

View File

@ -255,7 +255,7 @@ export function ProductInnovationPage() {
const observerRef = useRef<HTMLDivElement>(null); const observerRef = useRef<HTMLDivElement>(null);
const fetchingRef = useRef(false); const fetchingRef = useRef(false);
const handleProjectDetails = async (project: ProductInnovationData) => { const handleProjectDetails = async (project: ProductInnovationData) => {
setSelectedProjectDetails(project); setSelectedProjectDetails(project);
@ -267,7 +267,7 @@ export function ProductInnovationPage() {
const fetchPopupData = async (project: ProductInnovationData) => { const fetchPopupData = async (project: ProductInnovationData) => {
try { try {
setPopupLoading(true); setPopupLoading(true);
// Fetch popup stats // Fetch popup stats
const statsResponse = await apiService.call({ const statsResponse = await apiService.call({
innovation_product_popup_function1: { innovation_product_popup_function1: {
@ -296,9 +296,9 @@ export function ProductInnovationPage() {
const chartData = JSON.parse(chartResponse.data); const chartData = JSON.parse(chartResponse.data);
if (Array.isArray(chartData)) { if (Array.isArray(chartData)) {
// Set all data for line chart // Set all data for line chart
// Filter data for the selected project (bar chart) // Filter data for the selected project (bar chart)
const filteredData = chartData.filter(item => const filteredData = chartData.filter(item =>
item.product_title === project?.title item.product_title === project?.title
); );
setAllExportData(chartData); setAllExportData(chartData);
@ -314,10 +314,10 @@ export function ProductInnovationPage() {
}; };
const loadMore = useCallback(() => { const loadMore = useCallback(() => {
if (!loadingMore && hasMore && !loading) { if (hasMore && !loading) {
setCurrentPage((prev) => prev + 1); setCurrentPage((prev) => prev + 1);
} }
}, [loadingMore, hasMore, loading]); }, [hasMore, loading]);
const fetchProjects = async (reset = false) => { const fetchProjects = async (reset = false) => {
if (fetchingRef.current) { if (fetchingRef.current) {
@ -497,12 +497,12 @@ export function ProductInnovationPage() {
const scrollContainer = document.querySelector(".overflow-auto"); const scrollContainer = document.querySelector(".overflow-auto");
const handleScroll = () => { const handleScroll = () => {
if (!scrollContainer || !hasMore || loadingMore) return; if (!scrollContainer || !hasMore) return;
const { scrollTop, scrollHeight, clientHeight } = scrollContainer; const { scrollTop, scrollHeight, clientHeight } = scrollContainer;
const scrollPercentage = (scrollTop + clientHeight) / scrollHeight; const scrollPercentage = (scrollTop + clientHeight) / scrollHeight;
if (scrollPercentage >= 0.9) { if (scrollPercentage == 1) {
loadMore(); loadMore();
} }
}; };
@ -516,7 +516,7 @@ export function ProductInnovationPage() {
scrollContainer.removeEventListener("scroll", handleScroll); scrollContainer.removeEventListener("scroll", handleScroll);
} }
}; };
}, [loadMore, hasMore, loadingMore]); }, [loadMore, hasMore]);
const handleSort = (field: string) => { const handleSort = (field: string) => {
fetchingRef.current = false; fetchingRef.current = false;
@ -548,7 +548,7 @@ export function ProductInnovationPage() {
return seasons.map(season => { return seasons.map(season => {
const seasonData: any = { season }; const seasonData: any = { season };
products.forEach(product => { products.forEach(product => {
const productData = data.find(item => const productData = data.find(item =>
item.product_title === product && item.full_season === season item.product_title === product && item.full_season === season
); );
seasonData[product] = productData?.export_revenue_sum > 0 && productData ? Math.round(productData?.export_revenue_sum) : 0; seasonData[product] = productData?.export_revenue_sum > 0 && productData ? Math.round(productData?.export_revenue_sum) : 0;
@ -1042,7 +1042,7 @@ export function ProductInnovationPage() {
)} )}
</div> </div>
</div> </div>
{/* Left Column - Project Description and Charts */} {/* Left Column - Project Description and Charts */}
{popupLoading ? ( {popupLoading ? (
<div className="lg:col-span-2 border-r-2 flex flex-col gap-2 pr-4 pb-2 border-r-[#5F6284]/50"> <div className="lg:col-span-2 border-r-2 flex flex-col gap-2 pr-4 pb-2 border-r-[#5F6284]/50">
@ -1153,12 +1153,10 @@ export function ProductInnovationPage() {
</div> </div>
)} )}
</div> </div>
</DialogContent> </DialogContent>
</Dialog> </Dialog>
</DashboardLayout> </DashboardLayout>
); );
} }

View File

@ -264,10 +264,10 @@ export function ProjectManagementPage() {
}; };
const loadMore = useCallback(() => { const loadMore = useCallback(() => {
if (!loadingMore && hasMore && !loading) { if (hasMore && !loading) {
setCurrentPage((prev) => prev + 1); setCurrentPage((prev) => prev + 1);
} }
}, [loadingMore, hasMore, loading]); }, [hasMore, loading]);
useEffect(() => { useEffect(() => {
fetchProjects(true); fetchProjects(true);
@ -283,18 +283,16 @@ export function ProjectManagementPage() {
// Infinite scroll observer // Infinite scroll observer
useEffect(() => { useEffect(() => {
const scrollContainer = document.querySelector(".overflow-auto"); const scrollContainer = document.querySelector(".overflow-auto");
const handleScroll = () => { const handleScroll = () => {
if (!scrollContainer || !hasMore || loadingMore) return; if (!scrollContainer || !hasMore) return;
const { scrollTop, scrollHeight, clientHeight } = scrollContainer; const { scrollTop, scrollHeight, clientHeight } = scrollContainer;
const scrollPercentage = (scrollTop + clientHeight) / scrollHeight; const scrollPercentage = (scrollTop + clientHeight) / scrollHeight;
// Trigger load more when scrolled to 90% of the container // Trigger load more when scrolled to 90% of the container
if (scrollPercentage >= 0.9) { if (scrollPercentage == 1) {
loadMore(); loadMore();
} }
}; };
if (scrollContainer) { if (scrollContainer) {
scrollContainer.addEventListener("scroll", handleScroll); scrollContainer.addEventListener("scroll", handleScroll);
} }
@ -304,7 +302,7 @@ export function ProjectManagementPage() {
scrollContainer.removeEventListener("scroll", handleScroll); scrollContainer.removeEventListener("scroll", handleScroll);
} }
}; };
}, [loadMore, hasMore, loadingMore]); }, [loadMore, hasMore]);
const handleSort = (field: string) => { const handleSort = (field: string) => {
fetchingRef.current = false; // Reset fetching state on sort fetchingRef.current = false; // Reset fetching state on sort