-
Notifications
You must be signed in to change notification settings - Fork 1
feat(account): add forgot password page #147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2b7260a
1eb5691
a72d0b7
075d749
9610f87
110fa93
3d08d23
c42f5d1
1720218
20fd016
4ab1f7e
325841a
41dbea8
9f1cd39
9c247bd
3c705bd
6fba4a6
3d3366c
1825783
ca3f38e
484853d
8ae730a
a392ee6
c9394dc
89d952f
9d15c28
b4431f4
92d4e5d
9df1023
63b6495
51fc324
8a17584
649e0ef
9659066
1fb156d
d8e26bd
ad10e7c
8ad4f72
cb446e1
afc8343
ef5e1c6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<script setup lang="ts"> | ||
import type { RecoverData } from './AccountRecoverInner.vue'; | ||
|
||
const isLoading = ref(false); | ||
const showSuccessMessage = ref(false); | ||
|
||
const customerStore = useCustomerStore(); | ||
const { getStorefrontUrl } = useInternationalization(); | ||
|
||
const recover = async (recoverData: RecoverData) => { | ||
isLoading.value = true; | ||
|
||
try { | ||
await customerStore.resetPassword({ | ||
...recoverData, | ||
storefrontUrl: getStorefrontUrl(), | ||
}); | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
} catch (error) { | ||
// catch but do nothing | ||
} finally { | ||
showSuccessMessage.value = true; | ||
isLoading.value = false; | ||
} | ||
}; | ||
</script> | ||
|
||
<template> | ||
<AccountRecoverInner | ||
:is-loading="isLoading" | ||
:show-success-message="showSuccessMessage" | ||
@recover="(recoverData: RecoverData) => recover(recoverData)" | ||
/> | ||
</template> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<script setup lang="ts"> | ||
import * as z from 'zod'; | ||
const { t } = useI18n(); | ||
|
||
withDefaults( | ||
defineProps<{ | ||
isLoading?: boolean; | ||
showSuccessMessage?: boolean; | ||
}>(), | ||
{ | ||
isLoading: false, | ||
showSuccessMessage: false, | ||
}, | ||
); | ||
|
||
const emits = defineEmits<{ | ||
recover: [recoverData: RecoverData]; | ||
}>(); | ||
|
||
const schema = z.object({ | ||
email: z | ||
.string({ | ||
required_error: t('account.email.error'), | ||
}) | ||
.email(), | ||
}); | ||
|
||
export type RecoverData = z.infer<typeof schema>; | ||
|
||
const recover = (recoverData: RecoverData) => { | ||
emits('recover', recoverData); | ||
}; | ||
</script> | ||
|
||
<template> | ||
aheartforspinach marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<slot name="wrapper"> | ||
<div v-auto-animate> | ||
<slot name="success-message"> | ||
<template v-if="showSuccessMessage"> | ||
<UiAlert variant="successful" class="mb-4 flex gap-4"> | ||
<slot name="alert-icon"> | ||
<Icon name="mdi:check" class="size-4 shrink-0" /> | ||
</slot> | ||
|
||
<div> | ||
<UiAlertTitle>{{ $t('account.recover.successHeader') }}</UiAlertTitle> | ||
<UiAlertDescription> | ||
{{ $t('account.recover.successMessage') }} | ||
</UiAlertDescription> | ||
</div> | ||
</UiAlert> | ||
</template> | ||
</slot> | ||
|
||
<slot name="header"> | ||
<h1 class="text-lg font-semibold">{{ $t('account.recover.header') }}</h1> | ||
<hr> | ||
</slot> | ||
|
||
<slot name="info-text"> | ||
<p class="pb-4 pt-2 text-sm">{{ $t('account.recover.information') }}</p> | ||
</slot> | ||
|
||
<slot name="form"> | ||
<UiAutoForm | ||
class="space-y-6" | ||
:schema="schema" | ||
:field-config="{ | ||
email: { | ||
label: $t('account.email.label'), | ||
inputProps: { | ||
type: 'email', | ||
placeholder: $t('account.email.placeholder'), | ||
}, | ||
} | ||
}" | ||
@submit="recover" | ||
> | ||
<slot name="buttons"> | ||
<div class="flex flex-wrap gap-4"> | ||
<slot name="back-button"> | ||
<UiButton variant="outline" class="w-fit grow sm:grow-0"> | ||
<NuxtLinkLocale to="/account/login">{{ $t('account.recover.backButton') }}</NuxtLinkLocale> | ||
</UiButton> | ||
</slot> | ||
|
||
<slot name="submit-button"> | ||
<UiButton type="submit" :is-loading="isLoading" class="min-w-52 grow"> | ||
{{ $t('account.recover.submitButton') }} | ||
</UiButton> | ||
</slot> | ||
</div> | ||
</slot> | ||
</UiAutoForm> | ||
</slot> | ||
</div> | ||
</slot> | ||
</template> | ||
MorennMcFly marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -13,6 +13,12 @@ defineEmits<{ | |||||||
}>(); | ||||||||
|
||||||||
const { formatLink } = useInternationalization(); | ||||||||
|
||||||||
const dialogOpen = ref(true); | ||||||||
|
||||||||
Comment on lines
+17
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dialog is pre-opened ( Initializing the dialog as open ( -const dialogOpen = ref(true);
+const dialogOpen = ref(false); 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||
provide('closeDialog', () => { | ||||||||
dialogOpen.value = false; | ||||||||
}); | ||||||||
</script> | ||||||||
|
||||||||
<template> | ||||||||
|
@@ -104,7 +110,7 @@ const { formatLink } = useInternationalization(); | |||||||
<!-- guest view --> | ||||||||
<template v-else> | ||||||||
<slot name="guest"> | ||||||||
<UiDialog> | ||||||||
<UiDialog v-model:open="dialogOpen"> | ||||||||
<UiDialogTrigger class="w-full"> | ||||||||
<slot name="action-login"> | ||||||||
<UiDropdownMenuItem class="cursor-pointer" @select.prevent=""> | ||||||||
|
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.