AI store generator for ecommerce, Malaysia first. Laravel 13 + React + TypeScript.
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. import { Form } from '@inertiajs/react';
  2. import { useRef } from 'react';
  3. import ProfileController from '@/actions/App/Http/Controllers/Settings/ProfileController';
  4. import Heading from '@/components/heading';
  5. import InputError from '@/components/input-error';
  6. import PasswordInput from '@/components/password-input';
  7. import { Button } from '@/components/ui/button';
  8. import {
  9. Dialog,
  10. DialogClose,
  11. DialogContent,
  12. DialogDescription,
  13. DialogFooter,
  14. DialogTitle,
  15. DialogTrigger,
  16. } from '@/components/ui/dialog';
  17. import { Label } from '@/components/ui/label';
  18. export default function DeleteUser() {
  19. const passwordInput = useRef<HTMLInputElement>(null);
  20. return (
  21. <div className="space-y-6">
  22. <Heading
  23. variant="small"
  24. title="Delete account"
  25. description="Delete your account and all of its resources"
  26. />
  27. <div className="space-y-4 rounded-lg border border-red-100 bg-red-50 p-4 dark:border-red-200/10 dark:bg-red-700/10">
  28. <div className="relative space-y-0.5 text-red-600 dark:text-red-100">
  29. <p className="font-medium">Warning</p>
  30. <p className="text-sm">
  31. Please proceed with caution, this cannot be undone.
  32. </p>
  33. </div>
  34. <Dialog>
  35. <DialogTrigger asChild>
  36. <Button
  37. variant="destructive"
  38. data-test="delete-user-button"
  39. >
  40. Delete account
  41. </Button>
  42. </DialogTrigger>
  43. <DialogContent>
  44. <DialogTitle>
  45. Are you sure you want to delete your account?
  46. </DialogTitle>
  47. <DialogDescription>
  48. Once your account is deleted, all of its resources
  49. and data will also be permanently deleted. Please
  50. enter your password to confirm you would like to
  51. permanently delete your account.
  52. </DialogDescription>
  53. <Form
  54. {...ProfileController.destroy.form()}
  55. options={{
  56. preserveScroll: true,
  57. }}
  58. onError={() => passwordInput.current?.focus()}
  59. resetOnSuccess
  60. className="space-y-6"
  61. >
  62. {({ resetAndClearErrors, processing, errors }) => (
  63. <>
  64. <div className="grid gap-2">
  65. <Label
  66. htmlFor="password"
  67. className="sr-only"
  68. >
  69. Password
  70. </Label>
  71. <PasswordInput
  72. id="password"
  73. name="password"
  74. ref={passwordInput}
  75. placeholder="Password"
  76. autoComplete="current-password"
  77. />
  78. <InputError message={errors.password} />
  79. </div>
  80. <DialogFooter className="gap-2">
  81. <DialogClose asChild>
  82. <Button
  83. variant="secondary"
  84. onClick={() =>
  85. resetAndClearErrors()
  86. }
  87. >
  88. Cancel
  89. </Button>
  90. </DialogClose>
  91. <Button
  92. variant="destructive"
  93. disabled={processing}
  94. asChild
  95. >
  96. <button
  97. type="submit"
  98. data-test="confirm-delete-user-button"
  99. >
  100. Delete account
  101. </button>
  102. </Button>
  103. </DialogFooter>
  104. </>
  105. )}
  106. </Form>
  107. </DialogContent>
  108. </Dialog>
  109. </div>
  110. </div>
  111. );
  112. }