Skip to content

Commit

Permalink
Fixed Sprig errors
Browse files Browse the repository at this point in the history
- removed sprig script
- updated success and error checking conditonals
  • Loading branch information
ryanirelan committed Jun 14, 2024
1 parent 8ae1cc0 commit a5a8c48
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 43 deletions.
36 changes: 22 additions & 14 deletions templates/_components/forgot-password-form.twig
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,44 @@
Your Account Email Address
</label>
<div class="mt-1">
<input id="email" name="loginName" type="email" autocomplete="email" class="appearance-none block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none sm:text-sm" required value="">
<input id="email" name="loginName" type="email" autocomplete="email"
class="appearance-none block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none sm:text-sm"
required value="">
</div>
</div>
<div>
<button type="submit" class="w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-gray-800 hover:bg-gray-700 focus:outline-none">
<button type="submit"
class="w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-gray-800 hover:bg-gray-700 focus:outline-none">
<div id="spinner" class="htmx-indicator pr-4">
<svg class="animate-spin h-5 w-5 text-white" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
<svg class="animate-spin h-5 w-5 text-white" xmlns="http://www.w3.org/2000/svg" fill="none"
viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor"
stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor"
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
</div>
Request Password Reset
</button>
{% if errors is defined %}
<div class="rounded-lg bg-red-50 p-4 mt-4 border-2 border-red-100">
<div class="flex">
<div class="ml-3">
{{ forms.errorsList(errors) }}
{% if sprig.isError %}
{% if errors is defined %}
<div class="rounded-lg bg-red-50 p-4 mt-4 border-2 border-red-100">
<div class="flex">
<div class="ml-3">
{{ forms.errorsList(errors) }}
</div>
</div>
</div>
</div>

{% endif %}
{% endif %}

{% if success is defined and success %}
{% if sprig.isSuccess %}
<div class="rounded-lg bg-green-50 p-4 mt-4 border-2 border-green-100">
<div class="flex">
<div class="ml-3">
<p class="text-sm font-medium text-green-800">
We just sent an email to your account email address. Use the link in the email to reset your password.
We just sent an email to your account email address. Use the link in the email to
reset your password.
</p>
</div>
</div>
Expand Down
42 changes: 32 additions & 10 deletions templates/_components/register-form.twig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
First Name
</label>
<div class="mt-1">
<input id="first-name" name="firstName" type="text" autocomplete="first-name" class="appearance-none block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 sm:text-sm" required value="{{ user.firstName ?? null }}">
<input id="first-name" name="firstName" type="text" autocomplete="first-name"
class="appearance-none block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 sm:text-sm"
required value="{{ user.firstName ?? null }}">
</div>
{{ user ? forms.errorsList(user.getErrors('firstName')) }}
</div>
Expand All @@ -18,7 +20,9 @@
Last Name
</label>
<div class="mt-1">
<input id="last-name" name="lastName" type="text" autocomplete="last-name" class="appearance-none block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none sm:text-sm" required value="{{ user.lastName ?? null }}">
<input id="last-name" name="lastName" type="text" autocomplete="last-name"
class="appearance-none block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none sm:text-sm"
required value="{{ user.lastName ?? null }}">
</div>
{{ user ? forms.errorsList(user.getErrors('lastName')) }}
</div>
Expand All @@ -27,7 +31,9 @@
Email
</label>
<div class="mt-1">
<input id="email" name="email" type="email" autocomplete="email" class="appearance-none block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none sm:text-sm" required value="{{ user.email ?? null }}">
<input id="email" name="email" type="email" autocomplete="email"
class="appearance-none block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none sm:text-sm"
required value="{{ user.email ?? null }}">
</div>
{{ user ? forms.errorsList(user.getErrors('email')) }}
</div>
Expand All @@ -37,26 +43,42 @@
Password
</label>
<div class="mt-1">
<input id="password" name="password" type="password" autocomplete="current-password" required class="appearance-none block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none sm:text-sm">
<input id="password" name="password" type="password" autocomplete="current-password" required
class="appearance-none block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none sm:text-sm">
</div>
{{ user ? forms.errorsList(user.getErrors('password')) }}
</div>
<div>
<button type="submit" class="w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-gray-800 hover:bg-gray-700 focus:outline-none">
<button type="submit"
class="w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-gray-800 hover:bg-gray-700 focus:outline-none">
<div id="spinner" class="htmx-indicator pr-4">
<svg class="animate-spin h-5 w-5 text-white" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
<svg class="animate-spin h-5 w-5 text-white" xmlns="http://www.w3.org/2000/svg" fill="none"
viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor"
stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor"
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
</div>
Register
</button>
{% if success is defined and success %}
{% if sprig.isSuccess %}
<div class="rounded-lg bg-green-50 p-4 mt-4 border-2 border-green-100">
<div class="flex">
<div class="ml-3">
<p class="text-sm font-medium text-green-800">
We created your account! Please check your email to verify your email address before logging in.
We created your account! Please check your email to verify your email address before
logging in.
</p>
</div>
</div>
</div>
{% elseif sprig.isError %}
<div class="rounded-lg bg-red-50 p-4 mt-4 border-2 border-green-100">
<div class="flex">
<div class="ml-3">
<p class="text-sm font-medium text-red-800">
Oh, no! There was a problem creating your account.
</p>
</div>
</div>
Expand Down
19 changes: 10 additions & 9 deletions templates/_components/set-password-form.twig
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
</div>
Submit New Password
</button>
{% if sprig.isError %}
{% if errors is defined %}
<div class="rounded-lg bg-red-50 p-4 mt-4 border-2 border-red-100">
<div class="flex">
Expand All @@ -37,18 +38,18 @@
</div>
</div>
</div>

