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

Content manager & featured listings #526

Merged
merged 8 commits into from
Nov 6, 2024
Merged

Content manager & featured listings #526

merged 8 commits into from
Nov 6, 2024

Conversation

ivntsng
Copy link
Contributor

@ivntsng ivntsng commented Nov 4, 2024

What does this PR do?

Added content manager role and featured listings

  • Featured Listings appear on the left side of the navbar.
  • The Content Manager role can only be assigned by Admins.
  • The maximum number of featured listings is 3.
  • A user will know they are a Content Manager if they see the badge on their account page.

If this PR changes the UI, include a screenshot below.
No featured listings and featured button on post.
Screenshot 2024-11-04 at 2 53 00 PM

Content manager role
Screenshot 2024-11-04 at 2 54 39 PM

Copy link
Member

@codekansas codekansas left a comment

Choose a reason for hiding this comment

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

plz don't merge until all my changes are in

frontend/src/components/nav/Navbar.tsx Outdated Show resolved Hide resolved
frontend/src/components/nav/Sidebar.tsx Outdated Show resolved Hide resolved
Comment on lines +187 to +189
handleItemClick(
`/item/${listing.username}/${listing.slug || listing.id}`,
)
Copy link
Member

Choose a reason for hiding this comment

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

at some point we should move to having typed urls instead of string matching, since it is pretty error prone. like a route map

type RouteConfig = {
  path: AppRoute;
  component: React.FC;
};

const routes: RouteConfig[] = [
  { path: AppRoutes.Home, component: Home },
  { path: AppRoutes.Profile, component: Profile },
  { path: AppRoutes.Settings, component: Settings },
];

// Route rendering
import { Route, Routes } from "react-router-dom";

const AppRouter: React.FC = () => (
  <Routes>
    {routes.map(({ path, component: Component }) => (
      <Route key={path} path={path} element={<Component />} />
    ))}
  </Routes>
);

frontend/src/components/pages/Profile.tsx Outdated Show resolved Hide resolved
frontend/src/components/pages/Profile.tsx Outdated Show resolved Hide resolved
store/app/crud/listings.py Outdated Show resolved Hide resolved
store/app/crud/listings.py Outdated Show resolved Hide resolved
store/app/model.py Outdated Show resolved Hide resolved
frontend/src/components/listing/ListingRenderer.tsx Outdated Show resolved Hide resolved
frontend/src/components/listing/ListingFeatureButton.tsx Outdated Show resolved Hide resolved
Comment on lines +58 to +66
if (response.error) {
addErrorAlert(response.error);
} else {
const newFeaturedState = !isFeatured;
setIsFeatured(newFeaturedState);
addAlert(
`Listing ${newFeaturedState ? "featured" : "unfeatured"} successfully`,
"success",
);
Copy link
Member

Choose a reason for hiding this comment

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

this is such a common pattern, i feel like there must be a way to do this better - should make an issue for this

frontend/src/components/nav/Navbar.tsx Outdated Show resolved Hide resolved
frontend/src/components/nav/Navbar.tsx Outdated Show resolved Hide resolved
frontend/src/components/pages/Profile.tsx Outdated Show resolved Hide resolved
store/app/crud/listings.py Outdated Show resolved Hide resolved
store/app/crud/listings.py Outdated Show resolved Hide resolved
store/app/routers/users.py Show resolved Hide resolved
@codekansas
Copy link
Member

mstm

@codekansas
Copy link
Member

ref: #526

@ivntsng ivntsng merged commit 2887be0 into master Nov 6, 2024
1 check passed
@ivntsng ivntsng deleted the content-manager branch November 6, 2024 03:16
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