11<script setup lang="ts">
22import { ref , reactive } from ' vue'
3- // Ensure FormKit types are available if you're using them explicitly,
4- // though often not needed for basic setup with Nuxt FormKit module.
53
64interface ForgotPasswordFormData {
75 email: string
@@ -15,7 +13,7 @@ const message = ref('')
1513const loading = ref (false )
1614const isError = ref (false )
1715
18- const handleForgotPassword = async (data : ForgotPasswordFormData ) => {
16+ const handleForgotPassword = async () => {
1917 loading .value = true
2018 message .value = ' '
2119 isError .value = false
@@ -27,7 +25,7 @@ const handleForgotPassword = async (data: ForgotPasswordFormData) => {
2725 ' Content-Type' : ' application/json' ,
2826 ' Accept' : ' application/json' ,
2927 },
30- body: JSON .stringify ({ email: data .email }), // Use email from form data
28+ body: JSON .stringify ({ email: formData .email }),
3129 })
3230
3331 const responseData = await response .json ()
@@ -59,33 +57,32 @@ const handleForgotPassword = async (data: ForgotPasswordFormData) => {
5957<template >
6058 <div >
6159 <h2 >Forgot Password</h2 >
62- <FormKit
63- v-slot =" { disabled } "
64- type="form"
65- :actions =" false "
66- @submit =" handleForgotPassword "
67- >
68- <FormKit
69- v-model =" formData .email "
70- type="email"
71- name="email"
72- label="Email"
73- placeholder="your@email .com "
74- validation="required|email"
75- />
76- <FormKit
60+ <form @submit.prevent =" handleForgotPassword" >
61+ <div class =" form-group" >
62+ <label for =" email" >Email</label >
63+ <input
64+ id =" email"
65+ v-model =" formData.email"
66+ type =" email"
67+ name =" email"
68+ placeholder =" your@email.com"
69+ required
70+ >
71+ </div >
72+ <button
7773 type =" submit"
78- :label =" loading ? ' Sending...' : ' Send Password Reset Link' "
79- :disabled =" Boolean (disabled ) || loading "
80- />
74+ :disabled =" loading"
75+ >
76+ {{ loading ? 'Sending...' : 'Send Password Reset Link' }}
77+ </button >
8178 <p
8279 v-if =" message"
8380 :class =" { error: isError, success: !isError }"
8481 class =" form-message"
8582 >
8683 {{ message }}
8784 </p >
88- </FormKit >
85+ </form >
8986 </div >
9087</template >
9188
@@ -101,41 +98,35 @@ const handleForgotPassword = async (data: ForgotPasswordFormData) => {
10198 font-size : 0.9rem ;
10299}
103100/* Basic styling for FormKit elements if not using a global theme */
104- :deep( .formkit-outer ) {
105- margin-bottom : 1em ;
101+ .form-group {
102+ margin-bottom : 1em ;
106103}
107- :deep(.formkit-label ) {
104+
105+ label {
108106 display : block ;
109- margin-bottom : 0.25em ;
107+ margin-bottom : 0.25em ;
110108 font-weight : bold ;
111109}
112- :deep( .formkit-input input [ type = " email " ]),
113- :deep( .formkit- input input [type = " password " ]) {
110+
111+ input [type = " email " ] {
114112 width : 100% ;
115- padding : 0.75em ;
113+ padding : 0.75em ;
116114 box-sizing : border-box ;
117115 border : 1px solid var (--color-border-dark );
118116 border-radius : 4px ;
119117}
120- :deep(.formkit-input input [type = " submit" ]) {
121- padding : 0.75em 1.5em ;
118+
119+ button [type = " submit" ] {
120+ padding : 0.75em 1.5em ;
122121 cursor : pointer ;
123122 background-color : var (--color-gray-800 );
124123 color : white ;
125124 border : none ;
126125 border-radius : 4px ;
127126}
128- :deep(.formkit-input input [type = " submit" ]:disabled ) {
127+
128+ button [type = " submit" ]:disabled {
129129 background-color : var (--color-gray-500 );
130130 cursor : not-allowed ;
131131}
132- :deep(.formkit-messages ) {
133- list-style : none ;
134- padding : 0 ;
135- margin-top : 0.25em ;
136- }
137- :deep(.formkit-message ) {
138- color : red ;
139- font-size : 0.8rem ;
140- }
141132 </style >
0 commit comments