nitro-web 0.0.174 → 0.0.179
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -10,7 +10,7 @@ type resetInstructionsProps = {
|
|
|
10
10
|
|
|
11
11
|
export function ResetInstructions({ className, elements, redirectTo }: resetInstructionsProps) {
|
|
12
12
|
const navigate = useNavigate()
|
|
13
|
-
const isLoading = useState(false)
|
|
13
|
+
const [isLoading, setIsLoading] = useState(false)
|
|
14
14
|
const [, setStore] = useTracked()
|
|
15
15
|
const [state, setState] = useState({ email: '', errors: [] as Errors })
|
|
16
16
|
|
|
@@ -20,7 +20,8 @@ export function ResetInstructions({ className, elements, redirectTo }: resetInst
|
|
|
20
20
|
|
|
21
21
|
async function onSubmit (event: React.FormEvent<HTMLFormElement>) {
|
|
22
22
|
try {
|
|
23
|
-
|
|
23
|
+
if (isLoading) return
|
|
24
|
+
await request('post /api/reset-instructions', state, event, setIsLoading, setState)
|
|
24
25
|
setStore((s) => ({ ...s, message: 'Done! Please check your email.' }))
|
|
25
26
|
navigate(redirectTo || '/signin')
|
|
26
27
|
} catch (e) {
|
|
@@ -43,7 +44,7 @@ export function ResetInstructions({ className, elements, redirectTo }: resetInst
|
|
|
43
44
|
<FormError state={state} className="pt-2" />
|
|
44
45
|
</div>
|
|
45
46
|
|
|
46
|
-
<Elements.Button className="w-full" isLoading={isLoading
|
|
47
|
+
<Elements.Button className="w-full" isLoading={isLoading} type="submit">Email me a reset password link</Elements.Button>
|
|
47
48
|
</form>
|
|
48
49
|
</div>
|
|
49
50
|
)
|
|
@@ -52,7 +53,7 @@ export function ResetInstructions({ className, elements, redirectTo }: resetInst
|
|
|
52
53
|
export function ResetPassword({ className, elements, redirectTo }: resetInstructionsProps) {
|
|
53
54
|
const navigate = useNavigate()
|
|
54
55
|
const params = useParams()
|
|
55
|
-
const isLoading = useState(false)
|
|
56
|
+
const [isLoading, setIsLoading] = useState(false)
|
|
56
57
|
const [, setStore] = useTracked()
|
|
57
58
|
const [state, setState] = useState(() => ({
|
|
58
59
|
password: '',
|
|
@@ -67,7 +68,8 @@ export function ResetPassword({ className, elements, redirectTo }: resetInstruct
|
|
|
67
68
|
|
|
68
69
|
async function onSubmit (event: React.FormEvent<HTMLFormElement>) {
|
|
69
70
|
try {
|
|
70
|
-
|
|
71
|
+
if (isLoading) return
|
|
72
|
+
const data = await request('post /api/reset-password', state, event, setIsLoading, setState)
|
|
71
73
|
setStore((s) => ({ ...s, ...data }))
|
|
72
74
|
setTimeout(() => navigate(redirectTo || '/'), 10) // wait for setStore
|
|
73
75
|
} catch (e) {
|
|
@@ -94,7 +96,7 @@ export function ResetPassword({ className, elements, redirectTo }: resetInstruct
|
|
|
94
96
|
<FormError state={state} className="pt-2" />
|
|
95
97
|
</div>
|
|
96
98
|
|
|
97
|
-
<Elements.Button class="w-full" isLoading={isLoading
|
|
99
|
+
<Elements.Button class="w-full" isLoading={isLoading} type="submit">Reset Password</Elements.Button>
|
|
98
100
|
</form>
|
|
99
101
|
</div>
|
|
100
102
|
)
|
|
@@ -12,7 +12,7 @@ export function Signin({ className, elements, redirectTo }: signinProps) {
|
|
|
12
12
|
const navigate = useNavigate()
|
|
13
13
|
const location = useLocation()
|
|
14
14
|
const isSignout = location.pathname == '/signout'
|
|
15
|
-
const isLoading = useState(isSignout)
|
|
15
|
+
const [isLoading, setIsLoading] = useState(isSignout)
|
|
16
16
|
const [, setStore] = useTracked()
|
|
17
17
|
const [state, setState] = useState({
|
|
18
18
|
email: injectedConfig.env == 'development' ? (injectedConfig.placeholderEmail || '') : '',
|
|
@@ -35,18 +35,19 @@ export function Signin({ className, elements, redirectTo }: signinProps) {
|
|
|
35
35
|
setStore((s) => ({ ...s, user: undefined }))
|
|
36
36
|
// util.axios().get('/api/signout')
|
|
37
37
|
Promise.resolve()
|
|
38
|
-
.then(() =>
|
|
38
|
+
.then(() => setIsLoading(false))
|
|
39
39
|
.then(() => updateJwt())
|
|
40
40
|
.then(() => navigate({ pathname: '/signin', search: location.search }, { replace: true }))
|
|
41
|
-
.catch(err => (console.error(err),
|
|
41
|
+
.catch(err => (console.error(err), setIsLoading(false)))
|
|
42
42
|
}
|
|
43
43
|
}, [isSignout])
|
|
44
44
|
|
|
45
45
|
async function onSubmit (e: React.FormEvent<HTMLFormElement>) {
|
|
46
46
|
try {
|
|
47
|
-
|
|
47
|
+
if (isLoading) return
|
|
48
|
+
const data = await request('post /api/signin', state, e, setIsLoading, setState)
|
|
48
49
|
// Keep it loading until we navigate
|
|
49
|
-
|
|
50
|
+
setIsLoading(true)
|
|
50
51
|
setStore((s) => ({ ...s, ...data }))
|
|
51
52
|
setTimeout(() => { // wait for setStore
|
|
52
53
|
if (location.search.includes('redirect')) navigate(location.search.replace('?redirect=', ''))
|
|
@@ -80,7 +81,7 @@ export function Signin({ className, elements, redirectTo }: signinProps) {
|
|
|
80
81
|
<FormError state={state} className="pt-2" />
|
|
81
82
|
</div>
|
|
82
83
|
|
|
83
|
-
<Elements.Button class="w-full" isLoading={isLoading
|
|
84
|
+
<Elements.Button class="w-full" isLoading={isLoading} type="submit">Sign In</Elements.Button>
|
|
84
85
|
</form>
|
|
85
86
|
</div>
|
|
86
87
|
)
|
|
@@ -10,7 +10,7 @@ type signupProps = {
|
|
|
10
10
|
|
|
11
11
|
export function Signup({ className, elements, redirectTo }: signupProps) {
|
|
12
12
|
const navigate = useNavigate()
|
|
13
|
-
const isLoading = useState(false)
|
|
13
|
+
const [isLoading, setIsLoading] = useState(false)
|
|
14
14
|
const [, setStore] = useTracked()
|
|
15
15
|
const [state, setState] = useState({
|
|
16
16
|
email: injectedConfig.env === 'development' ? (injectedConfig.placeholderEmail || '') : '',
|
|
@@ -26,7 +26,8 @@ export function Signup({ className, elements, redirectTo }: signupProps) {
|
|
|
26
26
|
|
|
27
27
|
async function onSubmit (e: React.FormEvent<HTMLFormElement>) {
|
|
28
28
|
try {
|
|
29
|
-
|
|
29
|
+
if (isLoading) return
|
|
30
|
+
const data = await request('post /api/signup', state, e, setIsLoading, setState)
|
|
30
31
|
setStore((prev) => ({ ...prev, ...data }))
|
|
31
32
|
setTimeout(() => navigate(redirectTo || '/'), 10) // wait for setStore
|
|
32
33
|
} catch (e) {
|
|
@@ -66,7 +67,7 @@ export function Signup({ className, elements, redirectTo }: signupProps) {
|
|
|
66
67
|
<FormError state={state} className="pt-2" />
|
|
67
68
|
</div>
|
|
68
69
|
|
|
69
|
-
<Elements.Button class="w-full" isLoading={isLoading
|
|
70
|
+
<Elements.Button class="w-full" isLoading={isLoading} type="submit">Create Account</Elements.Button>
|
|
70
71
|
</form>
|
|
71
72
|
</div>
|
|
72
73
|
)
|
|
@@ -711,10 +711,17 @@ export function Styleguide({ className, elements, children, currencies }: Styleg
|
|
|
711
711
|
<h2 class="h3">Modals & Notifications</h2>
|
|
712
712
|
<div class="flex flex-wrap gap-x-6 gap-y-4 mb-6">
|
|
713
713
|
<Button color="primary" onClick={() => setShowModal1(true)}>Modal (default)</Button>
|
|
714
|
-
<Button color="danger" onClick={() => setStore({ message: { text: 'Error.', type: 'error' }})
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
<Button color="
|
|
714
|
+
<Button color="danger" onClick={() => setStore((s) => ({ ...s, message: { text: 'Error.', type: 'error' }}))}>
|
|
715
|
+
Notification error
|
|
716
|
+
</Button>
|
|
717
|
+
<Button color="warning" onClick={() => setStore((s) => ({ ...s, message: { text: 'Warning.', type: 'warning' }})) }>
|
|
718
|
+
Notification warning
|
|
719
|
+
</Button>{/*eslint-disable-line*/}
|
|
720
|
+
<Button color="info" onClick={() => setStore((s) => ({ ...s, message: { text: 'Info.', type: 'info' }})) }>
|
|
721
|
+
Notification info</Button>
|
|
722
|
+
<Button color="success" onClick={() => setStore((s) => ({ ...s, message: 'Success.' }))}>
|
|
723
|
+
Notification success
|
|
724
|
+
</Button>
|
|
718
725
|
</div>
|
|
719
726
|
</div>
|
|
720
727
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nitro-web",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.179",
|
|
4
4
|
"repository": "github:boycce/nitro-web",
|
|
5
5
|
"homepage": "https://boycce.github.io/nitro-web/",
|
|
6
6
|
"description": "Nitro is a battle-tested, modular base project to turbocharge your projects, styled using Tailwind 🚀",
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"major": "npm run types && standard-version -a --release-as major && npm publish && cd ../webpack && npm publish",
|
|
27
27
|
"minor": "npm run types && standard-version -a --release-as minor && npm publish && cd ../webpack && npm publish",
|
|
28
28
|
"patch": "npm run types && standard-version -a --release-as patch && npm publish && cd ../webpack && npm publish",
|
|
29
|
+
"publish": "npm publish && cd ../webpack && npm publish",
|
|
29
30
|
"types": "tsc util.js ./server/index.js --declaration --declarationMap --allowJs --emitDeclarationOnly --jsx react-jsx --esModuleInterop --skipLibCheck --outDir types && cd ../webpack && npm run types -w . && cd ../core"
|
|
30
31
|
},
|
|
31
32
|
"dependencies": {
|