AI store generator for ecommerce, Malaysia first. Laravel 13 + React + TypeScript.
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

profile.tsx 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. import { Form, Head, usePage } from '@inertiajs/react';
  2. import { Link } from '@inertiajs/react';
  3. import ProfileController from '@/actions/App/Http/Controllers/Settings/ProfileController';
  4. import DeleteUser from '@/components/delete-user';
  5. import Heading from '@/components/heading';
  6. import InputError from '@/components/input-error';
  7. import { Button } from '@/components/ui/button';
  8. import { Input } from '@/components/ui/input';
  9. import { Label } from '@/components/ui/label';
  10. import { edit } from '@/routes/profile';
  11. import type { Auth } from '@/types';
  12. import { send } from '@/routes/verification';
  13. type PageProps = {
  14. auth: Auth;
  15. };
  16. export default function Profile({
  17. mustVerifyEmail,
  18. status,
  19. }: {
  20. mustVerifyEmail: boolean;
  21. status?: string;
  22. }) {
  23. const { auth } = usePage<PageProps>().props;
  24. return (
  25. <>
  26. <Head title="Profile settings" />
  27. <h1 className="sr-only">Profile settings</h1>
  28. <div className="space-y-6">
  29. <Heading
  30. variant="small"
  31. title="Profile"
  32. description="Update your name and email address"
  33. />
  34. <Form
  35. {...ProfileController.update.form()}
  36. options={{
  37. preserveScroll: true,
  38. }}
  39. className="space-y-6"
  40. >
  41. {({ processing, errors }) => (
  42. <>
  43. <div className="grid gap-2">
  44. <Label htmlFor="name">Name</Label>
  45. <Input
  46. id="name"
  47. className="mt-1 block w-full"
  48. defaultValue={auth.user.name}
  49. name="name"
  50. required
  51. autoComplete="name"
  52. placeholder="Full name"
  53. />
  54. <InputError
  55. className="mt-2"
  56. message={errors.name}
  57. />
  58. </div>
  59. <div className="grid gap-2">
  60. <Label htmlFor="email">Email address</Label>
  61. <Input
  62. id="email"
  63. type="email"
  64. className="mt-1 block w-full"
  65. defaultValue={auth.user.email}
  66. name="email"
  67. required
  68. autoComplete="username"
  69. placeholder="Email address"
  70. />
  71. <InputError
  72. className="mt-2"
  73. message={errors.email}
  74. />
  75. </div>
  76. {mustVerifyEmail &&
  77. auth.user.email_verified_at === null && (
  78. <div>
  79. <p className="-mt-4 text-sm text-muted-foreground">
  80. Your email address is unverified.{' '}
  81. <Link
  82. href={send()}
  83. as="button"
  84. className="text-foreground underline decoration-neutral-300 underline-offset-4 transition-colors duration-300 ease-out hover:decoration-current! dark:decoration-neutral-500"
  85. >
  86. Click here to re-send the
  87. verification email.
  88. </Link>
  89. </p>
  90. {status ===
  91. 'verification-link-sent' && (
  92. <div className="mt-2 text-sm font-medium text-green-600">
  93. A new verification link has been
  94. sent to your email address.
  95. </div>
  96. )}
  97. </div>
  98. )}
  99. <div className="flex items-center gap-4">
  100. <Button
  101. disabled={processing}
  102. data-test="update-profile-button"
  103. >
  104. Save
  105. </Button>
  106. </div>
  107. </>
  108. )}
  109. </Form>
  110. </div>
  111. <DeleteUser />
  112. </>
  113. );
  114. }
  115. Profile.layout = {
  116. breadcrumbs: [
  117. {
  118. title: 'Profile settings',
  119. href: edit(),
  120. },
  121. ],
  122. };