diff --git a/src/components/posts/AverageRatingStars.tsx b/src/components/posts/AverageRatingStars.tsx index 70a1c0a..9c07aca 100644 --- a/src/components/posts/AverageRatingStars.tsx +++ b/src/components/posts/AverageRatingStars.tsx @@ -75,7 +75,7 @@ export const AverageRatingStars: Component = (props) => { >
= (props) => { } > = (props) => { = 1 && averageRating() < 2) || - (averageRating() >= 2 && averageRating() < 3) || - (averageRating() >= 3 && averageRating() < 4) || - (averageRating() >= 4 && averageRating() < 5) || - averageRating() === 5 + averageRating() >= 2 + // (averageRating() >= 1 && averageRating() < 2) || + // (averageRating() >= 2 && averageRating() < 3) || + // (averageRating() >= 3 && averageRating() < 4) || + // (averageRating() >= 4 && averageRating() < 5) || + // averageRating() === 5 } fallback={
@@ -147,7 +148,7 @@ export const AverageRatingStars: Component = (props) => { } > = (props) => { const [session, setSession] = createSignal(null); const [editRender, setEditRender] = createSignal(false); const [review, setReview] = createSignal(); + const [resourceReviews, setResourceReviews] = createSignal>( + [] + ); + const [loading, setLoading] = createSignal(true); if (UserError) { console.log("User Error: " + UserError.message); @@ -92,6 +98,10 @@ export const ViewFullPost: Component = (props) => { } // setTestImages(test2); + onMount(async () => { + await getResourceReviews(props.postId); + }); + createEffect(() => { if (props.postId === undefined) { location.href = `/${lang}/404`; @@ -137,6 +147,27 @@ export const ViewFullPost: Component = (props) => { } }; + const getResourceReviews = async (postID: any) => { + setLoading(true); + + const { data: reviews, error } = await supabase + .from("reviews") + .select("*") + .eq("resource_id", postID); + + if (error) { + console.log("Reviews Error: " + error.code + " " + error.message); + return; + } + + console.log("reviews data: ", reviews); + + setResourceReviews(reviews); + console.log("resourceReviews signal: ", resourceReviews()); + + setLoading(false); + }; + const fetchOwnedPost = async function (id: number) { const { data, error } = await supabase.from("orders").select("*"); @@ -847,18 +878,6 @@ export const ViewFullPost: Component = (props) => { - - - - {/* */} {/* NOTE: Quantity and AddToCart styles updated/correct in mobile merge */}
diff --git a/src/components/posts/ReviewPurchasedResource.tsx b/src/components/posts/ReviewPurchasedResource.tsx index d3016f0..4bce6f6 100644 --- a/src/components/posts/ReviewPurchasedResource.tsx +++ b/src/components/posts/ReviewPurchasedResource.tsx @@ -92,6 +92,7 @@ export const ReviewPurchasedResource: Component = (props) => { const [showReviewForm, setShowReviewForm] = createSignal(true); const [dbReviewNum, setDbReviewNum] = createSignal(0); const [showReviewFieldAlert, setShowReviewFieldAlert] = createSignal(false); + const [showTitleAlert, setShowTitleAlert] = createSignal(false); onMount(async () => { try { @@ -143,6 +144,16 @@ export const ReviewPurchasedResource: Component = (props) => { return false; } + if (reviewText() !== "" && reviewTitle() === "") { + setShowTitleAlert(true); + + setTimeout(() => { + setShowTitleAlert(false); + }, 3000); + + return false; + } + const formData = new FormData(e.target as HTMLFormElement); formData.append("review_title", reviewTitle()); formData.append("review_text", reviewText()); @@ -208,7 +219,7 @@ export const ReviewPurchasedResource: Component = (props) => { } > = (props) => { = (props) => { } > = (props) => {

+ +

+ {t( + "messages.titleRequiredIfTextEntered" + )} +

+ +
* diff --git a/src/components/posts/ViewPostReviews.tsx b/src/components/posts/ViewPostReviews.tsx index 6c54b2b..6f7f401 100644 --- a/src/components/posts/ViewPostReviews.tsx +++ b/src/components/posts/ViewPostReviews.tsx @@ -50,8 +50,8 @@ export const ViewPostReviews: Component = (props) => { >
{reviewsArray()?.map((review) => ( -
-
+
+
{/*

{ review.overall_rating }

*/}
= (props) => { } > = (props) => { } > = (props) => { } > = (props) => { } >