<%- include('partials/header.ejs') %>
<link href="/styles/users/category.css" rel="stylesheet"></link>
  
<section class='Main region'>
    <div class='sidebar'>
        <%- include('partials/menu.ejs') %>
    </div>

    <div class='content'>
        <form action='/users/category' method='post' >
            <a>ឈ្មោះជំពូកៈ</a><input type='text' name='label' required />
            <a>រូបសញ្ញាៈ</a><input type='text' name='thumb' required />
            <a>ពេល​បង្កើតៈ</a><input type='datetime-local' value='<%= datetime %>' name="datetime" required />
            <a></a><input type='submit' value='បញ្ជូនទិន្នន័យ' />
        </form>
    </div>
</section>
    
<%- include('partials/footer.ejs') %>

 

.Main .content form{
    width: 60%;
    display: grid;
    grid-template-columns: 20% 80%;
    grid-gap: 5px;
    align-items: center;
}

.Main .content form input{
    padding: 5px 10px;
}

.Main .content form input[type=submit]{
    font: var(--body-font);
}

.Main .content form a{
    text-align: right;
}

 

var express = require('express')
var router = express.Router()
var settings = require('../settings')


router.get('/', async function(req, res, next) {
  settings.dLogo = 'ទំព័រ​គ្រប់គ្រង'
  settings.message = ''

  if(req.session.user){
    res.render('users/index', settings)
  }else{
    res.render('login', settings)
  }
})

router.post('/', async function(req, res, next){
  const checkUser = require('../controllers/users/checkUser')
  const result = await checkUser(req)
  settings.message = result.message

  if(result.success){
    res.render('users/index', settings)
  }else{
    res.render('login', settings)
  }

})

router.get('/logout', async function(req, res, next) {
  req.session.destroy(function(err) {
      console.log('Session was destroyed')
   })
  res.redirect('/')
})

router.get('/post', async function(req, res, next) {
  settings.dLogo = 'ទំព័រ​ការផ្សាយ'

  if(req.session.user){
    res.render('users/post', settings)
  }else{
    res.redirect('/login')
  }
})

router.get('/category', async function(req, res, next) {
  settings.dLogo = 'ទំព័រ​ជំពូក'

  const today = new Date()
  const date = today.toLocaleDateString('fr-CA')
  const time = today.toLocaleTimeString('it-IT')
  settings.datetime = date + 'T' +  time

  if(req.session.user){
    res.render('users/category', settings)
  }else{
    res.redirect('/login')
  }
}) 

router.post('/category', async function(req, res, next){
  if(req.session.user){
    console.log(req.body.label)
    res.redirect('/users/category')
  }else{
    res.redirect('/login')
  }
})

module.exports = router

 

GitHub: https://github.com/Sokhavuth/tv

Vercel: https://tv-neon.vercel.app

Responsive: http://www.responsinator.com