client: lint and fix building due to missing type
This commit is contained in:
parent
b9d26e16f7
commit
00b03db3ef
4 changed files with 20 additions and 13 deletions
|
@ -38,7 +38,7 @@ const VisibilityControl = ({ postId, visibility, setVisibility }: Props) => {
|
||||||
setPasswordModalVisible(false)
|
setPasswordModalVisible(false)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[setToast]
|
[postId, setToast, setVisibility]
|
||||||
)
|
)
|
||||||
|
|
||||||
const onSubmit = useCallback(
|
const onSubmit = useCallback(
|
||||||
|
@ -63,7 +63,7 @@ const VisibilityControl = ({ postId, visibility, setVisibility }: Props) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const submitPassword = useCallback(
|
const submitPassword = useCallback(
|
||||||
(password) => onSubmit("protected", password),
|
(password: string) => onSubmit("protected", password),
|
||||||
[onSubmit]
|
[onSubmit]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,7 @@ const Post = ({
|
||||||
setSubmitting(false)
|
setSubmitting(false)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[docs, router, setToast, title]
|
[description, docs, router, setToast, title]
|
||||||
)
|
)
|
||||||
|
|
||||||
const [isSubmitting, setSubmitting] = useState(false)
|
const [isSubmitting, setSubmitting] = useState(false)
|
||||||
|
@ -192,7 +192,7 @@ const Post = ({
|
||||||
)
|
)
|
||||||
|
|
||||||
const onChangeDescription = useCallback(
|
const onChangeDescription = useCallback(
|
||||||
(e: ChangeEvent<HTMLTextAreaElement>) => {
|
(e: ChangeEvent<HTMLInputElement>) => {
|
||||||
setDescription(e.target.value)
|
setDescription(e.target.value)
|
||||||
},
|
},
|
||||||
[setDescription]
|
[setDescription]
|
||||||
|
|
|
@ -166,9 +166,15 @@ const PostPage = ({ post: initialPost, isProtected }: Props) => {
|
||||||
content={content}
|
content={content}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
{isOwner && <span className={styles.controls}>
|
{isOwner && (
|
||||||
<VisibilityControl postId={post.id} visibility={visibility} setVisibility={setVisibility} />
|
<span className={styles.controls}>
|
||||||
</span>}
|
<VisibilityControl
|
||||||
|
postId={post.id}
|
||||||
|
visibility={visibility}
|
||||||
|
setVisibility={setVisibility}
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
<ScrollToTop />
|
<ScrollToTop />
|
||||||
</Page.Content>
|
</Page.Content>
|
||||||
</Page>
|
</Page>
|
||||||
|
|
|
@ -403,7 +403,6 @@ posts.delete("/:id", jwt, async (req: UserJwtRequest, res, next) => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
posts.put(
|
posts.put(
|
||||||
"/:id",
|
"/:id",
|
||||||
jwt,
|
jwt,
|
||||||
|
@ -415,7 +414,7 @@ posts.put(
|
||||||
visibility: Joi.string()
|
visibility: Joi.string()
|
||||||
.custom(postVisibilitySchema, "valid visibility")
|
.custom(postVisibilitySchema, "valid visibility")
|
||||||
.required(),
|
.required(),
|
||||||
password: Joi.string().optional(),
|
password: Joi.string().optional()
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
async (req: UserJwtRequest, res, next) => {
|
async (req: UserJwtRequest, res, next) => {
|
||||||
|
@ -427,7 +426,7 @@ posts.put(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const { visibility, password } = req.body;
|
const { visibility, password } = req.body
|
||||||
|
|
||||||
let hashedPassword: string = ""
|
let hashedPassword: string = ""
|
||||||
if (visibility === "protected") {
|
if (visibility === "protected") {
|
||||||
|
@ -437,14 +436,14 @@ posts.put(
|
||||||
.digest("hex")
|
.digest("hex")
|
||||||
}
|
}
|
||||||
|
|
||||||
const { id } = req.params;
|
const { id } = req.params
|
||||||
const post = await Post.findByPk(id, {
|
const post = await Post.findByPk(id, {
|
||||||
include: [
|
include: [
|
||||||
{
|
{
|
||||||
model: User,
|
model: User,
|
||||||
as: "users",
|
as: "users",
|
||||||
attributes: ["id"]
|
attributes: ["id"]
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -453,7 +452,9 @@ posts.put(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isUserAuthor(post)) {
|
if (!isUserAuthor(post)) {
|
||||||
return res.status(403).json({ error: "This post does not belong to you" })
|
return res
|
||||||
|
.status(403)
|
||||||
|
.json({ error: "This post does not belong to you" })
|
||||||
}
|
}
|
||||||
|
|
||||||
await Post.update(
|
await Post.update(
|
||||||
|
|
Loading…
Reference in a new issue