This repository has been archived by the owner on Apr 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dev: ContactForm admin panel and ContactFormSeeder
- Loading branch information
Showing
7 changed files
with
322 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace Database\Seeders; | ||
|
||
use App\Models\ContactForm; | ||
use App\Models\User; | ||
use Illuminate\Database\Console\Seeds\WithoutModelEvents; | ||
use Illuminate\Database\Seeder; | ||
|
||
class ContactFormSeeder extends Seeder | ||
{ | ||
/** | ||
* Run the database seeds. | ||
*/ | ||
public function run(): void | ||
{ | ||
//$user = User::find(0); | ||
|
||
ContactForm::create([ | ||
"id" => 0, | ||
/*"first_name" => $user->first_name, | ||
"last_name" => $user->last_name, | ||
"email" => $user->email, | ||
"gender" => $user->gender, | ||
"job_id" => $user->job_id, | ||
"birth" => $user->birth,*/ | ||
"first_name" => "Steve", | ||
"last_name" => "Rogers", | ||
"email" => "steve@minecraft.block", | ||
"gender" => 0, | ||
"job_id" => 1, | ||
"birth" => "1970-01-01", | ||
"subject" => "This website is so cool", | ||
"content" => "This is just a supportive message to tell you just how awesome your website is.", | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
main { | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
div.manager { | ||
display: grid; | ||
grid-template-columns: 1fr 1fr; | ||
gap: 3vw; | ||
|
||
flex: 1 1 auto; | ||
} | ||
|
||
h1 { | ||
margin-top: 0; | ||
margin-left: auto; | ||
margin-right: auto; | ||
width: fit-content; | ||
} | ||
|
||
/* contact list */ | ||
|
||
div.manager div#contact_list { | ||
background: rgba(0, 0, 0, 0.6); | ||
padding: 1vw; | ||
} | ||
|
||
div.manager div#contact_details { | ||
background: rgba(73, 35, 1, 0.6); | ||
} | ||
|
||
div.manager hr { | ||
margin: 0.8vw 0; | ||
} | ||
|
||
/* Seach bar */ | ||
|
||
.search_container { | ||
display: flex; | ||
align-items: center; | ||
max-width: 70%; | ||
margin: 0 auto; | ||
|
||
background: rgba(0, 0, 0, 0.4); | ||
} | ||
|
||
.search_icon { | ||
max-width: 4%; | ||
|
||
color: white; | ||
padding: 0.5vw; | ||
} | ||
|
||
.search_input { | ||
flex: 1; | ||
background: none; | ||
border: none; | ||
padding: 0.5vw; | ||
|
||
color:white; | ||
font-family: 'Minecraft', sans-serif; | ||
font-size: 100%; | ||
} | ||
|
||
.search_input:focus { | ||
outline: none; | ||
} | ||
|
||
/* contact table */ | ||
|
||
div#contact_table table { | ||
width: 100%; | ||
border-collapse: collapse; | ||
} | ||
|
||
div#contact_table th, div#contact_table td { | ||
padding: 0.1vw; | ||
text-align: center; | ||
} | ||
|
||
div#contact_table thead { | ||
background: rgba(0, 0, 0, 0.65); | ||
} | ||
|
||
div#contact_table tbody { | ||
background: rgba(0, 0, 0, 0.3); | ||
} | ||
|
||
div#contact_table tbody td { | ||
padding: 0.4vw; | ||
} | ||
|
||
div#contact_table tbody tr:hover { | ||
background: rgba(0, 0, 0, 0.5); | ||
} | ||
|
||
/* contact details */ | ||
|
||
div#contact_details { | ||
display: flex; | ||
flex-direction: column; | ||
padding: 1vw; | ||
} | ||
|
||
/* Not loaded */ | ||
|
||
div#contact_details div#contact_details_not_loaded { | ||
margin: auto; | ||
} | ||
|
||
/* Loaded */ | ||
|
||
div#contact_details div#contact_details_loaded { | ||
margin: auto; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Seach system | ||
document.querySelector('.search_input').addEventListener('input', function() { | ||
let searchValue = this.value.toLowerCase(); | ||
let rows = document.querySelectorAll('#contact_table tbody tr'); | ||
rows.forEach(function(row) { | ||
let contact = row.querySelector('td:nth-child(2)').textContent.toLowerCase(); | ||
if (contact.indexOf(searchValue) > -1) { | ||
row.style.display = ''; | ||
} else { | ||
row.style.display = 'none'; | ||
} | ||
}); | ||
}); | ||
|
||
// contact details system | ||
let not_loaded_div = document.querySelector('#contact_details_not_loaded'); | ||
let loaded_div = document.querySelector('#contact_details_loaded'); | ||
|
||
let contact_id = document.querySelector('#contact_id'); | ||
let email_field = document.querySelector('#email'); | ||
let first_name_field = document.querySelector('#first_name'); | ||
let last_name_field = document.querySelector('#last_name'); | ||
let birthday_field = document.querySelector('#birthday'); | ||
let gender_field = document.querySelector('#gender'); | ||
let job_field = document.querySelector('#job'); | ||
let subject_field = document.querySelector('#subject'); | ||
let content_field = document.querySelector('#content'); | ||
let contact_id_delete = document.querySelector('#contact_id_delete'); | ||
|
||
function displayContactDetails(contact) { | ||
loaded_div.classList.remove('hidden'); | ||
not_loaded_div.classList.add('hidden'); | ||
|
||
// Set values | ||
contact_id.value = contact.id; | ||
email_field.value = contact.email; | ||
first_name_field.value = contact.first_name; | ||
last_name_field.value = contact.last_name; | ||
birthday_field.value = contact.birth; | ||
switch (contact.gender) { | ||
case 0: | ||
gender_field = "Homme"; | ||
break; | ||
case 1: | ||
gender_field = "Femme"; | ||
break; | ||
default: | ||
gender_field = "Autre"; | ||
break; | ||
} | ||
job_field.value = contact.job_id; | ||
subject_field.value = contact.subject; | ||
content_field.value = contact.content; | ||
contact_id_delete.value = contact.id; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<h1>Gestionnaire formulaires de contact</h1> | ||
@foreach($errors->all() as $error) | ||
<div class="notif error"> | ||
<img src="{{ asset('img/white-cross.png') }}" alt="Croix blanche" onclick="closeWidget(this.parentNode)"/> | ||
<p>{{$error}}</p> | ||
</div> | ||
@endforeach | ||
<div class=manager> | ||
<div id="contacts_list"> | ||
<div class="search_container"> | ||
<img class="search_icon" src="{{ asset('img/search-icon.svg') }}" alt="Search icon"> | ||
<input type="text" class="search_input" placeholder="Rechercher..."> | ||
</div> | ||
<hr> | ||
<div id="contact_table"> | ||
<table> | ||
<thead> | ||
<tr> | ||
<th>Id</th> | ||
<th>Subject</th> | ||
</tr> | ||
</thead> | ||
|
||
<tbody> | ||
@foreach(\App\Models\ContactForm::all() as $contact) | ||
<tr onclick="displayContactDetails({{ $contact }})"> | ||
<td>{{ $contact->id }}</td> | ||
<td>{{ $contact->subject }}</td> | ||
</tr> | ||
@endforeach | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
|
||
<div id="contact_details"> | ||
<div id="contact_details_not_loaded"> | ||
<h2>Veuillez sélectionner un utilisateur</h2> | ||
</div> | ||
<div id="contact_details_loaded" class="hidden"> | ||
|
||
<table> | ||
<tr> | ||
<td>Prénom:</td><td id="first_name"></td> | ||
</tr> | ||
<tr> | ||
<td>Nom:</td><td id="last_name"></td> | ||
</tr> | ||
<tr> | ||
<td>mail:</td><td id="email"></td> | ||
</tr> | ||
<tr> | ||
<td>Genre:</td><td id="gender"></td> | ||
</tr> | ||
<tr> | ||
<td>Date de naissance:</td><td id="birthday"></td> | ||
</tr> | ||
<tr> | ||
<td>Métier:</td><td id="job"></td> | ||
</tr> | ||
</table> | ||
|
||
<table> | ||
<tr> | ||
<td id="subject"></td> | ||
</tr> | ||
<tr> | ||
<td id="content"></td> | ||
</tr> | ||
</table> | ||
|
||
<form action="/admin/contact/reply" method="post" autocomplete="off"> | ||
@csrf | ||
|
||
<input type="hidden" id="contact_id" name="id"/> | ||
|
||
<!-- response --> | ||
<div class="contact_details_field"> | ||
<label for="mailBody">Réponse :</label> | ||
<textarea id="response" name="mailBody" required/> | ||
</div> | ||
|
||
<!-- Submit --> | ||
<div class="contact_details_field"> | ||
<input type="submit" value="Envoyer"/> | ||
</div> | ||
</form> | ||
|
||
<!-- Delete button --> | ||
<div class="contact_details_field"> | ||
<form action="/admin/contact/remove" method="post"> | ||
@csrf | ||
<input type="hidden" id="contact_id_delete" name="id"/> | ||
<input type="submit" value="Supprimer"/> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters