diff --git a/src/components/common/Header.tsx b/src/components/common/Header.tsx index 44bf2666..026cfbfe 100644 --- a/src/components/common/Header.tsx +++ b/src/components/common/Header.tsx @@ -16,7 +16,6 @@ const lang = getLangFromUrl(new URL(window.location.href)); const t = useTranslations(lang); export const Header: Component = () => { - const screenSize = useStore(windowSize); return ( @@ -27,7 +26,11 @@ export const Header: Component = () => { - +
@@ -95,7 +98,7 @@ export const Header: Component = () => {
- +
diff --git a/src/components/common/HeaderSearchBar.tsx b/src/components/common/HeaderSearchBar.tsx index 83aa6746..7138aee8 100644 --- a/src/components/common/HeaderSearchBar.tsx +++ b/src/components/common/HeaderSearchBar.tsx @@ -32,6 +32,7 @@ export const SearchBar: Component = () => { searchString() !== "null" ) { localStorage.setItem("searchString", searchString()); + console.log("Set Search to Local Storage", searchString()); } // console.log(window.location.href) @@ -67,13 +68,11 @@ export const SearchBar: Component = () => { return (
- setSearchString(e.target.value)} diff --git a/src/components/common/MobileProfileBtn.tsx b/src/components/common/MobileProfileBtn.tsx index f715b00a..c2fc3296 100644 --- a/src/components/common/MobileProfileBtn.tsx +++ b/src/components/common/MobileProfileBtn.tsx @@ -15,6 +15,7 @@ const lang = getLangFromUrl(new URL(window.location.href)); const t = useTranslations(lang); const { data: User, error: UserError } = await supabase.auth.getSession(); + export const MobileProfileBtn = () => { const [isUser, setIsUser] = createSignal(false); diff --git a/src/components/common/ProfileBtn.tsx b/src/components/common/ProfileBtn.tsx index 7e896811..4213e52b 100644 --- a/src/components/common/ProfileBtn.tsx +++ b/src/components/common/ProfileBtn.tsx @@ -10,11 +10,11 @@ import { CreatorRegistrationRouting } from "../members/CreatorRegistrationRoutin import { LanguagePicker } from "./LanguagePicker"; import { getLangFromUrl, useTranslations } from "../../i18n/utils"; - const lang = getLangFromUrl(new URL(window.location.href)); const t = useTranslations(lang); const { data: User, error: UserError } = await supabase.auth.getSession(); + export const ProfileBtn = () => { const [isUser, setIsUser] = createSignal(false); @@ -74,11 +74,11 @@ export const ProfileBtn = () => {
diff --git a/src/components/common/cart/CartCardDonateMobile.tsx b/src/components/common/cart/CartCardDonateMobile.tsx index ba1ae86a..960475ca 100644 --- a/src/components/common/cart/CartCardDonateMobile.tsx +++ b/src/components/common/cart/CartCardDonateMobile.tsx @@ -36,7 +36,7 @@ export const CartCardDonateMobile: Component = (props) => { src={LearnGroveCommunity.src} // TODO Internationalize alt="Build Your LearnGrove" - class="h-full w-full rounded-lg bg-background1 object-cover dark:bg-icon1-DM" + class="h-22 w-22 rounded-lg bg-background1 object-cover dark:bg-icon1-DM" />
diff --git a/src/components/common/cart/CartCardMobile.tsx b/src/components/common/cart/CartCardMobile.tsx index 5c825770..0104d955 100644 --- a/src/components/common/cart/CartCardMobile.tsx +++ b/src/components/common/cart/CartCardMobile.tsx @@ -27,38 +27,38 @@ export const CartCardMobile: Component = (props) => { createEffect(async () => { if (props.items) { - const updatedItems = await Promise.all( - props.items.map(async (item: Post) => { - const newItem = { ...item }; - newItem.image_urls - ? (newItem.image_url = await downloadPostImage( - newItem.image_urls.split(",")[0] - )) - : (newItem.image_url = undefined); + // const updatedItems = await Promise.all( + // props.items.map(async (item: Post) => { + // const newItem = { ...item }; + // newItem.image_urls + // ? (newItem.image_url = await downloadPostImage( + // newItem.image_urls.split(",")[0] + // )) + // : (newItem.image_url = undefined); - const { data: sellerImg, error: sellerImgError } = - await supabase - .from("sellerview") - .select("*") - .eq("seller_id", newItem.seller_id); + // const { data: sellerImg, error: sellerImgError } = + // await supabase + // .from("sellerview") + // .select("*") + // .eq("seller_id", newItem.seller_id); - if (sellerImgError) { - console.log(sellerImgError); - } + // if (sellerImgError) { + // console.log(sellerImgError); + // } - if (sellerImg) { - if (sellerImg[0].image_url) { - newItem.seller_img = await downloadUserImage( - sellerImg[0].image_url - ); - } - } + // if (sellerImg) { + // if (sellerImg[0].image_url) { + // newItem.seller_img = await downloadUserImage( + // sellerImg[0].image_url + // ); + // } + // } - return newItem; - }) - ); + // return newItem; + // }) + // ); - setNewItems(updatedItems); + setNewItems(props.items); } }); @@ -127,7 +127,7 @@ export const CartCardMobile: Component = (props) => { ? "User Image" : "No image" } - class="h-full w-full rounded-lg bg-background1 object-cover dark:bg-icon1-DM" + class="h-22 w-22 rounded-lg bg-background1 object-cover dark:bg-icon1-DM" loading="lazy" onload={(e) => { lazyLoadImage( diff --git a/src/components/common/cart/ViewCart.tsx b/src/components/common/cart/ViewCart.tsx index a7d72454..c33ed4ce 100644 --- a/src/components/common/cart/ViewCart.tsx +++ b/src/components/common/cart/ViewCart.tsx @@ -26,7 +26,6 @@ const t = useTranslations(lang); export const CartView = () => { const [totalItems, setTotalItems] = createSignal(0); - const [itemsDetails, setItemsDetails] = createSignal([]); const [cartTotal, setCartTotal] = createSignal(0); const [donation, setDonation] = createSignal(0); const screenSize = useStore(windowSize); @@ -75,7 +74,6 @@ export const CartView = () => { let total = 0; { console.log("items in cart: " + items.length); - console.log("Item Details: " + itemsDetails()); } items.forEach((item: Post) => { if (item.price) { diff --git a/src/components/home/Home.tsx b/src/components/home/Home.tsx index 72c1d6cb..6cdfba0d 100644 --- a/src/components/home/Home.tsx +++ b/src/components/home/Home.tsx @@ -1,31 +1,18 @@ -import type { Component } from "solid-js"; +import type { Component, JSXElement } from "solid-js"; import type { FilterPostsParams, Post } from "@lib/types"; -import { createEffect, createSignal, Show, onMount } from "solid-js"; +import { createSignal, Show, onMount } from "solid-js"; import { useStore } from "@nanostores/solid"; import { windowSize } from "@components/common/WindowSizeStore"; -import { HomeStickyFilters } from "./HomeStickyFilters"; import { HomeCard } from "@components/home/HomeCard"; -import { HomeSubjectCarousel } from "@components/home/HomeSubjectCarousel"; import { HomeGradeCarousel } from "./HomeGradeCarousel"; -import supabase from "../../lib/supabaseClient"; -import { ui } from "../../i18n/ui"; -import type { uiObject } from "../../i18n/uiType"; -import { getLangFromUrl, useTranslations } from "../../i18n/utils"; -import stripe from "@lib/stripe"; -import * as allFilters from "../posts/fetchPosts"; -import { IconH1 } from "@tabler/icons-solidjs"; - -const lang = getLangFromUrl(new URL(window.location.href)); -const t = useTranslations(lang); -const values = ui[lang] as uiObject; -const productSubjects = values.subjectCategoryInfo.subjects; +import { useTranslations } from "../../i18n/utils"; -interface Props { - id: string | undefined; -} +// const lang = getLangFromUrl(new URL(window.location.href)); -function redirectToResourcesPage() { - window.location.href = `/${lang}/resources`; +interface Props { + lang: "en" | "es" | "fr"; + stickyFilters: JSXElement; + subjectCarousel: JSXElement; } async function fetchPosts({ @@ -59,22 +46,10 @@ async function fetchPosts({ return data; } -export const Home: Component = () => { - const [posts, setPosts] = createSignal>([]); - const [currentPosts, setCurrentPosts] = createSignal>([]); +export const Home: Component = (props) => { + const [lang, setLang] = createSignal<"en" | "es" | "fr">(props.lang); const [popularPosts, setPopularPosts] = createSignal>([]); const [newPosts, setNewPosts] = createSignal>([]); - const [subjectFilters, setSubjectFilters] = createSignal>([]); - const [gradeFilters, setGradeFilters] = createSignal>([]); - const [resourceTypeFilters, setResourceTypeFilters] = createSignal< - Array - >([]); - const [fileTypeFilters, setFileTypeFilters] = createSignal>( - [] - ); - const [standardsFilters, setStandardsFilters] = createSignal(""); - - let test: any; onMount(async () => { const res = await fetchPosts({ @@ -83,7 +58,9 @@ export const Home: Component = () => { searchString: "", resourceFilters: [], secularFilter: false, - lang: lang, + lang: lang(), + listing_status: true, + draft_status: false, }); if ( @@ -103,8 +80,10 @@ export const Home: Component = () => { searchString: "", resourceFilters: [], secularFilter: false, - lang: lang, + lang: lang(), orderAscending: true, + listing_status: true, + draft_status: false, }); if ( @@ -121,12 +100,19 @@ export const Home: Component = () => { const screenSize = useStore(windowSize); + const t = useTranslations(props.lang); + function redirectToResourcesPage() { + window.location.href = `/${language}/resources`; + } + + const language = lang(); + return ( diff --git a/src/components/home/HomeCard.tsx b/src/components/home/HomeCard.tsx index bab2c79e..dd196257 100644 --- a/src/components/home/HomeCard.tsx +++ b/src/components/home/HomeCard.tsx @@ -1,85 +1,35 @@ import type { Component } from "solid-js"; import type { Post } from "@lib/types"; -import { createSignal, createEffect, Show, onMount } from "solid-js"; -import supabase from "../../lib/supabaseClient"; -import { ui } from "../../i18n/ui"; -import type { uiObject } from "../../i18n/uiType"; -import { getLangFromUrl, useTranslations } from "../../i18n/utils"; -import { - downloadPostImage, - downloadUserImage, - lazyLoadImage, -} from "@lib/imageHelper"; +import { Show, createSignal } from "solid-js"; +import { useTranslations } from "../../i18n/utils"; +import { lazyLoadImage } from "@lib/imageHelper"; import postPlaceHolder from "@src/assets/postPlaceHolder.svg"; import person from "@src/assets/person.svg"; -const lang = getLangFromUrl(new URL(window.location.href)); -const t = useTranslations(lang); - -// const values = ui[lang] as uiObject -const values = ui[lang] as uiObject; -const productCategories = values.subjectCategoryInfo.subjects; - interface Props { // Define the type for the filterPosts prop posts: Array; + lang: "en" | "es" | "fr"; } export const HomeCard: Component = (props) => { - const [newPosts, setNewPosts] = createSignal>([]); - const [postImages, setPostImages] = createSignal([]); - - createEffect(async () => { - if (props.posts) { - console.log("props.posts"); - console.log(props.posts); - const updatedPosts = await Promise.all( - props.posts.map(async (post: Post) => { - post.image_urls - ? (post.image_url = await downloadPostImage( - post.image_urls.split(",")[0] - )) - : (post.image_url = undefined); - // Set the default quantity to 1 - post.quantity = 1; - - const { data, error } = await supabase - .from("sellerview") - .select("*") - .eq("seller_id", post.seller_id); - - if (error) { - console.log(error); - } - - if (data) { - if (data[0].image_url) { - post.seller_img = await downloadUserImage( - data[0].image_url - ); - } - } - - return post; - }) - ); + const [lang, setLang] = createSignal<"en" | "es" | "fr">(props.lang); - setNewPosts(updatedPosts); - } - }); + const t = useTranslations(lang()); return (