<script>
  import pluralize from "pluralize";
  import ModalFrame from "../components/ModalFrame";

  import modal from "../stores/modal";
  import stufflog from "../stores/stufflog";

  export let activity = {};

  let error = null;

  function removeSubActivity() {
    stufflog.deleteActivity(activity.id).then(() => {
      modal.close();
    }).catch(err => {
      error = err.message || err;
      console.warn(err);
    });
  }
</script>

<ModalFrame title={`Remove ${activity.name}`} error={error} closable on:close={() => modal.close()}>
  <form on:submit|preventDefault={() => removeSubActivity()}>
    <p>
      Are you sure you want to remove activity <b>{activity.name}</b>?
    </p>

    <hr />

    <button type="submit">Yes, do as I say</button>
  </form>
</ModalFrame>