This repository has been archived by the owner on Jan 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from beohoang98/feature/partner-management
Feature/partner management
- Loading branch information
Showing
30 changed files
with
595 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
171 changes: 171 additions & 0 deletions
171
packages/client/src/admins/components/Partner/PartnerDetailModal.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
<template> | ||
<el-dialog | ||
close-on-press-escape | ||
:close-on-click-modal="false" | ||
:visible="localVisible" | ||
@close="handleOnClose" | ||
@closed="handleClosed" | ||
fullscreen | ||
modal-fade | ||
v-loading="isLoading || !isLoaded" | ||
> | ||
<template #title> | ||
<el-page-header | ||
title="Back" | ||
content="Details" | ||
@back="handleOnClose" | ||
/> | ||
</template> | ||
<el-tabs tab-position="top"> | ||
<el-tab-pane label="Info"> | ||
<el-form | ||
ref="form" | ||
label-position="left" | ||
:model="info" | ||
:rules="editInfoRules" | ||
> | ||
<el-form-item label="Public Key" prop="publicKey"> | ||
<el-input | ||
readonly | ||
type="password" | ||
show-password | ||
v-model="info.publicKey" | ||
/> | ||
</el-form-item> | ||
<el-collapse> | ||
<el-collapse-item title="More"> | ||
<el-form-item | ||
label="New Password" | ||
prop="newPassword" | ||
> | ||
<el-input | ||
readonly | ||
show-password | ||
type="password" | ||
v-model="info.newPassword" | ||
/> | ||
</el-form-item> | ||
</el-collapse-item> | ||
</el-collapse> | ||
</el-form> | ||
</el-tab-pane> | ||
<el-tab-pane label="Transactions"> | ||
<el-row> | ||
<el-col> | ||
<el-card> | ||
<template #header> | ||
<h2>Total transaction</h2> | ||
</template> | ||
<p>{{ stat.transCount }}</p> | ||
</el-card> | ||
</el-col> | ||
<el-col> | ||
<el-card> | ||
<template #header> | ||
<h2>Total amount</h2> | ||
</template> | ||
<p>{{ stat.transSum | vndFormat }}</p> | ||
</el-card> | ||
</el-col> | ||
</el-row> | ||
<el-divider /> | ||
<el-table :data="transactions"></el-table> | ||
</el-tab-pane> | ||
</el-tabs> | ||
</el-dialog> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { Component, Ref, Vue } from "vue-property-decorator"; | ||
import { Form } from "element-ui"; | ||
import { axiosInstance } from "@/utils/axios"; | ||
@Component({ | ||
name: "partner-detail-modal", | ||
}) | ||
export default class PartnerDetailModal extends Vue { | ||
@Ref("form") form!: Form; | ||
localVisible = false; | ||
isLoading = false; | ||
isLoaded = false; | ||
transactions: Transaction[] = []; | ||
info = { | ||
publicKey: "", | ||
newPassword: "", | ||
}; | ||
editInfoRules = { | ||
publicKey: [{ type: "string", required: false }], | ||
newPassword: [{ type: "string", min: 6, required: false }], | ||
}; | ||
stat = { | ||
transCount: 0, | ||
transSum: 0, | ||
}; | ||
handleOnClose() { | ||
this.form.resetFields(); | ||
this.localVisible = false; | ||
} | ||
handleClosed() { | ||
this.isLoaded = false; | ||
this.$router.replace({ | ||
name: "partner-management", | ||
}); | ||
} | ||
get partnerId() { | ||
return this.$route.params.id; | ||
} | ||
fetchTransaction() { | ||
axiosInstance | ||
.get<Paginate<PartnerTransLog>>( | ||
`/admin/partner/${this.partnerId}/transactions`, | ||
) | ||
.then(({ data }) => { | ||
this.transactions = data.items.map((item) => item.transaction); | ||
}); | ||
axiosInstance | ||
.get(`/admin/partner/${this.partnerId}/transaction-total`) | ||
.then(({ data }) => { | ||
console.debug(data); | ||
this.stat = data[0]; | ||
}); | ||
} | ||
fetchInfo() { | ||
this.isLoading = true; | ||
axiosInstance | ||
.get<Partner>(`/admin/partner/${this.partnerId}`) | ||
.then(({ data }) => { | ||
this.info = { | ||
publicKey: data.publicKey, | ||
newPassword: "", | ||
}; | ||
}) | ||
.catch((error) => { | ||
this.$notify({ | ||
title: "Error", | ||
type: "error", | ||
message: error + "", | ||
}); | ||
}) | ||
.finally(() => { | ||
this.isLoading = false; | ||
this.isLoaded = true; | ||
}); | ||
} | ||
mounted() { | ||
this.localVisible = true; | ||
this.fetchInfo(); | ||
this.fetchTransaction(); | ||
} | ||
} | ||
</script> | ||
|
||
<style lang="scss"></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<template> | ||
<div class="partner-management"> | ||
<el-table v-loading="isLoading" stripe border fit :data="partners"> | ||
<el-table-column label="id" prop="id" /> | ||
<el-table-column label="type" prop="type" /> | ||
<el-table-column label="actions" align="right"> | ||
<template slot-scope="{ row }"> | ||
<el-button type="link" @click="() => showDetail(row)" | ||
>Details</el-button | ||
> | ||
</template> | ||
</el-table-column> | ||
</el-table> | ||
<router-view /> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { Component, Vue } from "vue-property-decorator"; | ||
import { axiosInstance } from "@/utils/axios"; | ||
@Component({ | ||
name: "admin-partner-management", | ||
}) | ||
export default class AdminPartnerManagement extends Vue { | ||
partners: Partner[] = []; | ||
isLoading = false; | ||
async fetch() { | ||
this.isLoading = true; | ||
try { | ||
const { data } = await axiosInstance.get<Partner[]>( | ||
"/admin/partner", | ||
); | ||
this.partners = data; | ||
} catch (e) { | ||
this.$notify({ | ||
type: "error", | ||
title: "Error", | ||
message: e?.response?.data?.message || e + "", | ||
}); | ||
} finally { | ||
this.isLoading = false; | ||
} | ||
} | ||
showDetail(row: Partner) { | ||
this.$router.push({ | ||
name: "partner-detail", | ||
params: { | ||
id: row.id, | ||
}, | ||
}); | ||
} | ||
mounted() { | ||
this.fetch(); | ||
} | ||
} | ||
</script> | ||
|
||
<style lang="scss"></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,6 @@ import { | |
Icon, | ||
Input, | ||
InputNumber, | ||
Message, | ||
Option, | ||
Popconfirm, | ||
Select, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
declare interface Partner { | ||
id: string; | ||
publicKey: string; | ||
} | ||
|
||
declare interface PartnerTransLog { | ||
id: string; | ||
client: Partner; | ||
transaction: Transaction; | ||
createdAt: Date; | ||
updatedAt: Date; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,6 +100,7 @@ | |
}, | ||
"lint-staged": { | ||
"*.{js,ts}": [ | ||
"yarn format", | ||
"yarn lint" | ||
] | ||
} | ||
|
Oops, something went wrong.
a0399f6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to following URLs: