stacker.news/pages/items/[id]/edit.js

30 lines
1.2 KiB
JavaScript
Raw Normal View History

2021-10-26 20:49:37 +00:00
import { ITEM } from '../../../fragments/items'
import { getGetServerSideProps } from '../../../api/ssrApollo'
2021-08-11 20:13:10 +00:00
import { DiscussionForm } from '../../../components/discussion-form'
import { LinkForm } from '../../../components/link-form'
import LayoutCenter from '../../../components/layout-center'
2022-02-17 17:23:43 +00:00
import JobForm from '../../../components/job-form'
2022-08-18 18:15:24 +00:00
import { PollForm } from '../../../components/poll-form'
2023-01-26 16:11:55 +00:00
import { BountyForm } from '../../../components/bounty-form'
2021-08-11 20:13:10 +00:00
export const getServerSideProps = getGetServerSideProps(ITEM, null,
data => !data.item)
2021-08-11 20:13:10 +00:00
2021-10-26 20:49:37 +00:00
export default function PostEdit ({ data: { item } }) {
2021-08-11 20:13:10 +00:00
const editThreshold = new Date(item.createdAt).getTime() + 10 * 60000
return (
2023-05-05 17:38:56 +00:00
<LayoutCenter sub={item.subName}>
2022-09-29 20:42:33 +00:00
{item.isJob
2022-02-17 17:23:43 +00:00
? <JobForm item={item} sub={item.sub} />
: (item.url
2022-08-18 18:15:24 +00:00
? <LinkForm item={item} editThreshold={editThreshold} adv />
: (item.pollCost
2023-01-26 16:11:55 +00:00
? <PollForm item={item} editThreshold={editThreshold} adv />
: (item.bounty
? <BountyForm item={item} editThreshold={editThreshold} adv />
: <DiscussionForm item={item} editThreshold={editThreshold} adv />)))}
2021-08-11 20:13:10 +00:00
</LayoutCenter>
)
}