56 lines
1.6 KiB
JavaScript
56 lines
1.6 KiB
JavaScript
import { generateNewIdAsync } from "oak-domain/lib/utils/uuid";
|
|
export default OakComponent({
|
|
entity: 'account',
|
|
isList: false,
|
|
projection: {
|
|
id: 1,
|
|
total: 1,
|
|
avail: 1,
|
|
systemId: 1,
|
|
entity: 1,
|
|
entityId: 1,
|
|
},
|
|
properties: {
|
|
depositMax: 10000,
|
|
onDeposit: (payId) => undefined,
|
|
},
|
|
formData({ data }) {
|
|
return {
|
|
account: data,
|
|
};
|
|
},
|
|
actions: ['deposit', 'withdraw'],
|
|
methods: {
|
|
async deposit(price, channel, meta, success) {
|
|
const payId = await generateNewIdAsync();
|
|
const { onDeposit, oakId } = this.props;
|
|
await this.execute(undefined, undefined, undefined, [
|
|
{
|
|
entity: 'account',
|
|
operation: {
|
|
id: await generateNewIdAsync(),
|
|
action: 'deposit',
|
|
data: {
|
|
pay$account: {
|
|
id: await generateNewIdAsync(),
|
|
action: 'create',
|
|
data: {
|
|
id: payId,
|
|
channel,
|
|
price,
|
|
meta,
|
|
},
|
|
},
|
|
},
|
|
filter: {
|
|
id: oakId,
|
|
}
|
|
},
|
|
}
|
|
]);
|
|
success();
|
|
onDeposit && onDeposit(payId);
|
|
}
|
|
}
|
|
});
|