Landing Page#160
Conversation
Miyuki-L
left a comment
There was a problem hiding this comment.
The code isn't working as intended. There are various view places to be fixed up
|
|
||
| export const getPost = async (): Promise<APIResult<Discussion[]>> => { | ||
| try { | ||
| const response: Response = await get("/api/discussions"); |
There was a problem hiding this comment.
#158
make the chagnes here to the get like the chagnes to the createPost in this PR.
You should be sending the firebase token in to this getPost function and to the get function
There was a problem hiding this comment.
This still needs to be addressed.
getPost function needs to take in a firebase token which is then passed to the get function after callling createAuthHeader on the firebase token
| return handleAPIError("Failed to fetch posts"); | ||
| } | ||
|
|
||
| // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment |
There was a problem hiding this comment.
we should disable.
I think in our last 1-1 we can set lin 37 with as Discussion [] and it be good.
There was a problem hiding this comment.
put this in the path discussion
we don't need the separate landing page folder.
|
|
||
| .searchInput { | ||
| display: flex; | ||
| width: 384.634px; |
There was a problem hiding this comment.
We should never be using such a big px value since all screen sizes are not are the same at 384px would be too big for certain screens. We should use % value here and if you don't want it to get too small or too big min-width max-width would be friends
| <option value="author-desc">{t("Author Z-A")}</option> | ||
| </select> | ||
|
|
||
| <svg |
There was a problem hiding this comment.
let's not put the actual svg code in here. You should be able export and upload the svg and put it in our frontend/public/icons and the inport from there.
Look at the navbar and nav card components on how to do it.
| title: string; | ||
| content: string; | ||
| date: string; | ||
| author: string; |
There was a problem hiding this comment.
author here is the mongodb userId for the person creating the post you need to in the backend call the userModal and get the name before return data.
| )} | ||
|
|
||
| {/* If no posts */} | ||
| {posts.length === 0 && <div>{t("No posts yet.")}</div>} |
There was a problem hiding this comment.
you need to add these translation key's into the en.json and pt.json and es.json files for the translation to actually work.
look at the signup pages and see how its done or even the translationDemo.tsx file
| .postcard-divider { | ||
| width: 1px; | ||
| height: 100%; | ||
| /* height: 100%; */ |
| import { NextFunction, Response } from "express"; | ||
| import { Types } from "mongoose"; | ||
|
|
||
| import { getUserNameById } from "../helpers/userHelpers"; // Make sure this import exists |
There was a problem hiding this comment.
can we remove the comment on this line
|
|
||
| export const getPost = async (): Promise<APIResult<Discussion[]>> => { | ||
| try { | ||
| const response: Response = await get("/api/discussions"); |
There was a problem hiding this comment.
This still needs to be addressed.
getPost function needs to take in a firebase token which is then passed to the get function after callling createAuthHeader on the firebase token
|
|
||
| const json: unknown = await response.json(); | ||
|
|
||
| if (typeof window !== "undefined") { |
There was a problem hiding this comment.
why do wee needs this statement and the console, log
| console.info("Fetched posts JSON:", json); | ||
| } | ||
|
|
||
| if (Array.isArray(json)) { |
There was a problem hiding this comment.
we are calling our own backend and we know its expected shape and the backend return formmate won't change so there isn't much point in this conditional check. Just make sure you are parsing it correctly.
There was a problem hiding this comment.
it'll aways just use one of them since we won't be changing the response the backend provides
| const result = await getPost(); | ||
|
|
||
| if (result.success) { | ||
| if (Array.isArray(result.data)) { |
There was a problem hiding this comment.
redundant if you checked in the getPost and here. If you really want to check just do it once.
There was a problem hiding this comment.
if it failes there it fails here. if it passes both pass
| <div className={styles.sortContainer}> | ||
| <select className={styles.sortSelect} {...register("sort")}> | ||
| <option value="">{t("Sort By")}</option> | ||
| <option value="date-desc">{t("Newest First")}</option> |
There was a problem hiding this comment.
you need to put this into the the en.json and es.json and pt.json for translation to work.
. better to not have space either.
i.e. t("newest-first")
would need a "newest-first" : "Newest First" in en.json "newest-first": "whatever it is in spanish" in es.json etc
or else it'll jsut default to the key which is what you are doing but its not correctly using the translation then.
| title: discussion.title, | ||
| content: discussion.message, | ||
| date: discussion.createdAt, | ||
| author: discussion.userId, |
There was a problem hiding this comment.
shouldn't be using user id here
should be using the username you got from the now updated backend
| void fetchPosts(); | ||
| }, []); | ||
|
|
||
| useEffect(() => { |
There was a problem hiding this comment.
is this supposed to be for scroll?
It doesn't scroll.
The better option is just use css set the height of a container and then have overflow:scroll or a similar rule
| const thisWeekPosts: Post[] = []; | ||
| const earlierPosts: Post[] = []; | ||
|
|
||
| visiblePosts.forEach((post) => { |
There was a problem hiding this comment.
This and all the steps above might need to go into a useEffect for the sorting to take into effect. But I also think that we shouldn't have the splitting into sections if we do sorting.
So I think for rendering you have to check if there is sorting then display one way then dispay the other.
| // post.content.toLowerCase().includes(searchQuery), | ||
| // ); | ||
|
|
||
| // switch (data.sort) { |
There was a problem hiding this comment.
keeping this in here incase you still need sorting but the use effect below has pretty much the sae logic.
What i see happening is post is sorted but that sorted post list is never used and not correspondingly rendered on the page.
| </div> | ||
| <div className={styles.searchForm}> | ||
| {/* Wrap the search input and 'Sort By' dropdown */} | ||
| <div className={styles.searchAllSortContainer}> |
There was a problem hiding this comment.
and can we make the color solid black when an actual sorted option is selected so its more obvious that they have selected an option


Tracking Info
Resolves #115
CSS Checklist
remem%vwvhbe used instead?display:flex;and justify and align uses be used instead?Changes
I created the landing page itself.
Testing
did npm run dev to see and added a link to the landing page.
Confirmation of Change
I created fake posts to see if it looked right.