From d66f5912139f039e3a6562e3a5092f3b06ed1ea4 Mon Sep 17 00:00:00 2001 From: Meagan Date: Mon, 25 Nov 2024 11:12:36 -0600 Subject: [PATCH 1/2] Fix review star bugs --- src/components/posts/AverageRatingStars.tsx | 17 +++---- src/components/posts/FullPostView.tsx | 45 +++++++++++++------ .../posts/ReviewPurchasedResource.tsx | 5 +-- src/components/posts/ViewPostReviews.tsx | 10 ++--- 4 files changed, 48 insertions(+), 29 deletions(-) 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..d22587f 100644 --- a/src/components/posts/ReviewPurchasedResource.tsx +++ b/src/components/posts/ReviewPurchasedResource.tsx @@ -208,7 +208,7 @@ export const ReviewPurchasedResource: Component = (props) => { } > = (props) => { = (props) => { } > = (props) => {
{reviewsArray()?.map((review) => (
-
+
{/*

{ review.overall_rating }

*/}
= (props) => { } > = (props) => { } > = (props) => { } > = (props) => { } > Date: Mon, 25 Nov 2024 11:34:45 -0600 Subject: [PATCH 2/2] Improve styling for reviews on full card --- .../posts/ReviewPurchasedResource.tsx | 19 +++++++++++++++++++ src/components/posts/ViewPostReviews.tsx | 2 +- src/i18n/UI/English.ts | 3 ++- src/i18n/UI/French.ts | 1 + src/i18n/UI/Spanish.ts | 1 + src/i18n/uiType.ts | 1 + 6 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/components/posts/ReviewPurchasedResource.tsx b/src/components/posts/ReviewPurchasedResource.tsx index d22587f..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()); @@ -456,6 +467,14 @@ export const ReviewPurchasedResource: Component = (props) => {

+ +

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

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

{ review.overall_rating }

*/}
diff --git a/src/i18n/UI/English.ts b/src/i18n/UI/English.ts index b59f2a6..6844dff 100644 --- a/src/i18n/UI/English.ts +++ b/src/i18n/UI/English.ts @@ -231,7 +231,8 @@ export const English = { resourceLinks: "Thanks for using LearnGrove! Here are your links:", externalResourceDisclaimer: "LearnGrove provides links to these external resources as a convenience. LearnGrove is not responsible for and has no control over information at any external site. LearnGrove is not responsible for the quality, content, privacy, or reliability of any linked site. In no event shall LearnGrove be responsible for your use of a linked site. Many of these external sites are funded through advertising which may make use of cookies and other tracking technology to target your interests for that advertising. Please be careful when clicking on any links on an external site to ensure you are only accessing links you intend to.", submitted: "Submitted", - overallReviewRequired: "Please include an overall rating for your review" + overallReviewRequired: "Please include an overall rating for your review", + titleRequiredIfTextEntered: "Please include a title for your review if you enter a review description", }, formLabels: { diff --git a/src/i18n/UI/French.ts b/src/i18n/UI/French.ts index e0dc745..28c445e 100644 --- a/src/i18n/UI/French.ts +++ b/src/i18n/UI/French.ts @@ -233,6 +233,7 @@ export const French = { externalResourceDisclaimer: "LearnGrove fournit des liens vers ces ressources externes pour plus de commodité. LearnGrove n'est pas responsable et n'a aucun contrôle sur les informations contenues dans aucun site externe. LearnGrove n'est pas responsable de la qualité, du contenu, de la confidentialité ou de la fiabilité de tout site lié. En aucun cas LearnGrove ne sera responsable de votre utilisation d’un site lié. Beaucoup de ces sites externes sont financés par la publicité qui peut utiliser des cookies et d'autres technologies de suivi pour cibler vos intérêts pour cette publicité. Veuillez être prudent lorsque vous cliquez sur des liens sur un site externe pour vous assurer que vous accédez uniquement aux liens auxquels vous avez l'intention d'accéder.", submitted: "Soumise", overallReviewRequired: "Veuillez inclure une note globale pour votre avis", + titleRequiredIfTextEntered: "Veuillez inclure un titre pour votre avis si vous saisissez une description d'avis", }, formLabels: { diff --git a/src/i18n/UI/Spanish.ts b/src/i18n/UI/Spanish.ts index aa1ce30..9a8e0c6 100644 --- a/src/i18n/UI/Spanish.ts +++ b/src/i18n/UI/Spanish.ts @@ -235,6 +235,7 @@ export const Spanish = { externalResourceDisclaimer: "LearnGrove proporciona enlaces a estos recursos externos para su comodidad. LearnGrove no es responsable ni tiene control sobre la información contenida en ningún sitio externo. LearnGrove no es responsable de la calidad, el contenido, la privacidad o la confiabilidad de ningún sitio vinculado. En ningún caso LearnGrove será responsable del uso que usted haga de un sitio vinculado. Muchos de estos sitios externos se financian a través de publicidad que puede utilizar cookies y otras tecnologías de seguimiento para orientar sus intereses para esa publicidad. Tenga cuidado al hacer clic en cualquier enlace de un sitio externo para asegurarse de acceder solo a los enlaces que desea.", submitted: "Enviada", overallReviewRequired: "Incluya una calificación general para su revisión", + titleRequiredIfTextEntered: "Incluya un título para su reseña si ingresa una descripción de la reseña", }, formLabels: { diff --git a/src/i18n/uiType.ts b/src/i18n/uiType.ts index 7d9e2ec..d744793 100644 --- a/src/i18n/uiType.ts +++ b/src/i18n/uiType.ts @@ -223,6 +223,7 @@ export interface uiObject { externalResourceDisclaimer: string; submitted: string, overallReviewRequired: string, + titleRequiredIfTextEntered: string, }; formLabels: {