Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions client/src/Pages/LandingPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ const Home = () => {

useEffect(() => {
AOS.init({
duration: 1200,
once: false,
mirror: true,
});
duration: 1200,
once: true,
mirror: true,

});


}, []);

const features = [
Expand Down Expand Up @@ -78,7 +81,8 @@ const Home = () => {
];

return (
<div className="min-h-screen bg-[#f8fafc] dark:bg-gray-900 pt-20 overflow-x-hidden">
<div className="bg-[#f8fafc] dark:bg-gray-900 pt-20 overflow-y-hidden">

{/* Animated Background Elements */}
<div className="absolute inset-0 overflow-hidden">
{/* Remove animated background blobs */}
Expand Down
114 changes: 53 additions & 61 deletions client/src/Pages/Tutorial.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,69 +24,61 @@ const Tutorial = () => {
{ name: "Appliances", query: "home appliance repair" },
];

useEffect(() => {
const storedSearchHistory = localStorage.getItem("searchHistory");
const storedRecentlyViewed = localStorage.getItem("recentlyViewed");
const storedBookmarkedTutorials = localStorage.getItem(
"refixly_savedTutorials"
useEffect(() => {
const storedSearchHistory = localStorage.getItem("searchHistory");
const storedRecentlyViewed = localStorage.getItem("recentlyViewed");
const storedBookmarkedTutorials = localStorage.getItem("refixly_savedTutorials");

if (storedSearchHistory) setSearchHistory(JSON.parse(storedSearchHistory));
if (storedRecentlyViewed) setRecentlyViewed(JSON.parse(storedRecentlyViewed));
if (storedBookmarkedTutorials) setBookmarkedTutorials(JSON.parse(storedBookmarkedTutorials));
}, []);

useEffect(() => {
localStorage.setItem("searchHistory", JSON.stringify(searchHistory));
}, [searchHistory]);

useEffect(() => {
localStorage.setItem("recentlyViewed", JSON.stringify(recentlyViewed));
}, [recentlyViewed]);

useEffect(() => {
localStorage.setItem("refixly_savedTutorials", JSON.stringify(bookmarkedTutorials));
}, [bookmarkedTutorials]);

const fetchTutorials = useCallback(async (objectName, pageToken = "", append = false) => {
if (!objectName.trim()) {
setError("Please enter a search term or select a category.");
setTutorials([]);
setNextPageToken(null);
return;
}
setLoading(true);
setError(null);
try {
const res = await fetch(
`https://refixly.onrender.com/api/tutorials/${encodeURIComponent(objectName)}?pageToken=${pageToken}`
);
if (storedSearchHistory) setSearchHistory(JSON.parse(storedSearchHistory));
if (storedRecentlyViewed)
setRecentlyViewed(JSON.parse(storedRecentlyViewed));
if (storedBookmarkedTutorials)
setBookmarkedTutorials(JSON.parse(storedBookmarkedTutorials));
}, [fetchTutorials]);

useEffect(() => {
localStorage.setItem("searchHistory", JSON.stringify(searchHistory));
}, [searchHistory]);

useEffect(() => {
localStorage.setItem("recentlyViewed", JSON.stringify(recentlyViewed));
}, [recentlyViewed]);

useEffect(() => {
localStorage.setItem(
"bookmarkedTutorials",
JSON.stringify(bookmarkedTutorials)
if (!res.ok)
throw new Error((await res.json()).message || "Failed to fetch");
const data = await res.json();
setTutorials((prev) =>
append ? [...prev, ...data.tutorials] : data.tutorials
);
}, [bookmarkedTutorials]);

const fetchTutorials = async (objectName, pageToken = "", append = false) => {
if (!objectName.trim()) {
setError("Please enter a search term or select a category.");
setTutorials([]);
setNextPageToken(null);
return;
}
setLoading(true);
setError(null);
try {
const res = await fetch(
`https://refixly.onrender.com/api/tutorials/${encodeURIComponent(
objectName
)}?pageToken=${pageToken}`
);
if (!res.ok)
throw new Error((await res.json()).message || "Failed to fetch");
const data = await res.json();
setTutorials((prev) =>
append ? [...prev, ...data.tutorials] : data.tutorials
);
setNextPageToken(data.nextPageToken);
setSearchHistory((prev) =>
[objectName, ...prev.filter((term) => term !== objectName)].slice(0, 5)
);
} catch (e) {
setError(e.message);
if (!append) setTutorials([]);
setNextPageToken(null);
} finally {
setLoading(false);
}
},
[setError, setTutorials, setNextPageToken, setSearchHistory]
);
setNextPageToken(data.nextPageToken);
setSearchHistory((prev) =>
[objectName, ...prev.filter((term) => term !== objectName)].slice(0, 5)
);
} catch (e) {
setError(e.message);
if (!append) setTutorials([]);
setNextPageToken(null);
} finally {
setLoading(false);
}
}, [setError, setTutorials, setNextPageToken, setSearchHistory]);



const handleSearch = (e) => {
e.preventDefault();
Expand Down
3 changes: 2 additions & 1 deletion client/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

body {
@apply overflow-x-hidden;

}

html {
scroll-behavior: smooth;
overflow-y: scroll;
}

.glow {
Expand Down
2 changes: 1 addition & 1 deletion client/src/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import ReactDOM from 'react-dom/client';
import { BrowserRouter } from 'react-router-dom';
import App from './App.jsx';
import './index.css';
import { ThemeProvider } from './context/ThemeContext.jsx';
import { ThemeProvider } from './context/ThemeProvider.jsx';

ReactDOM.createRoot(document.getElementById('root')).render(
<React.StrictMode>
Expand Down