Skip to content

Commit 5bf3a8f

Browse files
committed
chore: wip
1 parent 2b605f6 commit 5bf3a8f

File tree

4 files changed

+99
-14
lines changed

4 files changed

+99
-14
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from '@stacksjs/datetime'

storage/framework/core/browser/src/utils/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export * from './base'
22
export * from './billable'
3+
export * from './date'
34
export * from './debounce'
45
export * from './function'
56
export * from './guards'

storage/framework/core/build.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ const components = await glob('./components/*', {
2020
// console.log('components', components)
2121
dirs.push(...components)
2222

23-
console.log('dirs', dirs)
2423
const startTime = Date.now()
2524

2625
for (const dir of dirs) {

storage/framework/core/components/auth/src/components/Login.vue

Lines changed: 97 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,131 @@
1+
<script setup lang="ts">
2+
import { ref } from 'vue'
3+
import { useRouter } from 'vue-router'
4+
5+
const props = defineProps({
6+
showLogo: {
7+
type: Boolean,
8+
default: true
9+
},
10+
headingText: {
11+
type: String,
12+
default: 'Sign in to your account'
13+
},
14+
showSocialLogin: {
15+
type: Boolean,
16+
default: true
17+
},
18+
showRememberMe: {
19+
type: Boolean,
20+
default: true
21+
},
22+
showForgotPassword: {
23+
type: Boolean,
24+
default: true
25+
},
26+
showSignup: {
27+
type: Boolean,
28+
default: true
29+
},
30+
signupText: {
31+
type: String,
32+
default: 'Start a 14 day free trial'
33+
}
34+
})
35+
36+
// Reactive state for form inputs and messages
37+
const email = ref('')
38+
const password = ref('')
39+
const errorMessage = ref('')
40+
41+
// Router instance
42+
const router = useRouter()
43+
44+
// Method to handle email and password login
45+
async function login() {
46+
const body = {
47+
email: email.value,
48+
password: password.value,
49+
}
50+
51+
try {
52+
const url = 'http://localhost:3008/api/login'
53+
54+
const response = await fetch(url, {
55+
method: 'POST',
56+
headers: {
57+
'Content-Type': 'application/json',
58+
'Accept': 'application/json',
59+
},
60+
body: JSON.stringify(body),
61+
})
62+
63+
const data: any = await response.json()
64+
65+
if (!response.ok) {
66+
errorMessage.value = data.error || 'Login failed'
67+
}
68+
else {
69+
localStorage.setItem('token', data.token)
70+
router.push({ path: '/dashboard' })
71+
}
72+
}
73+
catch (error) {
74+
console.error(error)
75+
errorMessage.value = 'An error occurred during login'
76+
}
77+
finally {
78+
// Clear password after login attempt
79+
password.value = ''
80+
}
81+
}
82+
</script>
83+
184
<template>
285
<div class="min-h-full flex flex-col justify-center py-12 lg:px-8 sm:px-6">
386
<div class="sm:mx-auto sm:max-w-md sm:w-full">
87+
<Logo v-if="showLogo" class="mx-auto h-11 w-auto" />
488
<h2 class="mt-6 text-center text-2xl text-gray-900 font-bold leading-9 tracking-tight">
5-
Sign in to your account
89+
{{ headingText }}
690
</h2>
791
</div>
892

993
<div class="mt-10 sm:mx-auto sm:max-w-[480px] sm:w-full">
1094
<div class="bg-white px-6 py-12 shadow sm:rounded-lg sm:px-12">
11-
<form class="space-y-6" action="#" method="POST">
95+
<div class="space-y-6">
1296
<div>
1397
<label for="email" class="block text-sm text-gray-900 font-medium leading-6">Email address</label>
1498
<div class="mt-2">
15-
<input id="email" name="email" type="email" autocomplete="email" required class="block w-full border-0 rounded-md p-2 py-1.5 text-gray-900 shadow-sm ring-1 ring-gray-300 ring-inset sm:text-sm placeholder:text-gray-400 sm:leading-6 focus:ring-2 focus:ring-teal-600 focus:ring-inset">
99+
<input id="email" v-model="email" name="email" type="email" autocomplete="email" required class="block w-full border-0 rounded-md py-1.5 text-gray-900 shadow-sm ring-1 ring-gray-300 ring-inset sm:text-sm placeholder:text-gray-400 sm:leading-6 focus:ring-2 focus:ring-indigo-600 focus:ring-inset">
16100
</div>
17101
</div>
18102

19103
<div>
20104
<label for="password" class="block text-sm text-gray-900 font-medium leading-6">Password</label>
21105
<div class="mt-2">
22-
<input id="password" name="password" type="password" autocomplete="current-password" required class="block w-full border-0 rounded-md p-2 py-1.5 text-gray-900 shadow-sm ring-1 ring-gray-300 ring-inset sm:text-sm placeholder:text-gray-400 sm:leading-6 focus:ring-2 focus:ring-teal-600 focus:ring-inset">
106+
<input id="password" v-model="password" name="password" type="password" autocomplete="current-password" required class="block w-full border-0 rounded-md py-1.5 text-gray-900 shadow-sm ring-1 ring-gray-300 ring-inset sm:text-sm placeholder:text-gray-400 sm:leading-6 focus:ring-2 focus:ring-indigo-600 focus:ring-inset">
23107
</div>
24108
</div>
25109

26110
<div class="flex items-center justify-between">
27-
<div class="flex items-center">
28-
<input id="remember-me" name="remember-me" type="checkbox" class="h-4 w-4 border-gray-300 rounded text-teal-600 focus:ring-teal-600">
111+
<div v-if="showRememberMe" class="flex items-center">
112+
<input id="remember-me" name="remember-me" type="checkbox" class="h-4 w-4 border-gray-300 rounded text-indigo-600 focus:ring-indigo-600">
29113
<label for="remember-me" class="ml-3 block text-sm text-gray-900 leading-6">Remember me</label>
30114
</div>
31115

32-
<div class="text-sm leading-6">
33-
<a href="#" class="text-teal-600 font-semibold hover:text-teal-500">Forgot password?</a>
116+
<div v-if="showForgotPassword" class="text-sm leading-6">
117+
<a href="#" class="text-indigo-600 font-semibold hover:text-indigo-500">Forgot password?</a>
34118
</div>
35119
</div>
36120

37121
<div>
38-
<button type="submit" class="w-full flex justify-center rounded-md bg-teal-600 px-3 py-1.5 text-sm text-white font-semibold leading-6 shadow-sm hover:bg-teal-500 focus-visible:outline-2 focus-visible:outline-teal-600 focus-visible:outline-offset-2 focus-visible:outline">
122+
<button type="submit" class="w-full flex justify-center rounded-md bg-indigo-600 px-3 py-1.5 text-sm text-white font-semibold leading-6 shadow-sm hover:bg-indigo-500 focus-visible:outline-2 focus-visible:outline-indigo-600 focus-visible:outline-offset-2 focus-visible:outline" @click="login">
39123
Sign in
40124
</button>
41125
</div>
42-
</form>
126+
</div>
43127

44-
<div>
128+
<div v-if="showSocialLogin">
45129
<div class="relative mt-10">
46130
<div class="absolute inset-0 flex items-center" aria-hidden="true">
47131
<div class="w-full border-t border-gray-200" />
@@ -72,9 +156,9 @@
72156
</div>
73157
</div>
74158

75-
<p class="mt-10 text-center text-sm text-gray-500">
159+
<p v-if="showSignup" class="mt-10 text-center text-sm text-gray-500">
76160
Not a member?
77-
<a href="#" class="text-teal-600 font-semibold leading-6 hover:text-teal-500">Start a 14 day free trial</a>
161+
<a href="#" class="text-indigo-600 font-semibold leading-6 hover:text-indigo-500">Start a 14 day free trial</a>
78162
</p>
79163
</div>
80164
</div>

0 commit comments

Comments
 (0)