mirror of
https://github.com/jcreek/SvelteKitSaasBoilerplate.git
synced 2026-07-12 18:43:50 +00:00
Merge pull request #57 from jcreek/51-editing-the-input-for-basket-item-qty-doesnt-recalculate-subtotal
51 editing the input for basket item qty doesn't recalculate subtotal
This commit is contained in:
@@ -11,10 +11,11 @@
|
||||
export let price = 0;
|
||||
export let quantity = 0;
|
||||
|
||||
$: dispatch('changeQuantity', { itemId, quantity });
|
||||
|
||||
function reduceQuantityByOne() {
|
||||
if (quantity > 1) {
|
||||
quantity--;
|
||||
dispatch('changeQuantity', { itemId, quantity });
|
||||
} else {
|
||||
dispatch('removeItem', { itemId });
|
||||
}
|
||||
@@ -22,7 +23,6 @@
|
||||
|
||||
function increaseQuantityByOne() {
|
||||
quantity++;
|
||||
dispatch('changeQuantity', { itemId, quantity });
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { general } from '$lib/stores/generalStore.js';
|
||||
|
||||
// Access the supabase client from the layout data
|
||||
export let supabase: any;
|
||||
|
||||
let newPassword = '';
|
||||
|
||||
async function resetPassword() {
|
||||
if (newPassword === '') {
|
||||
general.update((value) => {
|
||||
return {
|
||||
...value,
|
||||
hideToast: false,
|
||||
toastMessage: 'Please enter a new password',
|
||||
toastType: 'error'
|
||||
};
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
general.update((value) => {
|
||||
return { ...value, hideToast: true, toastMessage: '', toastType: 'success' };
|
||||
});
|
||||
}, 5000);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const { data, error } = await supabase.auth.updateUser({
|
||||
password: newPassword
|
||||
});
|
||||
|
||||
if (error) {
|
||||
console.error('Error updating password:', error.message);
|
||||
general.update((value) => {
|
||||
return {
|
||||
...value,
|
||||
hideToast: false,
|
||||
toastMessage: 'Error updating password. Please try again.',
|
||||
toastType: 'error'
|
||||
};
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
general.update((value) => {
|
||||
return { ...value, hideToast: true, toastMessage: '', toastType: 'success' };
|
||||
});
|
||||
}, 5000);
|
||||
|
||||
return;
|
||||
} else {
|
||||
general.update((value) => {
|
||||
return {
|
||||
...value,
|
||||
hideToast: false,
|
||||
toastMessage: 'Password updated successfully. Please sign in with your new password.',
|
||||
toastType: 'success'
|
||||
};
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
general.update((value) => {
|
||||
return { ...value, hideToast: true, toastMessage: '', toastType: 'success' };
|
||||
});
|
||||
}, 5000);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>Update Password</title>
|
||||
</svelte:head>
|
||||
|
||||
<main>
|
||||
<h1>Update Password</h1>
|
||||
<form on:submit|preventDefault={resetPassword}>
|
||||
<label for="newPassword">New Password</label>
|
||||
<input type="password" id="newPassword" bind:value={newPassword} />
|
||||
<button type="submit">Update Password</button>
|
||||
</form>
|
||||
</main>
|
||||
Reference in New Issue
Block a user