misc: switch to commentform for edit modal

This commit is contained in:
Xyphyn committed 2023-07-28 14:03:33 -07:00
1 parent f90ecb703c
commit 4cbb7381cb
2 files changed
+26 -19

No files matched your search

@@ -67,7 +67,10 @@
}} }}
> >
<span slot="title">Edit comment</span> <span slot="title">Edit comment</span>
<TextArea bind:value={newComment} /> <CommentForm
postId={node.comment_view.comment.id}
bind:value={newComment}
/>
</Modal> </Modal>
{/if} {/if}
@@ -13,24 +13,26 @@
const dispatch = createEventDispatcher<{ comment: CommentResponse }>() const dispatch = createEventDispatcher<{ comment: CommentResponse }>()
let newComment = '' export let value = ''
export let actions = true
let loading = false let loading = false
async function submit() { async function submit() {
if (!$user || !$authData || newComment == '') return if (!$user || !$authData || value == '') return
loading = true loading = true
try { try {
const response = await getClient().createComment({ const response = await getClient().createComment({
auth: $authData.token, auth: $authData.token,
content: newComment, content: value,
post_id: postId, post_id: postId,
parent_id: parentId, parent_id: parentId,
}) })
dispatch('comment', response) dispatch('comment', response)
newComment = '' value = ''
addToast( addToast(
'Success', 'Success',
'Your comment was added. You may need to refresh to see it.', 'Your comment was added. You may need to refresh to see it.',
@@ -54,20 +56,22 @@
rows={4} rows={4}
placeholder={locked ? 'This post is locked.' : 'What are you thinking?'} placeholder={locked ? 'This post is locked.' : 'What are you thinking?'}
class="!bg-slate-100 dark:!bg-zinc-900" class="!bg-slate-100 dark:!bg-zinc-900"
bind:value={newComment} bind:value
disabled={locked} disabled={locked}
/> />
<div class="sm:ml-auto sm:w-28"> {#if actions}
<Button <div class="sm:ml-auto sm:w-28">
large <Button
on:click={submit} large
color="primary" on:click={submit}
size="lg" color="primary"
class="w-full" size="lg"
{loading} class="w-full"
disabled={locked || loading} {loading}
> disabled={locked || loading}
Submit >
</Button> Submit
</div> </Button>
</div>
{/if}
</div> </div>