cms-frontend/resources/views/pages/add-terms-and-privacy.blade...

84 lines
3.1 KiB
PHP

@extends('layouts.app')
@section('page_title', 'Add Terms and Privacy')
@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 Terms and Privacy</h5>
</div>
<div class="row justify-content-center">
<div class="card-body p-3">
<form id="addTermsAndPrivacyForm">
<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="details" class="form-label">Details</label>
<textarea class="form-control" id="details" rows="6" placeholder="Enter details" required></textarea>
</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="Terms">Terms</option>
<option value="Privacy">Privacy</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 Terms and Privacy</button>
</div>
</form>
</div>
</div>
<style>
.card {
border-radius: 5px;
border: 1px solid #dee2e6;
}
.form-label {
font-size: 0.95rem;
}
.form-control,
.form-select,
textarea.form-control {
font-size: 0.9rem;
width: 100%;
}
</style>
<script>
document.getElementById('addTermsAndPrivacyForm').addEventListener('submit', function(e) {
e.preventDefault();
const title = document.getElementById('title').value;
const details = document.getElementById('details').value;
const type = document.getElementById('type').value;
if (!title || !details || !type) {
alert('Please fill out all required fields.');
return;
}
const newTerm = {
id: Date.now(),
title,
details,
type
};
let termsAndPrivacy = JSON.parse(sessionStorage.getItem('termsAndPrivacy') || '[]');
termsAndPrivacy.push(newTerm);
sessionStorage.setItem('termsAndPrivacy', JSON.stringify(termsAndPrivacy));
alert('Terms and Privacy added successfully!');
window.location.href = '/terms-and-privacy';
});
document.querySelector('.btn-outline-secondary').addEventListener('click', function() {
window.location.href = '/terms-and-privacy';
});
</script>
@endsection