clean/indent code

This commit is contained in:
Alexis Gousseau 2022-10-11 17:21:58 +02:00
parent 435a007ea2
commit ccabc6216d
9 changed files with 126 additions and 203 deletions

View file

@ -1,32 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddAvailableToProducts extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('products', function (Blueprint $table) {
$table->boolean('availability')->nullable()->after('status');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('products', function (Blueprint $table) {
$table->dropColumn('availability');
});
}
}

View file

@ -1,71 +1,70 @@
<template>
<div class="timeslot-container">
<p class="d-none d-lg-block title-regular text-center text-uppercase font-Barlow-extra-bold m-3">Choisissez où et quand retirer votre commande</p>
<h3 class="font-Barlow-extra-bold text-center text-lg-start text-uppercase title-small">
<span class="text-green">1.</span>
Votre point de retrait
</h3>
<div class="row row-cols-1 row-cols-md-2 g-4">
<div class="col m-0">
<div class="card card-activate mb-3">
<div class="row bkg-medium-grey shadow rounded-4 g-0 p-3">
<div class="col-4">
<img src="/sable/img/step_1.png" class="img-fluid" alt="...">
</div>
<div class="col-8 d-flex flex-column justify-content-center align-items-center">
<div class="card-body">
<h5 class="card-title title-regular text-uppercase font-Barlow-extra-bold">{{magasin.name}}</h5>
<p class="card-text font-Barlow-medium m-0">{{magasin.address}}</p>
<p class="card-text font-Barlow-medium m-0">{{magasin.postcode}} {{magasin.city}}</p>
<p class="card-text font-Barlow-medium m-0">{{magasin.phone}}</p>
</div>
</div>
</div>
</div>
</div>
<input type="hidden" :value="selectedmagasin" name="selectedmagasin"></input>
</div>
<h3 class="font-Barlow-extra-bold text-center text-lg-start text-uppercase title-small m-3">
<span class="text-green">2.</span>
Choisissez le jour du retrait de votre commande
</h3>
<div class="datetime-collect">
<div class="timeslot-pick-wrapper">
<div class="calendar">
<h2><span @click="prevMonth()" v-show="canPrevMonth()"><img src="/ldc/img/chevron_prev.svg"></span>{{ months[currentmonth] }} {{ currentyear }}<span @click="nextMonth()"><img src="/ldc/img/chevron_next.svg"></span></h2>
<header>
<div v-for="day in days" :key="day">{{ short(day) }}</div>
</header>
<section class="content">
<div v-for="tile in tiles" :class="style(tile)" @click="showCreneaux(tile)">
<span>{{ getday(tile.date) }}</span>
</div>
</section>
</div>
</div>
<input type="hidden" :value="selectedCreneau" name="selectedcreneau">
</div>
<h3 class="font-Barlow-extra-bold text-center text-lg-start text-uppercase title-small m-3">
<span class="text-green">3.</span>
Choisissez l'heure du retrait de votre commande
</h3>
<div class="row row-cols-1 row-cols-md-2 g-4">
<div class="col" v-for="(creneau,index) in creneaux" :class="styleCren(creneau)" @click="selectSlot(creneau)" ref="cren" :key="index">
<div class="card m-0 mb-lg-3" :class="styleCren(creneau)">
<div class="row bkg-medium-grey rounded-4 g-0 p-3">
<div class="d-flex flex-column justify-content-center align-items-center">
<div class="timeslot-container">
<p class="d-none d-lg-block title-regular text-center text-uppercase font-Barlow-extra-bold m-3">Choisissez où et quand retirer votre commande</p>
<h3 class="font-Barlow-extra-bold text-center text-lg-start text-uppercase title-small">
<span class="text-green">1.</span>
Votre point de retrait
</h3>
<div class="row row-cols-1 row-cols-md-2 g-4">
<div class="col m-0">
<div class="card card-activate mb-3">
<div class="row bkg-medium-grey shadow rounded-4 g-0 p-3">
<div class="col-4">
<img src="/sable/img/step_1.png" class="img-fluid" alt="...">
</div>
<div class="col-8 d-flex flex-column justify-content-center align-items-center">
<div class="card-body">
<h5 class="card-title title-small font-Barlow-medium">{{creneau.horaire}}</h5>
<h5 class="card-title title-regular text-uppercase font-Barlow-extra-bold">{{ magasin.name }}</h5>
<p class="card-text font-Barlow-medium m-0">{{ magasin.address }}</p>
<p class="card-text font-Barlow-medium m-0">{{ magasin.postcode }} {{ magasin.city }}</p>
<p class="card-text font-Barlow-medium m-0">{{ magasin.phone }}</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<input type="hidden" :value="selectedmagasin" name="selectedmagasin" />
</div>
<h3 class="font-Barlow-extra-bold text-center text-lg-start text-uppercase title-small m-3">
<span class="text-green">2.</span>
Choisissez le jour du retrait de votre commande
</h3>
<div class="datetime-collect">
<div class="timeslot-pick-wrapper">
<div class="calendar">
<h2><span @click="prevMonth()" v-show="canPrevMonth()"><img src="/ldc/img/chevron_prev.svg"></span>{{ months[currentmonth] }} {{ currentyear }}<span @click="nextMonth()"><img src="/ldc/img/chevron_next.svg"></span></h2>
<header>
<div v-for="day in days" :key="day">{{ short(day) }}</div>
</header>
<section class="content">
<div v-for="(tile, tileKey) in tiles" :key="tileKey" :class="style(tile)" @click="showCreneaux(tile)">
<span>{{ getday(tile.date) }}</span>
</div>
</section>
</div>
</div>
<input type="hidden" :value="selectedCreneau" name="selectedcreneau">
</div>
<h3 class="font-Barlow-extra-bold text-center text-lg-start text-uppercase title-small m-3">
<span class="text-green">3.</span>
Choisissez l'heure du retrait de votre commande
</h3>
<div class="row row-cols-1 row-cols-md-2 g-4">
<div class="col" v-for="(creneau,index) in creneaux" :class="styleCren(creneau)" @click="selectSlot(creneau)" ref="cren" :key="index">
<div class="card m-0 mb-lg-3" :class="styleCren(creneau)">
<div class="row bkg-medium-grey rounded-4 g-0 p-3">
<div class="d-flex flex-column justify-content-center align-items-center">
<div class="card-body">
<h5 class="card-title title-small font-Barlow-medium">{{ creneau.horaire }}</h5>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
props: {
@ -147,9 +146,6 @@ export default {
creneaux: {
get: function(){ return this.listCreneaux(); },
}
},
watch: {
},
data() {
return {
@ -178,7 +174,7 @@ export default {
nextMonth() {
if(this.currentmonth == 11) {
this.currentmonth = 0;
this.currentyear+=1;
this.currentyear += 1;
} else {
this.currentmonth+=1;
}
@ -186,9 +182,9 @@ export default {
prevMonth() {
if(this.currentmonth == 0) {
this.currentmonth = 11;
this.currentyear-=1;
this.currentyear -= 1;
} else {
this.currentmonth-=1;
this.currentmonth -= 1;
}
},
canPrevMonth() {
@ -202,15 +198,15 @@ export default {
short(value) { return value.substring(0, 3) },
getday(value) { return new Date(value).getDate() },
style(tile) {
return {
'last': tile.last,
'next': tile.next,
'current': tile.current,
'selected' : tile.selected,
'grey': tile.grey,
'unavailable': tile.unavailable
}
},
return {
'last': tile.last,
'next': tile.next,
'current': tile.current,
'selected' : tile.selected,
'grey': tile.grey,
'unavailable': tile.unavailable
}
},
styleCren(creneau) {
return {
'dispo' : creneau.dispo,
@ -225,26 +221,26 @@ export default {
let date = new Date(this.currentyear, this.currentmonth, (i < this.startday) ? -i : daycount);
let day = date.getDay() < 1 ? 6 : date.getDay() - 1;
let obj = {
//this day is from lastmonth
last: (i < this.startday) ? true : false,
//this day is next month
next: i >= this.dayscount + this.startday,
//this is a weekend day
grey: this.weekend.find((item) => item === day) ? true : false,
//this is today
current: (new Date(this.currentyear, this.currentmonth, daycount).toDateString() == this.current.toDateString()) ? true : false,
//selected
selected: (date.toLocaleDateString() == this.selectedDay) ? true : false,
//this tile's date
date: date,
//not available
unavailable: (new Date(this.current.getFullYear(), this.current.getMonth(), this.current.getDate()) > date)? true : false,
//this day is from lastmonth
last: (i < this.startday) ? true : false,
//this day is next month
next: i >= this.dayscount + this.startday,
//this is a weekend day
grey: this.weekend.find((item) => item === day) ? true : false,
//this is today
current: (new Date(this.currentyear, this.currentmonth, daycount).toDateString() == this.current.toDateString()) ? true : false,
//selected
selected: (date.toLocaleDateString() == this.selectedDay) ? true : false,
//this tile's date
date: date,
//not available
unavailable: (new Date(this.current.getFullYear(), this.current.getMonth(), this.current.getDate()) > date) ? true : false,
};
if (i < this.startday)
before.push(obj);
else {
current.push(obj);
daycount++;
daycount ++;
}
}
return before.reverse().concat(current);
@ -264,22 +260,21 @@ export default {
},
selectSlot(creneau){
if(creneau.dispo) {
this.selectedCreneau = this.selectedDay+"-"+creneau.horaire;
this.selectedCreneau = this.selectedDay + "-" + creneau.horaire;
}
},
listCreneaux() {
let todaysAvailable = [];
if(this.selectedDay in this.availableCreneaux) {
todaysAvailable = this.availableCreneaux[""+this.selectedDay];
todaysAvailable = this.availableCreneaux["" + this.selectedDay];
}
let crens = [];
todaysAvailable.forEach(element => {
let obj = {
//day: index,
horaire: element[0],
dispo: element[1],
selected: (this.selectedCreneau == this.selectedDay+"-"+element[0]) ? true : false
selected: (this.selectedCreneau == this.selectedDay + "-" + element[0]) ? true : false
};
//option pour ne générer que les créneaux disponibles
if(this.showOnlyAvailables) {
@ -294,7 +289,7 @@ export default {
},
scrollStart(way) {
this.interval = setInterval(() => {
this.scroll(way);
this.scroll(way);
}, 300);
},
scrollStop() {
@ -315,23 +310,21 @@ export default {
} else if (way == 'up') {
if (this.scrollCounter > 0) {
this.scrollCounter = this.scrollCounter - 1;
this.fixScrolling()
this.fixScrolling();
}
}
},
wheel(event) {
if ( event.deltaY < 0 )
{
if ( event.deltaY < 0 ) {
this.scroll('up');
}
else
{
else {
this.scroll('down');
}
},
fixScrolling(){
const divH = this.$refs.cren[this.scrollCounter].clientHeight;
if(this.scrollCounter==1) {
if(this.scrollCounter == 1) {
//cas du premier on va faire apparaite le bouton pour remonter, et réduire la taille du viewport de l'element
this.$refs.creneaux__slots.scrollTop = divH * this.scrollCounter + divH;
} else {
@ -348,7 +341,7 @@ export default {
},
loadAvailableCreneaux() {
if(this.selectedmagasin != null) {
$(".datetime-collect").show();
document.querySelector(".datetime-collect").show();
axios.post('/ajax/get-time-slots', {
id: this.selectedmagasin,
}).then(
@ -363,7 +356,7 @@ export default {
this.processing = false;
});
} else {
$(".datetime-collect").hide();
document.querySelector(".datetime-collect").hide();
}
}
}

View file

@ -1,9 +1,9 @@
window.showModalClearCart = function() {
$('#empty-basket-modal > div.modal').show();
$('#empty-basket-modal > div.modal').show();
}
window.closeModalClearCart = function() {
$('#empty-basket-modal > div.modal').hide();
$('#empty-basket-modal > div.modal').hide();
}
/* ----- BASKET ----- */

View file

@ -1,4 +1,4 @@
<footer id="footer" class="@if (Route::is('product') || Route::is('products')) mb-5 pb-3 @endif mb-lg-0">
<footer id="footer" class="@if (Route::is('product') || Route::is('products')) mb-5 @endif mb-lg-0">
<div class="container text-center">
<div class="row">
<div class="col">

View file

@ -10,9 +10,9 @@
@include('layouts.footer')
</div>
<script src="{{ asset(config('app.theme') . '/js/app.js') }}"></script>
@yield('scripts')
<script src="{{ asset(config('app.theme') . '/js/app.js') }}"></script>
@yield('scripts')
@include('partials.cookie')
@include('partials.cookie')
</body>
</html>

View file

@ -35,8 +35,7 @@
<div class="btn-icon btn-basket-icon"></div>
<span class="d-none d-lg-block"><basket-amount></basket-amount></span>
</button>
<a class="btn btn-icon btn-profile-icon p-0" href="{{ route('account.dashboard') }}" role="button">
</a>
<a class="btn btn-icon btn-profile-icon p-0" href="{{ route('account.dashboard') }}" role="button"></a>
</div>
</div>
</nav>

View file

@ -1,33 +0,0 @@
@section('subscribe')
<div class="subscribe section section_light">
<div class="subscribe__wrapper wrapper">
<div class="subscribe__block">
<div class="subscribe__title title title_medium">Recevez nos promotions et nouveautés</div>
{{--<form class="subscribe__form form">
@csrf--}}
<div class="subscribe__form form">
<input class="form__input" type="email" id="mailNewsletter" placeholder="Renseignez votre adresse mail" />
<button class="btn btn_contrast" id="buttonNewsletter">S’inscrire</button>
</div>
{{--</form>--}}
</div>
</div>
</div>
@stop
@push('scripts')
<script>
document.getElementById("buttonNewsletter").onclick = function(event) {
axios
.post('{{ route('add-single-optin') }}', {
email: document.getElementById("mailNewsletter").value
})
.then(function(response) {
document.getElementById("mailNewsletter").value = "";
})
.catch(function(error) {
console.log(error);
});
};
</script>
@endpush

View file

@ -1,8 +1,6 @@
<div class="recap-actions d-flex flex-row justify-content-between align-items-center w-100 my-5">
@if ( $activestep < 3 )
<a class="btn d-none d-lg-block" href="{{ route('ranges') }}">⟵ Continuer mes achats</a>
@else
<!-- -->
@endif
@if ( $activestep == 1 )
<form action="{{ route('sales.order-init') }}" method="POST">
@ -12,7 +10,7 @@
@elseif ( $activestep == 2 )
<form action="{{ route('sales.order-save-slot') }}" method="POST">
@csrf
<input type="submit" class="class="btn btn-product w-100 w-lg-fit text-uppercase font-Barlow-extra-bold rounded-4"" value="Suivant >">
<input type="submit" class="btn btn-product w-100 w-lg-fit text-uppercase font-Barlow-extra-bold rounded-4" value="Suivant >">
</form>
@endif
</div>

View file

@ -10,33 +10,31 @@
<p class="breadcrumb d-none d-lg-block text-muted p-2 m-0">Accueil / Panier / Réservation</p>
<div class="row m-0">
@include('partials.tunnel-stepper')
<form action="{{ route('sales.order-save-slot') }}" method="POST" class="col mt-6 m-lg-0">
@csrf
@if ($errors->any())
<div class="form__error">
@foreach ($errors->all() as $error)
<div>{{ $error }}</div>
@endforeach
<form action="{{ route('sales.order-save-slot') }}" method="POST" class="col mt-6 m-lg-0">
@csrf
@if ($errors->any())
<div class="form__error">
@foreach ($errors->all() as $error)
<div>{{ $error }}</div>
@endforeach
</div>
@elseif (session('success'))
<div class="form__success">
{{ session('success') }}
</div>
@endif
<input type="hidden" name="order_ref" value="{{ $order->reference }}">
<timeslot-picker :show-only-availables='false' dbavailablecreneaux='@json($availCreneaux)' dbmagasin='@json($magasin)'></timeslot-picker>
<div class="form-check d-flex flex-row-reverse justify-content-end align-items-start p-0 my-3">
<label class="form-check-label" role="button" for="ok_cgv">
J'ai lu et j'accepte les <a href="{{ route('terms') }}" target="_cgv">conditions générales de vente</a>.
</label>
<input class="form-check-input m-2 m-lg-1 @error('ok_cgv') form__error @enderror" type="checkbox" role="button" id="ok_cgv" name="ok_cgv">
</div>
@elseif (session('success'))
<div class="form__success">
{{ session('success') }}
<div class="recap-actions d-flex flex-row-reverse justify-content-between align-items-center w-100 my-5">
<input type="submit" class="btn btn-product w-100 w-lg-fit text-uppercase font-Barlow-extra-bold rounded-4" value="Suivant >">
</div>
@endif
<input type="hidden" name="order_ref" value="{{ $order->reference }}">
<timeslot-picker :show-only-availables='false' dbavailablecreneaux='@json($availCreneaux)'
dbmagasin='@json($magasin)'></timeslot-picker>
<div class="form-check d-flex flex-row-reverse justify-content-end align-items-start p-0 my-3">
<label class="form-check-label" role="button" for="ok_cgv">
J'ai lu et j'accepte les <a href="{{ route('terms') }}" target="_cgv">conditions générales de vente</a>.
</label>
<input class="form-check-input m-2 m-lg-1 @error('ok_cgv') form__error @enderror" type="checkbox" role="button" id="ok_cgv" name="ok_cgv">
</div>
<div class="recap-actions d-flex flex-row-reverse justify-content-between align-items-center w-100 my-5">
<input type="submit" class="btn btn-product w-100 w-lg-fit text-uppercase font-Barlow-extra-bold rounded-4" value="Suivant >">
</div>
</form>
</form>
</div>
</main>
@endsection