Skip to content

Commit

Permalink
feat: add dto
Browse files Browse the repository at this point in the history
  • Loading branch information
dewanakl committed Sep 12, 2024
1 parent 174fec4 commit fa13a14
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
7 changes: 4 additions & 3 deletions js/admin.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { dto } from './dto.js';
import { util } from './util.js';
import { storage } from './storage.js';
import { session } from './session.js';
Expand Down Expand Up @@ -99,7 +100,7 @@ export const admin = (() => {

await request(HTTP_PUT, '/api/key').
token(session.getToken()).
send().
send(dto.statusResponse).
then((res) => {
if (res.data.status) {
getUserDetail();
Expand Down Expand Up @@ -129,7 +130,7 @@ export const admin = (() => {
old_password: old.value,
new_password: newest.value,
}).
send().
send(dto.statusResponse).
then((res) => res.data.status, () => false);

btn.restore();
Expand Down Expand Up @@ -162,7 +163,7 @@ export const admin = (() => {
body({
name: name.value,
}).
send().
send(dto.statusResponse).
then((res) => res.data.status, () => false);

name.disabled = false;
Expand Down
7 changes: 7 additions & 0 deletions js/dto.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ export const dto = (() => {
};
});

const statusResponse = (({ status }) => {
return {
status,
};
});

const commentShowMore = ((uuid, show = false) => {
return {
uuid,
Expand All @@ -58,6 +64,7 @@ export const dto = (() => {

return {
baseResponse,
statusResponse,
likeCommentResponse,
postCommentResponse,
commentShowMore,
Expand Down
3 changes: 2 additions & 1 deletion js/like.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { dto } from './dto.js';
import { storage } from './storage.js';
import { session } from './session.js';
import { confetti } from './confetti.js';
Expand All @@ -18,7 +19,7 @@ export const like = (() => {
if (likes.has(id)) {
await request(HTTP_PATCH, '/api/comment/' + likes.get(id))
.token(session.getToken())
.send()
.send(dto.statusResponse)
.then((res) => {
if (res.data.status) {
likes.unset(id);
Expand Down

0 comments on commit fa13a14

Please sign in to comment.