pockethost / pockethost

Open source multitenant PocketBase server
https://pockethost.io
MIT License
1.09k stars 76 forks source link

Dashboard - Database Refactor + AlertBar Component #341

Closed brewhousedigital closed 11 months ago

brewhousedigital commented 1 year ago

AlertBar Changes

Old method involved creating the slide logic + the full HTML code from Daisy

{#if formError}
    <div transition:slide class="alert alert-error mb-5">
      <i class="fa-solid fa-circle-exclamation"></i>
      <span>{formError}</span>
    </div>
  {/if}

The new method now can be called like so:

<AlertBar message={formError} type="error" />

The slide behavior exists in the component and will trigger depending on if the message prop has data. This means that you'll need to set the message value to a blank string if you want to clear out the error. All the APIs calls are set up like this already.

// API Call
const handleSubmit = async() => {
  formError = "";
  successMessage = "";

  try {
    // do stuff
    successMessage = "Successful!";
  } catch (error) {
    formError = error.message
  }
}