edit.blade.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. @extends('layouts.app')
  2. @section('content')
  3. <div class="px-3">
  4. <div class="col-xxl-6 offset-xxl-2">
  5. <form action="{{ route('user.store') }}" method="post">
  6. @csrf
  7. @if($user)
  8. <input type="hidden" name="id" value="{{ $user->id }}">
  9. @endif
  10. <ul class="nav nav-tabs mb-3" role="tablist">
  11. <li class="nav-item" role="presentation">
  12. <button class="nav-link active" id="main-tab" data-bs-toggle="tab" data-bs-target="#main-pane" type="button" role="tab">Основное</button>
  13. </li>
  14. <li class="nav-item" role="presentation">
  15. <button class="nav-link" id="notifications-tab" data-bs-toggle="tab" data-bs-target="#notifications-pane" type="button" role="tab">Уведомления</button>
  16. </li>
  17. </ul>
  18. <div class="tab-content">
  19. <div class="tab-pane fade show active" id="main-pane" role="tabpanel" aria-labelledby="main-tab">
  20. @include('partials.input', ['name' => 'email',
  21. 'type' => 'text',
  22. 'title' => 'Логин/email',
  23. 'required' => true,
  24. 'value' => $user->email ?? '',
  25. 'disabled' => ($user && $user->email_verified_at),
  26. ])
  27. @include('partials.input', ['name' => 'notification_email',
  28. 'type' => 'email',
  29. 'title' => 'Email для уведомлений',
  30. 'value' => old('notification_email', $user->notification_email ?? '')])
  31. @include('partials.input', ['name' => 'name', 'title' => 'Имя', 'required' => true, 'value' => $user->name ?? ''])
  32. @include('partials.input', ['name' => 'phone', 'title' => 'Телефон', 'value' => $user->phone ?? ''])
  33. @include('partials.input', ['name' => 'password', 'type' => 'password', 'title' => 'Пароль'])
  34. @include('partials.select', ['name' => 'role', 'title' => 'Роль', 'options' => getRoles(), 'value' => $user->role ?? \App\Models\Role::MANAGER])
  35. @include('partials.input', ['name' => 'color', 'title' => 'Цвет', 'value' => $user->color ?? '#FFFFFF', 'type' => 'color'])
  36. </div>
  37. <div class="tab-pane fade" id="notifications-pane" role="tabpanel" aria-labelledby="notifications-tab">
  38. @php($settings = $notificationSettings ?? [])
  39. @include('partials.notification-settings-table', [
  40. 'channels' => $notificationChannels,
  41. 'disabledChannels' => $disabledChannels ?? [],
  42. 'sections' => [
  43. ['title' => 'Площадки', 'settingsKey' => 'orders', 'options' => $orderStatusOptions, 'colors' => $orderStatusColors, 'settings' => $settings['order_settings'] ?? []],
  44. ['title' => 'Рекламации', 'settingsKey' => 'reclamations', 'options' => $reclamationStatusOptions, 'colors' => $reclamationStatusColors, 'settings' => $settings['reclamation_settings'] ?? []],
  45. ['title' => 'График монтажей', 'settingsKey' => 'schedule', 'options' => $scheduleSourceOptions, 'colors' => [], 'settings' => $settings['schedule_settings'] ?? []],
  46. ],
  47. ])
  48. </div>
  49. </div>
  50. @if($user && !is_null($user->deleted_at))
  51. <div class="col-12 text-center">
  52. <div class="text-danger">ПОЛЬЗОВАТЕЛЬ УДАЛЁН!!!</div>
  53. <a href="#" class="btn btn-sm btn-warning undelete">Восстановить</a>
  54. </div>
  55. @else
  56. @include('partials.submit', ['delete' => ['form_id' => 'delete-user']])
  57. @if($user && auth()->id() !== $user->id)
  58. <div class="text-center mt-2">
  59. <a href="#" class="btn btn-sm btn-outline-primary impersonate-user">Impersonate</a>
  60. </div>
  61. @endif
  62. @endif
  63. </form>
  64. @if($user)
  65. <form action="{{ route('user.undelete', $user->id) }}" method="post" class="d-none" id="undelete-user">
  66. @csrf
  67. </form>
  68. <form action="{{ route('user.destroy', $user->id) }}" method="post" class="d-none" id="delete-user">
  69. @method('DELETE')
  70. @csrf
  71. </form>
  72. <form action="{{ route('user.impersonate', $user->id) }}" method="post" class="d-none" id="impersonate-user">
  73. @csrf
  74. </form>
  75. @endif
  76. </div>
  77. </div>
  78. @endsection
  79. @push('scripts')
  80. <script type="module">
  81. $('.undelete').on('click', function (){
  82. customConfirm('Восстановить пользователя?', function () {
  83. $('#undelete-user').submit();
  84. });
  85. });
  86. $('.impersonate-user').on('click', function (){
  87. customConfirm('Войти от имени этого пользователя?', function () {
  88. $('#impersonate-user').submit();
  89. });
  90. });
  91. </script>
  92. @endpush