generated from spatie/package-skeleton-laravel
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from fouteox/main
Add react support (jsx and tsx)
- Loading branch information
Showing
3 changed files
with
101 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React from 'react'; | ||
import { router } from '@inertiajs/react' | ||
|
||
export default function LoginLink({ | ||
className = 'underline', | ||
email = null, | ||
guard = null, | ||
keyId = null, | ||
label = 'Login', | ||
redirectUrl = null, | ||
userAttributes = null, | ||
}) { | ||
const submit = (event) => { | ||
event.preventDefault(); | ||
router.post(route('loginLinkLogin'), { | ||
email: email, | ||
key: keyId, | ||
redirect_url: redirectUrl, | ||
guard: guard, | ||
user_attributes: userAttributes, | ||
}); | ||
}; | ||
|
||
return ( | ||
<form onSubmit={submit}> | ||
<button className={className} type="submit"> | ||
{label} | ||
</button> | ||
</form> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React, { FormEvent } from 'react'; | ||
import { router } from '@inertiajs/react' | ||
|
||
interface LoginLinkProps { | ||
className?: string; | ||
email?: string; | ||
guard?: string; | ||
keyId?: string; | ||
label?: string; | ||
redirectUrl?: string; | ||
userAttributes?: Record<string, any>; | ||
} | ||
|
||
export default function LoginLink({ | ||
className = 'underline', | ||
email = null, | ||
guard = null, | ||
keyId = null, | ||
label = 'Login', | ||
redirectUrl = null, | ||
userAttributes = null, | ||
}: LoginLinkProps) { | ||
function submit(event: FormEvent) { | ||
event.preventDefault(); | ||
router.post(route('loginLinkLogin'), { | ||
email: email, | ||
key: keyId, | ||
redirect_url: redirectUrl, | ||
guard: guard, | ||
user_attributes: userAttributes, | ||
}); | ||
}; | ||
|
||
return ( | ||
<form onSubmit={submit}> | ||
<button className={className} type="submit"> | ||
{label} | ||
</button> | ||
</form> | ||
); | ||
}; |