104 lines
4.1 KiB
PHP
104 lines
4.1 KiB
PHP
@extends('layouts.app')
|
|
|
|
@section('page_title', 'Add Promotion')
|
|
|
|
@section('content')
|
|
<div class="card-header border-0 bg-transparent py-2">
|
|
<h5 class="mb-0 fw-bold text-dark" style="font-size: 1.25rem;">Add Promotion</h5>
|
|
</div>
|
|
<div class="row justify-content-center">
|
|
<div class="card-body p-3">
|
|
<form id="addPromotionForm">
|
|
<div class="mb-3">
|
|
<label for="title" class="form-label">Title</label>
|
|
<input type="text" class="form-control" id="title" placeholder="Enter title" required>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="type" class="form-label">Type</label>
|
|
<select class="form-select" id="type" required>
|
|
<option value="" disabled selected>Select type</option>
|
|
<option value="Discount">Discount</option>
|
|
<option value="Flash Sale">Flash Sale</option>
|
|
<option value="Reward">Reward</option>
|
|
<option value="Bundle">Bundle</option>
|
|
</select>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="startDate" class="form-label">Start Date</label>
|
|
<input type="date" class="form-control" id="startDate" required>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="endDate" class="form-label">End Date</label>
|
|
<input type="date" class="form-control" id="endDate" required>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="status" class="form-label">Status</label>
|
|
<select class="form-select" id="status" required>
|
|
<option value="" disabled selected>Select status</option>
|
|
<option value="Done">Done</option>
|
|
<option value="On Going">On Going</option>
|
|
</select>
|
|
</div>
|
|
<div class="d-flex justify-content-end mt-3">
|
|
<button type="button" class="btn btn-outline-secondary me-2" style="margin-right:5px">Cancel</button>
|
|
<button type="submit" class="btn btn-primary">Add Promotion</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<style>
|
|
.card {
|
|
border-radius: 5px;
|
|
border: 1px solid #dee2e6;
|
|
}
|
|
.form-label {
|
|
font-size: 0.95rem;
|
|
}
|
|
.form-control,
|
|
.form-select {
|
|
font-size: 0.9rem;
|
|
width: 100%;
|
|
}
|
|
</style>
|
|
|
|
<script>
|
|
document.getElementById('addPromotionForm').addEventListener('submit', function(e) {
|
|
e.preventDefault();
|
|
|
|
const title = document.getElementById('title').value;
|
|
const type = document.getElementById('type').value;
|
|
const startDate = document.getElementById('startDate').value;
|
|
const endDate = document.getElementById('endDate').value;
|
|
const status = document.getElementById('status').value;
|
|
|
|
if (!title || !type || !startDate || !endDate || !status) {
|
|
alert('Please fill out all fields.');
|
|
return;
|
|
}
|
|
|
|
// Simulate adding promotion (frontend-only)
|
|
const newPromotion = {
|
|
id: Date.now(),
|
|
title: title,
|
|
type: type,
|
|
startDate: startDate,
|
|
endDate: endDate,
|
|
status: status
|
|
};
|
|
|
|
// Store in sessionStorage
|
|
let promotions = JSON.parse(sessionStorage.getItem('promotions') || '[]');
|
|
promotions.push(newPromotion);
|
|
sessionStorage.setItem('promotions', JSON.stringify(promotions));
|
|
|
|
alert('Promotion added successfully!');
|
|
window.location.href = '/promotions';
|
|
});
|
|
|
|
// Cancel button click handler
|
|
document.querySelector('.btn-outline-secondary').addEventListener('click', function() {
|
|
window.location.href = '/promotions';
|
|
});
|
|
</script>
|
|
@endsection |