{{ define "title" }}Preview Comment{{ end }}
{{ define "content" }}

{{ if .V.deleting }}
	<h1>Delete Comment?</h1>
{{ else }}
	<h1>Preview Comment</h1>
{{ end }}

{{ RenderComment .ResponseWriter .Request .V.NewComment .V.OriginURL false }}

{{ if .V.deleting }}
	<form action="/comments" method="POST">
		{{ CSRF }}
		<input type="hidden" name="id" value="{{ .V.NewComment.ID }}">
		<input type="hidden" name="origin" value="{{ .V.OriginURL }}">
		<input type="hidden" name="body" value="{{ .V.NewComment.Body }}">

		<p>
			Are you sure you want to delete this comment?
		</p>

		<button type="submit"
			class="btn btn-primary mr-2"
			name="submit"
			value="confirm-delete">
			Yes, Delete
		</button>
		<a href="{{ .V.OriginURL }}"
			class="btn btn-secondary">
			Cancel
		</a>
	</form>
{{ else }}
	{{ RenderCommentForm .Request .V.NewComment .V.Subject .V.ThreadID .V.OriginURL }}
{{ end }}

{{ if .V.OriginURL}}
<div class="mt-4">
	(<a href="{{ .V.OriginURL }}">back to post</a>)
</div>
{{ end }}

{{ end }}
