Skip to content

Commit

Permalink
fixed redirection when register form submission failed
Browse files Browse the repository at this point in the history
  • Loading branch information
believelody authored and billybillydev committed Jul 17, 2024
1 parent 3aee606 commit ed985dd
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
1 change: 0 additions & 1 deletion src/components/auth.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export function RegisterForm() {
hx-target-500={`#${errorRegisterId}`}
hx-target-4xx={`#${errorRegisterId}`}
hx-target="main"
hx-push-url="/"
>
<p class="text-red-500 text-center text-lg" id={errorRegisterId} />
<FormField fieldName="name" />
Expand Down
6 changes: 3 additions & 3 deletions src/components/habits.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
SecondaryButton,
} from "$components/buttons.component";
import { FormField } from "$components/fields.component";
import { Notification } from "$components/notifications.component";
import { Notification, notificationListId } from "$components/notifications.component";
import { LimitPaginationRadio } from "$components/pagination.component";
import { Habit } from "$db/models";
import { generateDatesByNumberOfDays } from "$lib";
Expand Down Expand Up @@ -189,7 +189,7 @@ export function HabitComponent({
variant="solid"
hx-delete={`/api/habits/${item._id}`}
hx-swap="afterbegin"
hx-target="#notification-list"
hx-target={`#${notificationListId}`}
hx-confirm="Are you sure ?"
/>
</div>
Expand Down Expand Up @@ -374,7 +374,7 @@ export function HabitsBulkDeletion() {
x-on:click={`
items = Array.from($manage("#habit-list").itemIdsToDelete);
if (window.confirm("Are you sure to delete these " + nbItemsToDelete + " items ?")) {
htmx.ajax("DELETE", "/api/habits/bulk?" + items.map((item) => "items=" + item).join("&"), { target: "#notification-list", swap: "afterbegin" });
htmx.ajax("DELETE", "/api/habits/bulk?" + items.map((item) => "items=" + item).join("&"), { target: "#${notificationListId}", swap: "afterbegin" });
}
`}
>
Expand Down
2 changes: 2 additions & 0 deletions src/controllers/api/auth.api.controller.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ const registerApiController = new Hono<{ Variables: AppVariables }>().post(
path: sessionCookie.attributes.path,
maxAge: sessionCookie.attributes.maxAge,
});

ctx.header("Hx-Push-Url", "/");

return ctx.html(
<HomePage
Expand Down
2 changes: 1 addition & 1 deletion src/script/alpine/magic/notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function notificationMagic() {
const notificationListElement = document.getElementById(notificationListId);
if (!notificationListElement) {
const bodyElement = document.body;
if (!notificationListElement) {
if (!bodyElement) {
console.error("Body was not found");
return;
}
Expand Down

0 comments on commit ed985dd

Please sign in to comment.