redirect to pricing back

This commit is contained in:
MuslemRahimi 2024-11-08 16:23:58 +01:00
parent 3949859398
commit 94c271d07e
2 changed files with 32 additions and 29 deletions

View File

@ -5,6 +5,7 @@
import toast from "svelte-french-toast"; import toast from "svelte-french-toast";
import Input from "$lib/components/Input.svelte"; import Input from "$lib/components/Input.svelte";
import { screenWidth } from "$lib/store"; import { screenWidth } from "$lib/store";
import { page } from "$app/stores";
export let form; export let form;
@ -17,20 +18,6 @@
return async ({ result, update }) => { return async ({ result, update }) => {
switch (result.type) { switch (result.type) {
case "success": case "success":
if (form?.notVerified) {
toast.error("Please verify your email first", {
style: "border-radius: 200px; background: #333; color: #fff;",
});
await update();
break;
} else form?.notVerified === false;
{
toast.success("Login successfully!", {
style: "border-radius: 200px; background: #333; color: #fff;",
});
await update();
break;
}
case "redirect": case "redirect":
isClicked = true; isClicked = true;
toast.success("Login successfully!", { toast.success("Login successfully!", {
@ -53,17 +40,18 @@
await update(); await update();
} }
/* setTimeout(() => {
setTimeout(() => { if (
if (result.type === 'redirect') { ["redirect", "success"]?.includes(result.type) &&
const anchor = document.createElement('a'); $page?.url?.pathname === "/pricing"
anchor.href = '/'; ) {
anchor.dataset.sveltekitReload = true; const anchor = document.createElement("a");
document.body.appendChild(anchor); anchor.href = "/pricing";
anchor.dispatchEvent(new MouseEvent('click')); anchor.dataset.sveltekitReload = true;
} document.body.appendChild(anchor);
}, 280); anchor.dispatchEvent(new MouseEvent("click"));
*/ }
}, 280);
loading = false; loading = false;
}; };
@ -74,6 +62,7 @@
return async ({ result, update }) => { return async ({ result, update }) => {
switch (result.type) { switch (result.type) {
case "success": case "success":
case "redirect":
isClicked = true; isClicked = true;
toast.success("Registration successfully!", { toast.success("Registration successfully!", {
style: "border-radius: 200px; background: #333; color: #fff;", style: "border-radius: 200px; background: #333; color: #fff;",
@ -94,6 +83,20 @@
default: default:
await update(); await update();
} }
setTimeout(() => {
if (
["redirect", "success"]?.includes(result.type) &&
$page?.url?.pathname === "/pricing"
) {
const anchor = document.createElement("a");
anchor.href = "/pricing";
anchor.dataset.sveltekitReload = true;
document.body.appendChild(anchor);
anchor.dispatchEvent(new MouseEvent("click"));
}
}, 280);
loading = false; loading = false;
}; };
}; };
@ -209,7 +212,7 @@ const output = await response.json();
> >
<div class="flex flex-row m-auto items-center"> <div class="flex flex-row m-auto items-center">
<span class="loading loading-infinity"></span> <span class="loading loading-infinity"></span>
<span class="text-white ml-1.5">Signing Up</span> <span class=" ml-1.5">Signing Up</span>
</div> </div>
</label> </label>
{/if} {/if}

View File

@ -61,7 +61,7 @@ export const actions = {
error(err.status, err.message); error(err.status, err.message);
} }
redirect(302, "/"); redirect(302, "/pricing");
}, },
register: async ({ locals, request }) => { register: async ({ locals, request }) => {
@ -78,7 +78,7 @@ export const actions = {
} }
try { try {
let newUser = await locals.pb.collection("users").create(formData); await locals.pb.collection("users").create(formData);
/* /*
await locals.pb?.collection('users').update( await locals.pb?.collection('users').update(
newUser?.id, { newUser?.id, {
@ -101,7 +101,7 @@ await locals.pb?.collection('users').update(
error(err.status, err.message); error(err.status, err.message);
} }
redirect(303, "/"); redirect(302, "/pricing");
}, },
oauth2: async ({ url, locals, request, cookies }) => { oauth2: async ({ url, locals, request, cookies }) => {