<script lang="ts">
    import Centered from "$lib/Centered.svelte";
    import EditPost from "$lib/EditPost.svelte";
    import { getMe } from "$lib/globals.svelte";
    import GuildSelect from "$lib/GuildSelect.svelte";
    import SLayout from "$lib/SLayout.svelte";
    import { RiErrorWarningLine } from "svelte-remixicon";

    let me = getMe();

    let content = $state("");
    let privacy = $state(0);


</script>


{#if me}
<SLayout title="New post">
  <form method="POST" class="card">
    <p>Posting as <strong>@{me.username}</strong></p>

    <label>
      Post to:
      <GuildSelect />
    </label>

    <EditPost bind:content bind:privacy />

    {#if privacy === 0}
      <span class="warning"><RiErrorWarningLine /> Your post will be PUBLIC!</span>
    {/if}

    <button class="card primary" disabled>Create</button>
    
  </form>

  {#snippet left()}
      ...
  {/snippet}
  
  {#snippet right()}
      ...
  {/snippet}
</SLayout>
{:else}
<Centered>
  You must be <a href="login">logged in</a> in order to create posts.
</Centered>
{/if}

<style>

form {
    display: flex;
    flex-direction: column;
}


</style>