95 lines
3.7 KiB
PHP
95 lines
3.7 KiB
PHP
@extends('layouts.app')
|
|
|
|
@section('page_title', 'Add Notification')
|
|
|
|
@section('content')
|
|
<div class="card">
|
|
<div class="card-header border-0 bg-transparent">
|
|
<h5 class="mb-0 fw-bold text-dark">Add Notification</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<form id="addNotificationForm">
|
|
<div class="mb-3">
|
|
<label for="subject" class="form-label">Subject</label>
|
|
<input type="text" class="form-control" id="subject" required>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="content" class="form-label">Content</label>
|
|
<textarea class="form-control" id="content" rows="4" required></textarea>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="isScheduled" class="form-label">Is Scheduled</label>
|
|
<select class="form-select" id="isScheduled" required>
|
|
<option value="">Select option</option>
|
|
<option value="Yes">Yes</option>
|
|
<option value="No">No</option>
|
|
</select>
|
|
</div>
|
|
<div class="d-flex justify-content-end">
|
|
<button type="button" class="btn btn-outline-secondary me-2" onclick="window.location.href='/notification'">Cancel</button>
|
|
<button type="submit" class="btn btn-primary">Add Notification</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<style>
|
|
.card {
|
|
border-radius: 10px;
|
|
font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
|
|
}
|
|
.card-header {
|
|
background-color: transparent;
|
|
}
|
|
.form-label {
|
|
font-weight: 500;
|
|
font-size: 0.9rem;
|
|
}
|
|
.form-control,
|
|
.form-select {
|
|
font-size: 0.9rem;
|
|
border-radius: 5px;
|
|
}
|
|
.btn-primary {
|
|
background-color: #E74610;
|
|
border-color: #E74610;
|
|
}
|
|
.btn-primary:hover {
|
|
background-color: #E74610;
|
|
border-color: #E74610;
|
|
}
|
|
</style>
|
|
|
|
<script>
|
|
document.getElementById('addNotificationForm').addEventListener('submit', function(e) {
|
|
e.preventDefault();
|
|
|
|
const subject = document.getElementById('subject').value;
|
|
const content = document.getElementById('content').value;
|
|
const isScheduled = document.getElementById('isScheduled').value;
|
|
|
|
if (!subject || !content || !isScheduled) {
|
|
alert('Please fill out all fields.');
|
|
return;
|
|
}
|
|
|
|
// Simulate adding notification (frontend-only)
|
|
const newNotification = {
|
|
id: Date.now(), // Unique ID based on timestamp
|
|
subject: subject,
|
|
content: content,
|
|
isScheduled: isScheduled === 'Yes' ? 'Scheduled' : 'Not Scheduled',
|
|
schedule: isScheduled === 'Yes' ? new Date().toISOString().slice(0, 16).replace('T', ' ') : '',
|
|
expiration: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000).toISOString().slice(0, 16).replace('T', ' ')
|
|
};
|
|
|
|
// Store in sessionStorage to simulate adding
|
|
let notifications = JSON.parse(sessionStorage.getItem('notifications') || '[]');
|
|
notifications.push(newNotification);
|
|
sessionStorage.setItem('notifications', JSON.stringify(notifications));
|
|
|
|
alert('Notification added successfully!');
|
|
window.location.href = '/notification';
|
|
});
|
|
</script>
|
|
@endsection |