Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edit Page Enhancements #1319

Merged
merged 6 commits into from
Apr 11, 2024
Merged

Edit Page Enhancements #1319

merged 6 commits into from
Apr 11, 2024

Conversation

GeorgeCloud
Copy link
Contributor

@GeorgeCloud GeorgeCloud commented Feb 8, 2024

This ticket fixes issues with the edit page UI here is the ticket

We need to merge these API changes before this PR.

Screenshot 2024-02-27 at 3 55 55 PM

Copy link
Member

@richardxia richardxia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really awesome! I left some suggestions, but this is shaping up to be great, and my experience from checking this out locally was already a lot better than what we had before.

Also, in the future, if it's not too much trouble, could you include a screenshot of the UI in the PR description? It's not critical, but I definitely find stuff like that helpful as a reviewer.

app/pages/EditBreakingNewsPage.scss Outdated Show resolved Hide resolved
app/pages/EditBreakingNewsPage.scss Outdated Show resolved Hide resolved
app/pages/EditBreakingNewsPage.scss Outdated Show resolved Hide resolved
app/pages/EditBreakingNewsPage.scss Show resolved Hide resolved
app/pages/EditBreakingNewsPage.tsx Outdated Show resolved Hide resolved
@richardxia
Copy link
Member

Also, you're failing lint here, at least the code formatting check. To automatically reformat your code, you can run docker-compose run --rm web npm run prettier:fix. We have a standard Prettier setup, so you could also install the Prettier plugin for your editor, and it should allow you to format your code based on the config file in this repo.

Copy link
Member

@richardxia richardxia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making these updates! This mostly looks good to me. I think one last functional request I'd make is to sort the articles by status, at least on initial page load. I'm thinking we should do the order "Scheduled", "Active", "Expired", though I think it could also make sense to do "Active", "Scheduled", "Expired". Either way, the expired articles really should go to the bottom of the list, because otherwise, as we accumulate more and more articles, the expired ones will take up more space and push down the other two status.

Also, it looks like you're still failing the lint checks. I think some of it should be automatically fixable by running Prettier, but the remaining ones you may need to fix up manually.

app/pages/EditBreakingNewsPage.scss Outdated Show resolved Hide resolved

sortedArticles.sort((a, b) => {
const statusOrder = ["Scheduled", "Active", "Expired"];
const statusA = articleStatus(a).props.children;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this actually work? Even if it does, I don't think we should be trying to access the props on a nested React component like this. Instead, I'd factor this out into two separate pieces: 1) a pure function that just returns a status string, and 2) a React component that renders the badge icon.

const onSave = (articleId: string) => {
const article = breakingNewsArticles.find(
({ id }: any) => id === articleId
const articleStatus = (article: NewsArticle): JSX.Element | null => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to my other comment, to turn this into a true React component, change the argument from just a plain article to an an object with an article property. Also, the convention for React components is to capitalize the first letter of the name, since React components were originally written only as classes, before they added function-based components.

Suggested change
const articleStatus = (article: NewsArticle): JSX.Element | null => {
const ArticleStatus = ({ article}: { article: NewsArticle}) => {

(The return type can usually be omitted from React components as well)

@richardxia richardxia merged commit af7f65f into master Apr 11, 2024
5 checks passed
@richardxia richardxia deleted the edit-page-enhancements branch April 11, 2024 04:23
@richardxia
Copy link
Member

Thanks again for working on this @GeorgeCloud! This will be greatly appreciated by the team!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants