Skip to content

Commit 783bc43

Browse files
committed
Move delete pinned photo
1 parent 2e6aec1 commit 783bc43

File tree

2 files changed

+81
-85
lines changed

2 files changed

+81
-85
lines changed

web/components/buttons/more-options-user-button.tsx

Lines changed: 61 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
1-
import { usePrivateUser } from 'web/hooks/use-user'
2-
import { Button } from 'web/components/buttons/button'
3-
import { Modal } from 'web/components/layout/modal'
4-
import { useState } from 'react'
5-
import { Col } from 'web/components/layout/col'
6-
import { User } from 'common/user'
1+
import {usePrivateUser} from 'web/hooks/use-user'
2+
import {Button} from 'web/components/buttons/button'
3+
import {Modal} from 'web/components/layout/modal'
4+
import {useState} from 'react'
5+
import {Col} from 'web/components/layout/col'
6+
import {User} from 'common/user'
77
import clsx from 'clsx'
8-
import { DotsHorizontalIcon } from '@heroicons/react/outline'
9-
import { useAdmin, useTrusted } from 'web/hooks/use-admin'
10-
import { UncontrolledTabs } from 'web/components/layout/tabs'
11-
import { BlockUser } from 'web/components/profile/block-user'
12-
import { ReportUser } from 'web/components/profile/report-user'
13-
import { Title } from 'web/components/widgets/title'
14-
import { Row } from '../layout/row'
15-
import { SimpleCopyTextButton } from 'web/components/buttons/copy-link-button'
16-
import { api } from 'web/lib/api'
17-
import { buildArray } from 'common/util/array'
18-
import { DeleteYourselfButton } from '../profile/delete-yourself'
8+
import {DotsHorizontalIcon} from '@heroicons/react/outline'
9+
import {useAdmin, useTrusted} from 'web/hooks/use-admin'
10+
import {UncontrolledTabs} from 'web/components/layout/tabs'
11+
import {BlockUser} from 'web/components/profile/block-user'
12+
import {ReportUser} from 'web/components/profile/report-user'
13+
import {Title} from 'web/components/widgets/title'
14+
import {Row} from '../layout/row'
15+
import {SimpleCopyTextButton} from 'web/components/buttons/copy-link-button'
16+
import {api} from 'web/lib/api'
17+
import {buildArray} from 'common/util/array'
18+
import {DeleteYourselfButton} from '../profile/delete-yourself'
1919
import {toast} from "react-hot-toast";
20+
import Router from "next/router";
2021

2122
export function MoreOptionsUserButton(props: { user: User }) {
22-
const { user } = props
23-
const { id: userId, name } = user
23+
const {user} = props
24+
const {id: userId, name} = user
2425
const currentPrivateUser = usePrivateUser()
2526
const [isModalOpen, setIsModalOpen] = useState(false)
2627
const isAdmin = useAdmin()
2728
const isTrusted = useTrusted()
2829

29-
if (!currentPrivateUser) return <div />
30+
if (!currentPrivateUser) return <div/>
3031

3132
const createdTime = new Date(user.createdTime).toLocaleDateString('en-us', {
3233
year: 'numeric',
@@ -76,6 +77,17 @@ export function MoreOptionsUserButton(props: { user: User }) {
7677
>
7778
{user.isBannedFromPosting ? 'Banned' : 'Ban User'}
7879
</Button>
80+
<Button
81+
size="sm"
82+
color="red"
83+
onClick={() => {
84+
api('remove-pinned-photo', {userId}).then(() =>
85+
Router.back()
86+
)
87+
}}
88+
>
89+
Delete pinned photo
90+
</Button>
7991
</Row>
8092
)}
8193
</div>
@@ -100,36 +112,36 @@ export function MoreOptionsUserButton(props: { user: User }) {
100112
// TODO: if isYou include a tab for users you've blocked?
101113
isYou
102114
? [
103-
{
104-
title: 'Delete Account',
105-
content: (
106-
<div className="flex min-h-[200px] items-center justify-center p-4">
107-
<DeleteYourselfButton/>
108-
</div>
109-
),
110-
},
111-
]
115+
{
116+
title: 'Delete Account',
117+
content: (
118+
<div className="flex min-h-[200px] items-center justify-center p-4">
119+
<DeleteYourselfButton/>
120+
</div>
121+
),
122+
},
123+
]
112124
: [
113-
{
114-
title: 'Block',
115-
content: (
116-
<BlockUser
117-
user={user}
118-
currentUser={currentPrivateUser}
119-
closeModal={() => setIsModalOpen(false)}
120-
/>
121-
),
122-
},
123-
{
124-
title: 'Report',
125-
content: (
126-
<ReportUser
127-
user={user}
128-
closeModal={() => setIsModalOpen(false)}
129-
/>
130-
),
131-
},
132-
],
125+
{
126+
title: 'Block',
127+
content: (
128+
<BlockUser
129+
user={user}
130+
currentUser={currentPrivateUser}
131+
closeModal={() => setIsModalOpen(false)}
132+
/>
133+
),
134+
},
135+
{
136+
title: 'Report',
137+
content: (
138+
<ReportUser
139+
user={user}
140+
closeModal={() => setIsModalOpen(false)}
141+
/>
142+
),
143+
},
144+
],
133145
])}
134146
/>
135147
</Col>

