flexbiz-server
Version:
Flexible Server
38 lines (36 loc) • 2.1 kB
JavaScript
'use strict';var Approve=global.getModel("approve");module.exports=function($router$$){$router$$.route("/approve/:id").get(function($req$$,$res$$){let $goto_home$$=configs.home_url?`<a href="${configs.home_url}">M\u1edf ch\u01b0\u01a1ng tr\u00ecnh</a>`:"";Approve.approve($req$$.params.id,$e$$=>{let $msg$$="B\u1ea1n \u0111\u00e3 duy\u1ec7t th\u00e0nh c\u00f4ng.";$e$$&&($msg$$=$e$$);$res$$.send(`
<html>
<head>
<meta content="width=device-width, initial-scale=1.0, shrink-to-fit=no" name="viewport"/>
<title>${configs.program}</title>
</head>
<body>
<h1 style="text-align:center;color:green">${$msg$$}</h1>
<div style="text-align:center">${$goto_home$$}</div>
</body>
</html>`)})});$router$$.route("/deny-approve/:id").get(function($req$$,$res$$){$res$$.send(`<html>
<head>
<meta content="width=device-width, initial-scale=1.0, shrink-to-fit=no" name="viewport"/>
<title>${configs.program}</title>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script>
var reason = prompt("L\u00fd do t\u1eeb ch\u1ed1i:","");
if(reason!=null){
var url_deny = "/public/deny-approve/${$req$$.params.id}";
axios.post(url_deny, {
reason: reason
})
.then(function (response) {
alert("B\u1ea1n \u0111\u00e3 t\u1eeb ch\u1ed1i duy\u1ec7t y\u00eau c\u1ea7u n\u00e0y");
})
.catch(function (error) {
alert(error.response.data || error);
});
}
</script>
</head>
<body>
<h1 style="text-align:center;color:red">B\u1ea1n \u0111\u00e3 t\u1eeb ch\u1ed1i duy\u1ec7t y\u00eau c\u1ea7u n\u00e0y</h1>
<div style="text-align:center">${configs.home_url?`<a href="${configs.home_url}">M\u1edf ch\u01b0\u01a1ng tr\u00ecnh</a>`:""}</div>
</body>
</html>`)});$router$$.route("/deny-approve/:id").post(function($req$$,$res$$){Approve.deny($req$$.params.id,$e$$=>{if($e$$)return $res$$.status(400).send($e$$);$res$$.send({ok:!0})},null,{reason:($req$$.body||{}).reason})})};