Show featured to all users

This commit is contained in:
Pico2x 2022-10-12 17:44:43 +01:00
parent 12ed569ff6
commit b49264ddfa
2 changed files with 12 additions and 7 deletions

View File

@ -230,7 +230,7 @@ export function PinnedItems(props: {
return pinned.length > 0 || isEditable ? ( return pinned.length > 0 || isEditable ? (
<div> <div>
<Row className="mb-3 items-center justify-between"> <Row className=" items-center justify-between">
<SectionHeader label={'Featured'} href={`#`} /> <SectionHeader label={'Featured'} href={`#`} />
{isEditable && ( {isEditable && (
<Button <Button
@ -265,7 +265,7 @@ export function PinnedItems(props: {
</div> </div>
)} )}
{pinned.map((element, index) => ( {pinned.map((element, index) => (
<div className="relative my-2"> <div className="relative mb-4">
{element} {element}
{editMode && <CrossIcon onClick={() => onDeleteClicked(index)} />} {editMode && <CrossIcon onClick={() => onDeleteClicked(index)} />}

View File

@ -275,9 +275,13 @@ function renderSections(
} }
if (id === 'featured') { if (id === 'featured') {
// For now, only admins can see the featured section, until we all agree its ship-ready return (
if (!isAdmin) return <></> <FeaturedSection
return <FeaturedSection globalConfig={globalConfig} pinned={pinned} /> globalConfig={globalConfig}
pinned={pinned}
isAdmin={isAdmin}
/>
)
} }
const contracts = sectionContracts[id] const contracts = sectionContracts[id]
@ -396,8 +400,9 @@ function SearchSection(props: {
function FeaturedSection(props: { function FeaturedSection(props: {
globalConfig: GlobalConfig globalConfig: GlobalConfig
pinned: JSX.Element[] pinned: JSX.Element[]
isAdmin: boolean
}) { }) {
const { globalConfig, pinned } = props const { globalConfig, pinned, isAdmin } = props
const posts = useAllPosts() const posts = useAllPosts()
async function onSubmit(selectedItems: { itemId: string; type: string }[]) { async function onSubmit(selectedItems: { itemId: string; type: string }[]) {
@ -422,7 +427,7 @@ function FeaturedSection(props: {
<Col> <Col>
<PinnedItems <PinnedItems
posts={posts} posts={posts}
isEditable={true} isEditable={isAdmin}
pinned={pinned} pinned={pinned}
onDeleteClicked={onDeleteClicked} onDeleteClicked={onDeleteClicked}
onSubmit={onSubmit} onSubmit={onSubmit}