{% endif %}

{% if success is defined and success %}
<div class="rounded-lg bg-green-50 p-4 mt-4 border-2 border-green-100">
<div class="flex">
<div class="ml-3">
<p class="text-sm font-medium text-green-800">
Your password was reset and you're logged in! <a class="underline" href="/dashboard">Access the dashboard</a> to continue with your account. </p>
</div>
<div class="rounded-lg bg-green-50 p-4 mt-4 border-2 border-green-100">
{% endif %}
{% if sprig.isSuccess %}
<div class="flex">
<div class="ml-3">
<p class="text-sm font-medium text-green-800">
Your password was reset and you're logged in! <a class="underline" href="/dashboard">Access
the dashboard</a> to continue with your account. </p>
</div>
</div>
</div>
{% endif %}
</div>
</form>
Expand Down
2 changes: 1 addition & 1 deletion templates/dashboard/index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div class="flex flex-col w-64">
<div class="flex flex-col flex-grow bg-gray-900 pt-5 pb-4 overflow-y-auto">
<div class="flex items-center flex-shrink-0 px-4">
<img class="h-8 w-auto" src="https://craftquest.io/img/logo.svg" alt="CraftQuest"">
<img class="h-8 w-auto" src="https://craftquest.io/img/logo.svg" alt="CraftQuest">
</div>
<nav class="mt-5 flex-1 flex flex-col divide-y divide-black overflow-y-auto" aria-label="Sidebar">
<div class="px-2 space-y-1">
Expand Down
3 changes: 0 additions & 3 deletions templates/forgot-password.twig
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{% extends "_layout" %}
{% if currentUser %} {% redirect "/dashboard" %} {% endif %}
{% block headJs %}
{{ sprig.script }}
{% endblock %}
{% block headCss %}
<style>
.htmx-indicator { display: none; }
Expand Down
3 changes: 0 additions & 3 deletions templates/register.twig
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{% extends "_layout" %}
{% if currentUser %} {% redirect "/dashboard" %} {% endif %}
{% block headJs %}
{{ sprig.script }}
{% endblock %}
{% block headCss %}
<style>
.htmx-indicator { display: none; }
Expand Down
3 changes: 0 additions & 3 deletions templates/setpassword.twig
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{% extends "_layout" %}
{% block headJs %}
{{ sprig.script }}
{% endblock %}
{% block headCss %}
<style>
.htmx-indicator { display: none; }
Expand Down

0 comments on commit a5a8c48

Please sign in to comment.