@extends('layouts.app')
@section('content')
<main>
    <header class="alert alert-success">
        <h4 class="container">ユーザー情報確認 &gt; 入力内容確認</h4>
    </header>
    <section class="container mt30 mb50">
        <h5 class="mb30 offset-md-1">下記の内容で変更します。</h5>
        <form class="row form" action="{{ route('user.edit.submit') }}" method="post">
            @csrf
            <!-- お名前 -->
            <div class="col-12 col-md-3 offset-0 offset-md-2">
                <label for="user_name">お名前</label>
            </div>
            <div class="col-12 col-lg-6 mb10">
                <h3>{{ $user->user_name }}</h3>
                <input type="hidden" name="user_name" value="{{ $user->user_name }}">
            </div>
            <!-- フリガナ -->
            <div class="col-12 col-md-3 offset-0 offset-md-2">
                <label for="user_phonetic">フリガナ</label>
            </div>
            <div class="col-12 col-lg-6 mb10">
                <h3>{{ $user->user_phonetic }}</h3>
                <input type="hidden" name="user_phonetic" value="{{ $user->user_phonetic }}">
            </div>
            <!-- 性別 -->
            @if (!empty($input['user_gender']))
            <div class="col-12 col-md-3 offset-0 offset-md-2">
                <label for="user_gender">性別</label>
            </div>
            <div class="col-12 col-lg-6 mb10">
                <h3>{{ $input['user_gender'] }}</h3>
                <input type="hidden" name="user_gender" value="{{ $input['user_gender'] }}">
            </div>
            @endif
            <!-- 居住所 -->
            <div class="col-12 col-md-3 offset-0 offset-md-2">
                <label for="user_regident_zip">居住所</label>
            </div>
            <div class="col-12 col-lg-6 mb10">
                <h3>
                    @php
                    $zip1 = $input['user_regident_zip_1'] ?? $user->user_regident_zip_1 ?? '';
                    $zip2 = $input['user_regident_zip_2'] ?? $user->user_regident_zip_2 ?? '';
                    $pre = $input['user_regident_pre'] ?? $user->user_regident_pre ?? '';
                    $city = $input['user_regident_city'] ?? $user->user_regident_city ?? '';
                    $add = $input['user_regident_add'] ?? $user->user_regident_add ?? '';
                    $zip = ($zip1 && $zip2) ? $zip1.'-'.$zip2 : (($zip1 || $zip2) ? $zip1.$zip2 : '');
                    @endphp
                    {{ $zip }}{{ $pre }}{{ $city }}{{ $add }}
                </h3>
                <input type="hidden" name="user_regident_zip_1" value="{{ $input['user_regident_zip_1'] ?? $user->user_regident_zip_1 ?? '' }}">
                <input type="hidden" name="user_regident_zip_2" value="{{ $input['user_regident_zip_2'] ?? $user->user_regident_zip_2 ?? '' }}">
                <input type="hidden" name="user_regident_pre" value="{{ $input['user_regident_pre'] ?? $user->user_regident_pre ?? '' }}">
                <input type="hidden" name="user_regident_city" value="{{ $input['user_regident_city'] ?? $user->user_regident_city ?? '' }}">
                <input type="hidden" name="user_regident_add" value="{{ $input['user_regident_add'] ?? $user->user_regident_add ?? '' }}">
            </div>
            <!-- 生年月日 -->
            <div class="col-12 col-md-3 offset-0 offset-md-2">
                <label for="user_birthdate">生年月日</label>
            </div>
            <div class="col-12 col-lg-6 mb10">
                <h3>{{ $input['user_birthdate'] }}</h3>
                <input type="hidden" name="user_birthdate" value="{{ $input['user_birthdate'] }}">
            </div>
            <!-- 年齢 -->
            <div class="col-12 col-md-3 offset-0 offset-md-2">
                <label for="user_age">年齢</label>
            </div>
            <div class="col-12 col-lg-6 mb10">
                <h3>{{ $input['user_age'] }}</h3>
                <input type="hidden" name="user_age" value="{{ $input['user_age'] }}">
            </div>
            <!-- 自宅電話番号 -->
            <div class="col-12 col-md-3 offset-0 offset-md-2">
                <label for="user_homephone">自宅電話番号</label>
            </div>
            <div class="col-12 col-lg-6 mb10">
                <h3>
                    @php
                    $home = array_filter($input['user_homephone'] ?? []);
                    @endphp
                    {{ $home ? implode('-', $home) : '' }}
                </h3>
                @foreach ($input['user_homephone'] as $val)
                <input type="hidden" name="user_homephone[]" value="{{ $val }}">
                @endforeach
            </div>
            <!-- 携帯電話番号 -->
            <div class="col-12 col-md-3 offset-0 offset-md-2">
                <label for="user_mobile">携帯電話番号</label>
            </div>
            <div class="col-12 col-lg-6 mb10">
                <h3>
                    @php
                    $mobile = array_filter($input['user_mobile'] ?? []);
                    @endphp
                    {{ $mobile ? implode('-', $mobile) : '' }}
                </h3>
                @foreach ($input['user_mobile'] as $val)
                <input type="hidden" name="user_mobile[]" value="{{ $val }}">
                @endforeach
            </div>
            <!-- メールアドレス -->
            <div class="col-12 col-md-3 offset-0 offset-md-2">
                <label for="user_primemail">メールアドレス</label>
            </div>
            <div class="col-12 col-lg-6 mb10">
                <h3>{{ $input['user_primemail'] }}</h3>
                <input type="hidden" name="user_primemail" value="{{ $input['user_primemail'] }}">
            </div>
            <!-- メールアドレス確認 -->
            <div class="col-12 col-md-3 offset-0 offset-md-2">
                <label for="user_primemail_confirmation">メールアドレスの確認</label>
            </div>
            <div class="col-12 col-lg-6 mb10">
                <h3>{{ $input['user_primemail_confirmation'] }}</h3>
                <input type="hidden" name="user_primemail_confirmation" value="{{ $input['user_primemail_confirmation'] }}">
            </div>
            <!-- 予備メールアドレス -->
            <div class="col-12 col-md-3 offset-0 offset-md-2">
                <label for="user_submail">予備メールアドレス</label>
            </div>
            <div class="col-12 col-lg-6 mb10">
                <h3>{{ $input['user_submail'] }}</h3>
                <input type="hidden" name="user_submail" value="{{ $input['user_submail'] }}">
            </div>
            <!-- 利用者区分 -->
            <div class="col-12 col-md-3 offset-0 offset-md-2">
                <label for="user_category">利用者区分</label>
            </div>
            <div class="col-12 col-lg-6 mb10">
                <h3>{{ $input['user_category'] }}</h3>
                <input type="hidden" name="user_category" value="{{ $input['user_category'] }}">
            </div>
            @if ($input['user_category'] === '学生')
            <!-- 学生の場合：学校名・卒業予定のみ表示 -->
            <div class="col-12 col-md-3 offset-0 offset-md-2">
                <label for="user_school">学校名</label>
            </div>
            <div class="col-12 col-lg-6 mb10">
                <h3>{{ $input['user_school'] }}</h3>
                <input type="hidden" name="user_school" value="{{ $input['user_school'] }}">
            </div>
            <div class="col-12 col-md-3 offset-0 offset-md-2">
                <label for="user_graduate">卒業予定</label>
            </div>
            <div class="col-12 col-lg-6 mb10">
                <h3>{{ $input['user_graduate'] }}</h3>
                <input type="hidden" name="user_graduate" value="{{ $input['user_graduate'] }}">
            </div>
            @else
            <!-- 一般の場合：勤務先名のみ表示 -->
            <div class="col-12 col-md-3 offset-0 offset-md-2">
                <label for="user_workplace">勤務先名</label>
            </div>
            <div class="col-12 col-lg-6 mb10">
                <h3>{{ $input['user_workplace'] }}</h3>
                <input type="hidden" name="user_workplace" value="{{ $input['user_workplace'] }}">
            </div>
            @endif
            <!-- 住所（関連） -->
            <div class="col-12 col-md-3 offset-0 offset-md-2">
                <label for="user_relate">住所</label>
            </div>
            <div class="col-12 col-lg-6 mb10">
                <h3>
                    @php
                    $zip1 = $input['user_relate_zip_1'] ?? $user->user_relate_zip_1 ?? '';
                    $zip2 = $input['user_relate_zip_2'] ?? $user->user_relate_zip_2 ?? '';
                    $pre = $input['user_relate_pre'] ?? $user->user_relate_pre ?? '';
                    $city = $input['user_relate_city'] ?? $user->user_relate_city ?? '';
                    $add = $input['user_relate_add'] ?? $user->user_relate_add ?? '';
                    $zip = ($zip1 && $zip2) ? $zip1.'-'.$zip2 : (($zip1 || $zip2) ? $zip1.$zip2 : '');
                    @endphp
                    {{ $zip }}{{ $pre }}{{ $city }}{{ $add }}
                </h3>
                <input type="hidden" name="user_relate_zip_1" value="{{ $input['user_relate_zip_1'] ?? $user->user_relate_zip_1 ?? '' }}">
                <input type="hidden" name="user_relate_zip_2" value="{{ $input['user_relate_zip_2'] ?? $user->user_relate_zip_2 ?? '' }}">
                <input type="hidden" name="user_relate_pre" value="{{ $input['user_relate_pre'] ?? $user->user_relate_pre ?? '' }}">
                <input type="hidden" name="user_relate_city" value="{{ $input['user_relate_city'] ?? $user->user_relate_city ?? '' }}">
                <input type="hidden" name="user_relate_add" value="{{ $input['user_relate_add'] ?? $user->user_relate_add ?? '' }}">
            </div>
            <!-- 本人確認書類1 -->
            <div class="col-12 col-md-3 offset-0 offset-md-2">
                <label for="photo_filename1">本人確認書類1</label>
            </div>
            <div class="col-12 col-lg-6 mb10">
                @if(isset($input['photo_filename1']) && $input['photo_filename1'] !== '')
                <input type="hidden" name="photo_filename1" value="{{ $input['photo_filename1'] }}">
                <img src="{{ asset('storage/photo/' . $input['photo_filename1']) }}" style="max-width:200px; margin-top:8px;">
                @endif
            </div>
            <!-- 本人確認書類2 -->
            <div class="col-12 col-md-3 offset-0 offset-md-2">
                <label for="photo_filename2">本人確認書類2</label>
            </div>
            <div class="col-12 col-lg-6 mb10">
                @if(isset($input['photo_filename2']) && $input['photo_filename2'] !== '')
                <input type="hidden" name="photo_filename2" value="{{ $input['photo_filename2'] }}">
                <img src="{{ asset('storage/photo/' . $input['photo_filename2']) }}" style="max-width:200px; margin-top:8px;">
                @endif
            </div>
            <!-- パスワード -->
            <div class="col-12 col-md-3 offset-0 offset-md-2">
                <label for="user_pass">パスワード</label>
            </div>
            <div class="col-12 col-lg-6 mb10">
                @if(isset($input['user_pass']) && $input['user_pass'] !== '')
                <h3>＊＊＊＊＊＊＊＊</h3>
                <input type="hidden" name="user_pass" value="{{ $input['user_pass'] }}">
                @endif
            </div>
            <div class="col-12 col-md-5 offset-0 offset-md-1 mt10">
                <button type="submit" class="btn btn-lg btn-block btn-success">変更を確定する</button>
            </div>
            <div class="col-12 col-md-5 mt10">
                <a href="{{ route('user.edit') }}" class="btn btn-lg btn-block btn-outline-success">戻って修正する</a>
            </div>
        </form>
    </section>
</main>
@endsection