web/components/profile-carousel.tsx

Lines changed: 20 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
1-
import { useState } from 'react'
1+
import {useState} from 'react'
22
import clsx from 'clsx'
33
import Image from 'next/image'
4-
import Router from 'next/router'
5-
import { buildArray } from 'common/util/array'
6-
import { Carousel } from 'web/components/widgets/carousel'
7-
import { MODAL_CLASS, Modal } from 'web/components/layout/modal'
8-
import { Col } from 'web/components/layout/col'
9-
import { SignUpButton } from './nav/sidebar'
10-
import { Profile } from 'common/profiles/profile'
11-
import { useAdmin } from 'web/hooks/use-admin'
12-
import { Button } from 'web/components/buttons/button'
13-
import { updateProfile } from 'web/lib/api'
14-
import { Row } from 'web/components/layout/row'
15-
import { useUser } from 'web/hooks/use-user'
16-
import { PlusIcon } from '@heroicons/react/solid'
17-
import { api } from 'web/lib/api'
18-
import { EditablePhotoGrid } from './widgets/editable-photo-grid'
19-
import { AddPhotosWidget } from './widgets/add-photos'
4+
import {buildArray} from 'common/util/array'
5+
import {Carousel} from 'web/components/widgets/carousel'
6+
import {Modal, MODAL_CLASS} from 'web/components/layout/modal'
7+
import {Col} from 'web/components/layout/col'
8+
import {SignUpButton} from './nav/sidebar'
9+
import {Profile} from 'common/profiles/profile'
10+
import {Button} from 'web/components/buttons/button'
11+
import {updateProfile} from 'web/lib/api'
12+
import {Row} from 'web/components/layout/row'
13+
import {useUser} from 'web/hooks/use-user'
14+
import {PlusIcon} from '@heroicons/react/solid'
15+
import {EditablePhotoGrid} from './widgets/editable-photo-grid'
16+
import {AddPhotosWidget} from './widgets/add-photos'
2017

2118
export default function ProfileCarousel(props: { profile: Profile }) {
22-
const { profile } = props
19+
const {profile} = props
2320
const photoNums = profile.photo_urls ? profile.photo_urls.length : 0
2421

2522
const [lightboxUrl, setLightboxUrl] = useState('')
@@ -30,7 +27,6 @@ export default function ProfileCarousel(props: { profile: Profile }) {
3027
const [pinnedUrl, setPinnedUrl] = useState<string | null>(profile.pinned_url)
3128
const [photoUrls, setPhotoUrls] = useState<string[]>(profile.photo_urls ?? [])
3229

33-
const isAdmin = useAdmin()
3430
const currentUser = useUser()
3531
const isCurrentUser = currentUser?.id === profile.user_id
3632

@@ -59,7 +55,8 @@ export default function ProfileCarousel(props: { profile: Profile }) {
5955
</div>
6056
)}
6157
{photoNums > 0 && (
62-
<Col className="bg-canvas-100 dark:bg-canvas-0 text-ink-500 relative h-80 w-[250px] flex-none items-center rounded text-6xl ">
58+
<Col
59+
className="bg-canvas-100 dark:bg-canvas-0 text-ink-500 relative h-80 w-[250px] flex-none items-center rounded text-6xl ">
6360
<Col className=" m-auto items-center gap-1">
6461
<div className="select-none font-semibold">+{photoNums}</div>
6562
<SignUpButton
@@ -78,19 +75,6 @@ export default function ProfileCarousel(props: { profile: Profile }) {
7875
return (
7976
<>
8077
<div className="flex gap-2 self-end">
81-
{isAdmin && (
82-
<Button
83-
size="sm"
84-
color="red"
85-
onClick={() => {
86-
api('remove-pinned-photo', { userId: profile.user_id }).then(() =>
87-
Router.back()
88-
)
89-
}}
90-
>
91-
Admin: Delete pinned photo
92-
</Button>
93-
)}
9478
{isCurrentUser && !isEditMode && (
9579
<Button
9680
onClick={() => setIsEditMode(true)}
@@ -158,7 +142,7 @@ export default function ProfileCarousel(props: { profile: Profile }) {
158142
size="sm"
159143
className="self-start"
160144
>
161-
<PlusIcon className="mr-1 h-5 w-5" />
145+
<PlusIcon className="mr-1 h-5 w-5"/>
162146
Add photos
163147
</Button>
164148
</Col>
@@ -186,14 +170,14 @@ export default function ProfileCarousel(props: { profile: Profile }) {
186170
className="bg-ink-200 text-ink-0 group flex h-80 w-[250px] flex-none cursor-pointer snap-start items-center justify-center rounded ease-in-out"
187171
onClick={() => setAddPhotosOpen(true)}
188172
>
189-
<PlusIcon className="w-20 transition-all group-hover:w-24" />
173+
<PlusIcon className="w-20 transition-all group-hover:w-24"/>
190174
</button>
191175
)}
192176
</Carousel>
193177
)}
194178

195179
<Modal open={lightboxOpen} setOpen={setLightboxOpen}>
196-
<Image src={lightboxUrl} width={1000} height={1000} alt="" />
180+
<Image src={lightboxUrl} width={1000} height={1000} alt=""/>
197181
</Modal>
198182

199183
{isCurrentUser && (

0 commit comments

Comments
 (0)