Skip to content

Commit

Permalink
rmv redundant codes
Browse files Browse the repository at this point in the history
  • Loading branch information
huytran17 committed Aug 23, 2024
1 parent eeb1d7a commit 9de783a
Show file tree
Hide file tree
Showing 44 changed files with 113 additions and 983 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ export default {
this.is_open_update_dialog = false;
const gallery_id = this.$route.params.id;
if (gallery_id) {
return await Promise.all([
this.GET_GALLERIES_BY_PARENT({ parent_id: gallery_id }),
this.GET_GALLERY({ _id: gallery_id }),
]);
if (!gallery_id) {
return await this.GET_GALLERIES_PAGINATED({ is_parent: true });
}
await this.GET_GALLERIES_PAGINATED({ is_parent: true });
await Promise.all([
this.GET_GALLERIES_BY_PARENT({ parent_id: gallery_id }),
this.GET_GALLERY({ _id: gallery_id }),
]);
} catch (error) {
console.error(error);
}
Expand Down
6 changes: 0 additions & 6 deletions core/admin-dashboard/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@
"Restore": "Restore",
"Delete": "Delete",
"Delete Forever": "Delete Forever",
"Disable auto censorship post": "Disable auto censorship post",
"Disable auto censorship for admin ${email} successfully": "Disable auto censorship for admin ${email} successfully",
"Encountered error while disabling auto censorship": "Encountered error while disabling auto censorship",
"Enable auto censorship for admin ${email} successfully": "Enable auto censorship for admin ${email} successfully",
"Encountered error while enabling auto censorship": "Encountered error while enabling auto censorship",
"Restored admin ${title} successfully": "Restored admin ${title} successfully",
"Encountered error while restoring admin": "Encountered error while restoring admin",
"Deleted admin ${title} successfully": "Deleted admin ${title} successfully",
Expand All @@ -42,7 +37,6 @@
"Password": "Password",
"Password Confirmation": "Password Confirmation",
"Type": "Type",
"Enable auto censorship post": "Enable auto censorship post",
"Create": "Create",
"Created admin successfully": "Created admin successfully",
"Encountered error while creating admin": "Encountered error while creating admin",
Expand Down
6 changes: 0 additions & 6 deletions core/admin-dashboard/locales/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@
"Restore": "Khôi phục",
"Delete": "Xóa",
"Delete Forever": "Xóa vĩnh viễn",
"Disable auto censorship post": "Tắt tự động kiểm duyệt bài viết",
"Enable auto censorship post": "Bật tự động kiểm duyệt bài viết",
"Disable auto censorship for admin ${email} successfully": "Tắt tự động kiểm duyệt thành công cho quản trị viên {email}",
"Encountered error while disabling auto censorship": "Xảy ra lỗi trong khi tắt tự dộng kiểm duyệt",
"Enable auto censorship for admin ${email} successfully": "Bật tự động kiểm duyệt thành công cho quản trị viên {email}",
"Encountered error while enabling auto censorship": "Xảy ra lỗi trong khi bật tự dộng kiểm duyệt",
"Restored admin ${title} successfully": "Khôi phục thành công quản trị viên {title}",
"Encountered error while restoring admin": "Xảy ra lỗi trong khi khôi phục quản trị viên",
"Deleted admin ${title} successfully": "Đã xóa quản trị viên {title}",
Expand Down
2 changes: 0 additions & 2 deletions core/admin-dashboard/mixins/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ export default {
DELETE_ADMIN: "admin/DELETE_ADMIN",
RESTORE_ADMIN: "admin/RESTORE_ADMIN",
HARD_DELETE_ADMIN: "admin/HARD_DELETE_ADMIN",
DISABLE_AUTO_CENSORSHIP_POST: "admin/DISABLE_AUTO_CENSORSHIP_POST",
ENABLE_AUTO_CENSORSHIP_POST: "admin/ENABLE_AUTO_CENSORSHIP_POST",
UPDATE_ADMIN_PASSWORD: "admin/UPDATE_ADMIN_PASSWORD",
GET_ADMIN_ANALYTICS: "admin/GET_ADMIN_ANALYTICS",
RESET_ADMIN_LOGIN_FAILED_TIMES: "admin/RESET_ADMIN_LOGIN_FAILED_TIMES",
Expand Down
4 changes: 0 additions & 4 deletions core/admin-dashboard/mixins/comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ export default {
methods: {
...mapActions({
GET_COMMENTS: "comment/GET_COMMENTS",
GET_COMMENT: "comment/GET_COMMENT",
CREATE_COMMENT: "comment/CREATE_COMMENT",
UPDATE_COMMENT: "comment/UPDATE_COMMENT",
UPLOAD_COMMENT_THUMBNAIL: "comment/UPLOAD_COMMENT_THUMBNAIL",
HARD_DELETE_COMMENT: "comment/HARD_DELETE_COMMENT",
}),
...mapMutations({
Expand Down
1 change: 0 additions & 1 deletion core/admin-dashboard/mixins/gallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export default {
DELETE_GALLERY_ITEM: "gallery/DELETE_GALLERY_ITEM",
HARD_DELETE_GALLERY: "gallery/HARD_DELETE_GALLERY",
CREATE_GALLERY: "gallery/CREATE_GALLERY",
UPLOAD_GALLERY_ITEM: "gallery/UPLOAD_GALLERY_ITEM",
GET_GALLERY: "gallery/GET_GALLERY",
GET_GALLERIES_BY_PARENT: "gallery/GET_GALLERIES_BY_PARENT",
UPDATE_GALLERY: "gallery/UPDATE_GALLERY",
Expand Down
1 change: 0 additions & 1 deletion core/admin-dashboard/mixins/subscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export default {
methods: {
...mapActions({
GET_SUBSCRIPTIONS: "subscription/GET_SUBSCRIPTIONS",
GET_SUBSCRIPTION: "subscription/GET_SUBSCRIPTION",
GET_SUBSCRIPTION_ANALYTICS: "subscription/GET_SUBSCRIPTION_ANALYTICS",
}),
...mapMutations({
Expand Down
1 change: 0 additions & 1 deletion core/admin-dashboard/mixins/system-configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export default {
},
methods: {
...mapActions({
GET_SYSTEM_CONFIGURATION: "system-configuration/GET_SYSTEM_CONFIGURATION",
GET_LATEST_SYSTEM_CONFIGURATION:
"system-configuration/GET_LATEST_SYSTEM_CONFIGURATION",
UPDATE_SYSTEM_CONFIGURATION:
Expand Down
2 changes: 0 additions & 2 deletions core/admin-dashboard/store/admin/action-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ export enum ActionTypes {
UPDATE_ADMIN = "UPDATE_ADMIN",
DELETE_ADMIN = "DELETE_ADMIN",
HARD_DELETE_ADMIN = "HARD_DELETE_ADMIN",
ENABLE_AUTO_CENSORSHIP_POST = "ENABLE_AUTO_CENSORSHIP_POST",
RESTORE_ADMIN = "RESTORE_ADMIN",
DISABLE_AUTO_CENSORSHIP_POST = "DISABLE_AUTO_CENSORSHIP_POST",
UPDATE_ADMIN_PASSWORD = "UPDATE_ADMIN_PASSWORD",
UPDATE_ADMIN_PERSONAL_PASSWORD = "UPDATE_ADMIN_PERSONAL_PASSWORD",
GET_ADMIN_ANALYTICS = "GET_ADMIN_ANALYTICS",
Expand Down
79 changes: 18 additions & 61 deletions core/admin-dashboard/store/admin/actions.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { ActionTypes } from "./action-types";
import { MutationTypes } from "./mutation-types";
import { ADMIN_TYPES } from "@/constants";
import { get, join } from "lodash";
import { ActionTree } from "vuex";
import { AdminState } from ".";
import { RootState } from "..";
import { ADMIN_TYPES } from "@/constants";
import { get, join } from "lodash";
import { ActionTypes } from "./action-types";
import { MutationTypes } from "./mutation-types";

const actions: ActionTree<AdminState, RootState> = {
async [ActionTypes.GET_ADMIN_ANALYTICS]({ commit }, params = {}) {
Expand All @@ -24,71 +24,42 @@ const actions: ActionTree<AdminState, RootState> = {

const { data } = await this.$axios.$get(`/admin/analystics?${url_query}`);
commit(MutationTypes.SET_ADMIN_ANALYS_DATA, { data });
return data;
},

async [ActionTypes.GET_ADMINS]({ commit }, params = {}) {
const keep_in_store = get(params, "keep_in_store", true);

const { data: admins } = await this.$axios.$get("/admin");
const { data } = await this.$axios.$get("/admin");

if (!keep_in_store) {
return admins;
return data;
}

commit(MutationTypes.SET_ADMINS, { data: admins });
return admins;
},

async [ActionTypes.ENABLE_AUTO_CENSORSHIP_POST](
{ commit },
{ id }: { id: string }
) {
const { data: admin } = await this.$axios.$put(
`/admin/enable-auto-censorship/${id}`
);
return admin;
commit(MutationTypes.SET_ADMINS, { data });
return data;
},

async [ActionTypes.UPDATE_ADMIN_PASSWORD](
{ commit },
{ data }: { data: any }
) {
const { data: admin } = await this.$axios.$put(`/admin/password`, data);
return admin;
await this.$axios.$put(`/admin/password`, data);
},

async [ActionTypes.UPDATE_ADMIN_PERSONAL_PASSWORD](
{ commit },
{ data }: { data: any }
) {
const { data: admin } = await this.$axios.$put(
`/admin/personal-password`,
data
);
return admin;
await this.$axios.$put(`/admin/personal-password`, data);
},

async [ActionTypes.RESTORE_ADMIN]({ commit }, { id }: { id: string }) {
const { data: admin } = await this.$axios.$put(`/admin/restore/${id}`);
return admin;
},

async [ActionTypes.DISABLE_AUTO_CENSORSHIP_POST](
{ commit },
{ id }: { id: string }
) {
const { data: admin } = await this.$axios.$put(
`/admin/disable-auto-censorship/${id}`
);
return admin;
await this.$axios.$put(`/admin/restore/${id}`);
},

async [ActionTypes.GET_ADMIN]({ commit }, { id }: { id: string }) {
const { data: admin } = await this.$axios.$get(`/admin/${id}`);

commit(MutationTypes.SET_ADMIN, { data: admin });
return admin;
const { data } = await this.$axios.$get(`/admin/${id}`);
commit(MutationTypes.SET_ADMIN, { data });
},

async [ActionTypes.CREATE_ADMIN]({ commit }, { data }: { data: any }) {
Expand All @@ -97,31 +68,22 @@ const actions: ActionTree<AdminState, RootState> = {
},

async [ActionTypes.UPDATE_ADMIN]({ commit }, { data }: { data: any }) {
const { data: admin } = await this.$axios.$put(`/admin`, data);
return admin;
await this.$axios.$put(`/admin`, data);
},

async [ActionTypes.DELETE_ADMIN]({ commit }, { id }: { id: string }) {
const { data: admin } = await this.$axios.$delete(`/admin/${id}`);
return admin;
await this.$axios.$delete(`/admin/${id}`);
},

async [ActionTypes.HARD_DELETE_ADMIN]({ commit }, { id }: { id: string }) {
const { data: admin } = await this.$axios.$delete(
`/admin/hard-delete/${id}`
);
return admin;
await this.$axios.$delete(`/admin/hard-delete/${id}`);
},

async [ActionTypes.RESET_ADMIN_LOGIN_FAILED_TIMES](
{ commit },
{ id }: { id: string }
) {
const { data: admin } = await this.$axios.$put(
`/admin/reset-admin-login-failed-times/${id}`
);

return admin;
await this.$axios.$put(`/admin/reset-admin-login-failed-times/${id}`);
},

async [ActionTypes.BATCH_UPLOAD_ADMINS]({ commit }, params = {}) {
Expand All @@ -130,12 +92,7 @@ const actions: ActionTree<AdminState, RootState> = {
const form_data = new FormData();
form_data.append("file", file);

const data = await this.$axios.post(
`/v2/batch/admin/upload-admins`,
form_data
);

return data;
await this.$axios.post(`/v2/batch/admin/upload-admins`, form_data);
},

async [ActionTypes.GET_ADMINS_PAGINATED]({ commit }, params = {}) {
Expand Down
19 changes: 7 additions & 12 deletions core/admin-dashboard/store/auth/actions.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
import { ActionTypes } from "./action-types";
import { MutationTypes } from "./mutation-types";
import { ActionTree } from "vuex";
import { AuthState } from "./";
import { RootState } from "..";
import { AuthState } from "./";
import { ActionTypes } from "./action-types";
import { MutationTypes } from "./mutation-types";

const actions: ActionTree<AuthState, RootState> = {
async [ActionTypes.SIGN_IN]({ commit }, { data }: { data: any }) {
const returned_data = await this.$axios.$post("/auth/sign-in", data);

await this.$axios.$post("/auth/sign-in", data);
commit(MutationTypes.SET_HAS_USER, { data: true });
return returned_data;
},

async [ActionTypes.SIGN_OUT]() {
const { data } = await this.$axios.$post("/auth/sign-out");

return data;
await this.$axios.$post("/auth/sign-out");
},

async [ActionTypes.GET_ME]({ commit }) {
const { data: user } = await this.$axios.$get("/auth/me");
const { data } = await this.$axios.$get("/auth/me");

commit(MutationTypes.SET_ME, { data: user });
commit(MutationTypes.SET_ME, { data });
commit(MutationTypes.SET_HAS_USER, { data: true });
return user;
},
};

Expand Down
37 changes: 11 additions & 26 deletions core/admin-dashboard/store/category/actions.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { ActionTypes } from "./action-types";
import { MutationTypes } from "./mutation-types";
import { get, join } from "lodash";
import { ActionTree } from "vuex";
import { CategoryState } from ".";
import { RootState } from "..";
import { get, join } from "lodash";
import { ActionTypes } from "./action-types";
import { MutationTypes } from "./mutation-types";

const actions: ActionTree<CategoryState, RootState> = {
async [ActionTypes.GET_CATEGORY_ANALYTICS]({ commit }, params = {}) {
Expand All @@ -25,28 +25,22 @@ const actions: ActionTree<CategoryState, RootState> = {
`/category/analystics?${url_query}`
);
commit(MutationTypes.SET_CATEGORY_ANALYS_DATA, { data });
return data;
},
async [ActionTypes.GET_CATEGORIES]({ commit }, params = {}) {
const keep_in_store = get(params, "keep_in_store", true);

const { data: categories } = await this.$axios.$get("/category");
const { data } = await this.$axios.$get("/category");

if (!keep_in_store) {
return categories;
return data;
}

commit(MutationTypes.SET_CATEGORIES, { data: categories });

return categories;
commit(MutationTypes.SET_CATEGORIES, { data });
},

async [ActionTypes.GET_CATEGORY]({ commit }, { id }: { id: string }) {
const { data: category } = await this.$axios.$get(`/category/${id}`);

commit(MutationTypes.SET_CATEGORY, { data: category });

return category;
const { data } = await this.$axios.$get(`/category/${id}`);
commit(MutationTypes.SET_CATEGORY, { data });
},

async [ActionTypes.CREATE_CATEGORY]({ commit }, { data }: { data: any }) {
Expand All @@ -59,27 +53,18 @@ const actions: ActionTree<CategoryState, RootState> = {
const { data: category } = await this.$axios.$put(`/category/${_id}`, data);

commit(MutationTypes.SET_CATEGORY, { data: category });

return category;
},

async [ActionTypes.DELETE_CATEGORY]({ commit }, { id }: { id: string }) {
const { data: category } = await this.$axios.$delete(`/category/${id}`);
return category;
await this.$axios.$delete(`/category/${id}`);
},

async [ActionTypes.RESTORE_CATEGORY]({ commit }, { id }: { id: string }) {
const { data: category } = await this.$axios.$put(
`/category/restore/${id}`
);
return category;
await this.$axios.$put(`/category/restore/${id}`);
},

async [ActionTypes.HARD_DELETE_CATEGORY]({ commit }, { id }: { id: string }) {
const { data: category } = await this.$axios.$delete(
`/category/hard-delete/${id}`
);
return category;
await this.$axios.$delete(`/category/hard-delete/${id}`);
},
};

Expand Down
4 changes: 0 additions & 4 deletions core/admin-dashboard/store/comment/action-types.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
export enum ActionTypes {
GET_COMMENTS = "GET_COMMENTS",
GET_COMMENT = "GET_COMMENT",
CREATE_COMMENT = "CREATE_COMMENT",
UPDATE_COMMENT = "UPDATE_COMMENT",
UPLOAD_COMMENT_THUMBNAIL = "UPLOAD_COMMENT_THUMBNAIL",
HARD_DELETE_COMMENT = "HARD_DELETE_COMMENT",
}
Loading

0 comments on commit 9de783a

Please sign in to comment.