edit.blade.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. @if($user)
  37. @include('partials.input', ['name' => 'token_fcm', 'title' => 'FCM Token', 'value' => $user->token_fcm ?? '', 'disabled' => true])
  38. @endif
  39. </div>
  40. <div class="tab-pane fade" id="notifications-pane" role="tabpanel" aria-labelledby="notifications-tab">
  41. @php($settings = $notificationSettings ?? [])
  42. @include('partials.notification-settings-table', [
  43. 'channels' => $notificationChannels,
  44. 'disabledChannels' => $disabledChannels ?? [],
  45. 'sections' => [
  46. ['title' => 'Площадки', 'settingsKey' => 'orders', 'options' => $orderStatusOptions, 'colors' => $orderStatusColors, 'settings' => $settings['order_settings'] ?? []],
  47. ['title' => 'Рекламации', 'settingsKey' => 'reclamations', 'options' => $reclamationStatusOptions, 'colors' => $reclamationStatusColors, 'settings' => $settings['reclamation_settings'] ?? []],
  48. ['title' => 'График монтажей', 'settingsKey' => 'schedule', 'options' => $scheduleSourceOptions, 'colors' => [], 'settings' => $settings['schedule_settings'] ?? []],
  49. ],
  50. ])
  51. </div>
  52. </div>
  53. @if($user && !is_null($user->deleted_at))
  54. <div class="col-12 text-center">
  55. <div class="text-danger">ПОЛЬЗОВАТЕЛЬ УДАЛЁН!!!</div>
  56. <a href="#" class="btn btn-sm btn-warning undelete">Восстановить</a>
  57. </div>
  58. @else
  59. @include('partials.submit', ['delete' => ['form_id' => 'delete-user']])
  60. @if($user && auth()->id() !== $user->id)
  61. <div class="text-center mt-2">
  62. <a href="#" class="btn btn-sm btn-outline-primary impersonate-user">Impersonate</a>
  63. </div>
  64. @endif
  65. @endif
  66. </form>
  67. @if($user)
  68. <form action="{{ route('user.undelete', $user->id) }}" method="post" class="d-none" id="undelete-user">
  69. @csrf
  70. </form>
  71. <form action="{{ route('user.destroy', $user->id) }}" method="post" class="d-none" id="delete-user">
  72. @method('DELETE')
  73. @csrf
  74. </form>
  75. <form action="{{ route('user.impersonate', $user->id) }}" method="post" class="d-none" id="impersonate-user">
  76. @csrf
  77. </form>
  78. @endif
  79. </div>
  80. </div>
  81. @endsection
  82. @push('scripts')
  83. <script type="module">
  84. $('.undelete').on('click', function (){
  85. customConfirm('Восстановить пользователя?', function () {
  86. $('#undelete-user').submit();
  87. });
  88. });
  89. $('.impersonate-user').on('click', function (){
  90. customConfirm('Войти от имени этого пользователя?', function () {
  91. $('#impersonate-user').submit();
  92. });
  93. });
  94. </script>
  95. @endpush