Login promote

This commit is contained in:
LittleSheep 2024-02-05 21:47:17 +08:00
parent f8f8c3c3b5
commit 9bc270c12f
2 changed files with 67 additions and 47 deletions

View File

@ -105,6 +105,14 @@ export default function PostItem(props: {
</div> </div>
<Show when={!props.noControl}> <Show when={!props.noControl}>
<div class="relative">
<Show when={!userinfo?.isLoggedIn}>
<div
class="px-7 py-2.5 h-12 w-full opacity-0 transition-opacity hover:opacity-100 bg-base-100 border-t border-base-200 z-[1] absolute top-0 left-0">
<b>Login!</b> To access entire platform.
</div>
</Show>
<div class="grid grid-cols-3 border-y border-base-200"> <div class="grid grid-cols-3 border-y border-base-200">
<div class="grid grid-cols-2"> <div class="grid grid-cols-2">
<div class="tooltip" data-tip="Daisuki"> <div class="tooltip" data-tip="Daisuki">
@ -155,6 +163,7 @@ export default function PostItem(props: {
</div> </div>
</div> </div>
</div> </div>
</div>
</Show> </Show>
</div> </div>

View File

@ -15,6 +15,17 @@ export default function PostPublish(props: {
}) { }) {
const userinfo = useUserinfo(); const userinfo = useUserinfo();
if (!userinfo?.isLoggedIn) {
return (
<div class="py-9 flex justify-center items-center">
<div class="text-center">
<h2 class="text-lg font-bold">Login!</h2>
<p>Or keep silent.</p>
</div>
</div>
);
}
const [submitting, setSubmitting] = createSignal(false); const [submitting, setSubmitting] = createSignal(false);
const [uploading, setUploading] = createSignal(false); const [uploading, setUploading] = createSignal(false);
@ -61,8 +72,8 @@ export default function PostPublish(props: {
props.onError(await res.text()); props.onError(await res.text());
} else { } else {
form.reset(); form.reset();
props.onPost();
props.onError(null); props.onError(null);
setTimeout(() => props.onPost(), 250);
} }
setSubmitting(false); setSubmitting(false);
} }
@ -97,8 +108,8 @@ export default function PostPublish(props: {
props.onError(await res.text()); props.onError(await res.text());
} else { } else {
form.reset(); form.reset();
props.onPost();
props.onError(null); props.onError(null);
setTimeout(() => props.onPost(), 250);
} }
setSubmitting(false); setSubmitting(false);
} }
@ -135,7 +146,7 @@ export default function PostPublish(props: {
setAttachments(attachments().concat([{ setAttachments(attachments().concat([{
...data, ...data,
author_id: userinfo?.profiles?.id, author_id: userinfo?.profiles?.id
}])); }]));
form.reset(); form.reset();
} }