Skip to content

Commit

Permalink
Clean up reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
meagan13 committed Nov 18, 2024
1 parent 7bfe253 commit c9913b6
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 106 deletions.
4 changes: 0 additions & 4 deletions src/components/posts/FullPostView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,13 @@ export const ViewFullPost: Component<Props> = (props) => {
} else {
setPost(userRes.body[0]);
setPostImages(userRes.body[0].image_signedUrls);
console.log("this is the post:", post());
}
} else if (res.body.length < 1 && User.session === null) {
alert(t("messages.noPost"));
location.href = `/${lang}/resources`;
} else {
setPost(res.body[0]);
setPostImages(res.body[0].image_signedUrls);
console.log("post() in FullPostView:", post());
}
} catch (error) {
console.log(error);
Expand Down Expand Up @@ -173,7 +171,6 @@ export const ViewFullPost: Component<Props> = (props) => {
function showSlide(n: number) {
let i;
const slides = document.getElementsByClassName("slide");
// console.log(slides)
const dots = document.getElementsByClassName("dot");

if (n > slides.length) {
Expand Down Expand Up @@ -413,7 +410,6 @@ export const ViewFullPost: Component<Props> = (props) => {
qa.classList.add("hidden");
}
}
// console.log(postImages());

return (
<div class="flex w-full justify-center">
Expand Down
60 changes: 3 additions & 57 deletions src/components/posts/ReviewPurchasedResource.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ interface Props {
postCreator: string;
purchaseDate: string;
createdDate: string;
// review: string;
}

async function postFormData(formData: FormData) {
Expand Down Expand Up @@ -105,7 +104,6 @@ export const ReviewPurchasedResource: Component<Props> = (props) => {
setDbReviewNum(reviewerRating);

if (reviewerRating) {
console.log("reviewerRating was true");
setShowReviewForm(false);
}
} catch (err) {
Expand All @@ -118,45 +116,6 @@ export const ReviewPurchasedResource: Component<Props> = (props) => {
});
setLoading(false);
}

// try {
// //Refactor: We aren't going to want to load all the reviews every time, probably need pagination
// //So we will need to do checks like "has this been reviewed by this user" on the server/API call
// const data = await fetchPostReviews(props.resourceId.toString());
// setReviewsData(data.body);
// } catch (err) {
// console.error(err);
// } finally {
// const arrayLength = () => reviewsData().length;
// if (arrayLength() === 0) {
// setShowReviewForm(true);
// setLoading(false);
// return;
// }
// reviewsData().map((review: Review) => {
// if (review.reviewer_id === props.userId) {
// return;
// } else {
// setShowReviewForm(true);
// }
// });

// // Set loading to false after fetch is complete
// setLoading(false);
// setTotalReviews(arrayLength);
// // Refactor: I would like to see this done on the server as part of the fetch if possible I think it will probably be faster
// // plus we won't want to return every single review but we will need to use them all to calculate this.
// // Might need to use a SQL query of some kind to store the average for the post in the view? Calculating this continually will be slow.
// if (arrayLength() > 0) {
// reviewsData().map((review: Review) => {
// setTotalRatingOfPost(
// review.overall_rating + totalRatingOfPost()
// );
// });
// setTotalRatingOfPost(totalRatingOfPost() / totalReviews());
// setTotalRatingOfPost(Math.round(totalRatingOfPost() * 2) / 2);
// }
// }
});

createEffect(async () => {
Expand All @@ -166,7 +125,6 @@ export const ReviewPurchasedResource: Component<Props> = (props) => {
let reviewerRating = data.body[0].overall_rating;
setDbReviewNum(reviewerRating);
if (reviewerRating) {
console.log("reviewerRating was true");
setShowReviewForm(false);
}
}
Expand All @@ -175,8 +133,6 @@ export const ReviewPurchasedResource: Component<Props> = (props) => {
async function submit(e: SubmitEvent, buttonId: string) {
e.preventDefault();

console.log(overallRating(), reviewTitle(), reviewText());

if (overallRating() === "") {
setShowReviewFieldAlert(true);

Expand Down Expand Up @@ -542,7 +498,7 @@ export const ReviewPurchasedResource: Component<Props> = (props) => {

<span class="invisible absolute m-4 mx-auto w-48 -translate-x-full -translate-y-2/3 rounded-md bg-background2 p-2 text-sm text-ptext2 transition-opacity peer-hover:visible dark:bg-background2-DM dark:text-ptext2-DM md:translate-x-1/4 md:translate-y-0">
{t(
"formLabels.overallRatingDescription"
"toolTips.overallRatingDescription"
)}
</span>
</div>
Expand Down Expand Up @@ -732,15 +688,6 @@ export const ReviewPurchasedResource: Component<Props> = (props) => {
</span>
</div>
</div>
{/* <input
type="number"
id=""
name="overallRating"
class="bg-background mb-4 w-full rounded border border-inputBorder1 px-1 text-ptext1 focus:border-2 focus:border-highlight1 focus:outline-none dark:border-inputBorder1-DM dark:bg-background2-DM dark:text-ptext2-DM dark:focus:border-highlight1-DM"
oninput={(e) =>
setOverallRating(e.target.value)
}
/> */}
</div>

{/* <div id="slider-reviews" class="md:grid grid-cols-2 grid-rows-7 "> */}
Expand Down Expand Up @@ -813,7 +760,7 @@ export const ReviewPurchasedResource: Component<Props> = (props) => {
p-2 text-sm text-ptext2 transition-opacity peer-hover:visible dark:bg-background2-DM dark:text-ptext2-DM md:translate-x-1/4 md:translate-y-0"
>
{t(
"formLabels.reviewTitleDescription"
"toolTips.reviewTitleDescription"
)}
</span>
</div>
Expand Down Expand Up @@ -866,7 +813,7 @@ export const ReviewPurchasedResource: Component<Props> = (props) => {
p-2 text-sm text-ptext2 transition-opacity peer-hover:visible dark:bg-background2-DM dark:text-ptext2-DM md:translate-x-1/4 md:translate-y-0"
>
{t(
"formLabels.reviwTextDescription"
"toolTips.reviewTextDescription"
)}
</span>
</div>
Expand Down Expand Up @@ -896,7 +843,6 @@ export const ReviewPurchasedResource: Component<Props> = (props) => {
{response() && (
<p class="mt-2 text-center font-bold text-alert1 dark:text-alert1-DM">
{response().message}
{/* {t("messages.submitted")} */}
</p>
)}
</Suspense>
Expand Down
3 changes: 0 additions & 3 deletions src/components/posts/ViewPostReviews.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export const ViewPostReviews: Component<Props> = (props) => {
);

onMount(async () => {
console.log("props.resourceID: ", props.resourceID);
await fetchReviews(props.resourceID);
});

Expand All @@ -40,8 +39,6 @@ export const ViewPostReviews: Component<Props> = (props) => {

setReviewsArray(data.body);

console.log("ReviewsArray: ", reviewsArray());

return data;
}

Expand Down
12 changes: 7 additions & 5 deletions src/i18n/UI/English.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,17 +288,14 @@ export const English = {
downloadable: "Downloadable",
whatDidYouThink: "What did you think?",
overallRating: "Overall Rating",
overallRatingDescription: "Please rate this resource on a scale of one to five, with one being the lowest rating and five being the highest.",
reviewQ1: "As described",
reviewQ2: "Age/grade appropriate",
reviewQ3: "Engaging",
reviewQ4: "High quality",
reviewQ5: "Easy to use/implement",
reviewQ6: "Fair price",
reviewTitle: "Review Title",
reviewTitleDescription: "The review title will appear at the top of your review. A short and specific description is recommended for the review title.",
reviewText: "Review Text",
reviwTextDescription: "The review text field provides more space for you to further explain your overall rating. We recommend one to three paragraphs.",
priceFilter: "Price",
freeResources: "Free Resources",
listName: "List Name",
Expand Down Expand Up @@ -399,7 +396,10 @@ export const English = {
"Tax category determines how sales tax will be calculated in states where LearnGrove collects and remits tax on your behalf. As stated in the Terms you are responsible for choosing the appropriate tax category for each resource you list. Click the link below to learn more.",
resourceTypes: "Please select all applicable resource types.",
price: "The price entered is the price charged to the customer. The creator will receive the remaining amount after fees. See Terms for more information about the LearnGrove fee structure.",
secular: "LearnGrove acknowledges that a secular curriculum or resource could mean different things to different creators, learners and learning facilitators. At LearnGrove we use this term to refer to both faith-neutral resources as well as those that may teach a world view that is not in alignment with any particular religion but may teach concepts that are in direct conflict with particular religion. We leave it up to our creators to determine if they feel their resources are suitable for a secular environment. We strongly recommend that you include additional detail in your description to detail how your resource addresses various topics such as creation vs evolution, religious literary texts, etc."
secular: "LearnGrove acknowledges that a secular curriculum or resource could mean different things to different creators, learners and learning facilitators. At LearnGrove we use this term to refer to both faith-neutral resources as well as those that may teach a world view that is not in alignment with any particular religion but may teach concepts that are in direct conflict with particular religion. We leave it up to our creators to determine if they feel their resources are suitable for a secular environment. We strongly recommend that you include additional detail in your description to detail how your resource addresses various topics such as creation vs evolution, religious literary texts, etc.",
overallRatingDescription: "Please rate this resource on a scale of one to five, with one being the lowest rating and five being the highest.",
reviewTitleDescription: "The review title will appear at the top of your review. A short and specific description is recommended for the review title.",
reviewTextDescription: "The review text field provides more space for you to further explain your overall rating. We recommend one to three paragraphs.",
},

apiErrors: {
Expand Down Expand Up @@ -436,7 +436,9 @@ export const English = {
singleListFavoriteError: "Error getting single list favorites",
favoriteListError: "Error fetching favorite list",
multipleListFavoriteError: "Error handling multiple lists",
},
problemPostingReview: "We're sorry, there was an issue posting your review. Please try again or contact LearnGrove support.",
noDataFound: "No data found",
},

socialModal: {
shareService: "Share this resource",
Expand Down
10 changes: 6 additions & 4 deletions src/i18n/UI/French.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,17 +289,14 @@ export const French = {
downloadable: "Téléchargeable",
whatDidYouThink: "Qu'en as-tu pensé?",
overallRating: "Note Globale",
overallRatingDescription: "Veuillez évaluer cette ressource sur une échelle de un à cinq, un étant la note la plus basse et cinq la plus élevée.",
reviewQ1: "Comme décrit",
reviewQ2: "Adapté à l'âge",
reviewQ3: "Engageante",
reviewQ4: "Haute qualité",
reviewQ5: "Facile à utiliser/mettre en œuvre",
reviewQ6: "Juste prix",
reviewTitle: "Titre de la Revue",
reviewTitleDescription: "Le titre de votre avis apparaîtra en haut de votre avis. Une description courte et précise est recommandée pour le titre de votre avis.",
reviewText: "Texte de le Revue",
reviewTextDescription: "Le champ de texte de l'avis vous offre plus d'espace pour expliquer plus en détail votre note globale. Nous vous recommandons d'écrire un à trois paragraphes.",
priceFilter: "Prix",
freeResources: "Ressources gratuites",
listName: "Nom de la Liste",
Expand Down Expand Up @@ -399,6 +396,9 @@ export const French = {
resourceTypes: "Veuillez sélectionner tous les types de ressources applicables.",
price: "Le prix saisi est le prix facturé au client. Le créateur recevra le montant restant après frais. Consultez les conditions pour plus d'informations sur la structure tarifaire LearnGrove.",
secular: "LearnGrove reconnaît qu'un programme ou une ressource laïque peut signifier différentes choses pour différents créateurs, apprenants et facilitateurs d'apprentissage. Chez LearnGrove, nous utilisons ce terme pour désigner à la fois les ressources neutres en matière de foi ainsi que celles qui peuvent enseigner une vision du monde qui n'est pas conforme à une religion particulière, mais qui peuvent enseigner des concepts qui sont en conflit direct avec une religion particulière. Nous laissons à nos créateurs le soin de déterminer s'ils estiment que leurs ressources sont adaptées à un environnement laïc. Nous vous recommandons fortement d'inclure des détails supplémentaires dans votre description pour détailler la manière dont votre ressource aborde divers sujets tels que la création par rapport à l'évolution, les textes littéraires religieux, etc.",
overallRatingDescription: "Veuillez évaluer cette ressource sur une échelle de un à cinq, un étant la note la plus basse et cinq la plus élevée.",
reviewTitleDescription: "Le titre de votre avis apparaîtra en haut de votre avis. Une description courte et précise est recommandée pour le titre de votre avis.",
reviewTextDescription: "Le champ de texte de l'avis vous offre plus d'espace pour expliquer plus en détail votre note globale. Nous vous recommandons d'écrire un à trois paragraphes.",
},

apiErrors: {
Expand Down Expand Up @@ -432,7 +432,9 @@ export const French = {
emailNotConfirmed:
"Correo electrónico no registrado. Si registró previamente esta dirección de correo electrónico, utilice la opción de olvidé mi contraseña que aparece a continuación; de lo contrario, utilice la opción de registro que aparece a continuación.",
noFavoriteLists: "Aucune liste de favoris trouvée",
},
problemPostingReview: "Nous sommes désolés, un problème est survenu lors de la publication de votre avis. Veuillez réessayer ou contacter le support LearnGrove.",
noDataFound: "Aucune donnée trouvée",
},

socialModal: {
shareService: "Partager ce ressource",
Expand Down
10 changes: 6 additions & 4 deletions src/i18n/UI/Spanish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,17 +291,14 @@ export const Spanish = {
downloadable: "Descargable",
whatDidYouThink: "¿Qué pensó Ud?",
overallRating: "Calificación General",
overallRatingDescription: "Califique este recurso en una escala del uno al cinco, siendo uno la calificación más baja y cinco la más alta.",
reviewQ1: "Como se describe",
reviewQ2: "Apropiado para edad/grado",
reviewQ3: "Atractivo",
reviewQ4: "Alta calidad",
reviewQ5: "Fácil de usar/implementar",
reviewQ6: "Precio justo",
reviewTitle: "Títula de la Calificación",
reviewTitleDescription: "El título de la reseña aparecerá en la parte superior de la misma. Se recomienda incluir una descripción breve y específica para el título de la reseña.",
reviewText: "Texto de la Calificación",
reviewTextDescription: "El campo de texto de la reseña le ofrece más espacio para explicar con más detalle su calificación general. Recomendamos que incluya entre uno y tres párrafos.",
priceFilter: "Precio",
freeResources: "Recursos gratuitos",
listName: "Nombre de la lista",
Expand Down Expand Up @@ -402,6 +399,9 @@ export const Spanish = {
resourceTypes: "Seleccione todos los tipos de recursos aplicables.",
price: "El precio introducido es el precio cobrado al cliente. El creador recibirá el importe restante después de las tarifas. Consulte los Términos para obtener más información sobre la estructura de tarifas de LearnGrove.",
secular: "LearnGrove reconoce que un plan de estudios o recurso secular podría significar cosas diferentes para diferentes creadores, estudiantes y facilitadores de aprendizaje. En LearnGrove utilizamos este término para referirnos tanto a los recursos neutrales a la fe como a aquellos que pueden enseñar una visión del mundo que no está alineada con ninguna religión en particular, pero que pueden enseñar conceptos que están en conflicto directo con una religión en particular. Dejamos en manos de nuestros creadores determinar si creen que sus recursos son adecuados para un entorno secular. Le recomendamos encarecidamente que incluya detalles adicionales en su descripción para detallar cómo su recurso aborda diversos temas, como creación versus evolución, textos literarios religiosos, etc.",
overallRatingDescription: "Califique este recurso en una escala del uno al cinco, siendo uno la calificación más baja y cinco la más alta.",
reviewTitleDescription: "El título de la reseña aparecerá en la parte superior de la misma. Se recomienda incluir una descripción breve y específica para el título de la reseña.",
reviewTextDescription: "El campo de texto de la reseña le ofrece más espacio para explicar con más detalle su calificación general. Recomendamos que incluya entre uno y tres párrafos.",
},

apiErrors: {
Expand Down Expand Up @@ -432,7 +432,9 @@ export const Spanish = {
emailNotConfirmed:
"Correo electrónico no registrado. Si registró previamente esta dirección de correo electrónico, utilice la opción de olvidé mi contraseña que aparece a continuación; de lo contrario, utilice la opción de registro que aparece a continuación.",
noFavoriteLists: "No se encontraron lista de favoritos",
},
problemPostingReview: "Lo sentimos, se produjo un problema al publicar tu reseña. Vuelve a intentarlo o ponte en contacto con el servicio de asistencia de LearnGrove.",
noDataFound: "No se encontraron datos",
},

socialModal: {
shareService: "Comparte este recurso",
Expand Down
Loading

0 comments on commit c9913b6

Please sign in to comment.