This repository has been archived by the owner on Mar 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 187
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 #529 from OpenBazaar/order-details-dispute
Order details dispute
- Loading branch information
Showing
54 changed files
with
2,034 additions
and
360 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
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
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,26 @@ | ||
import app from '../../app'; | ||
import BaseModel from '../BaseModel'; | ||
|
||
export default class extends BaseModel { | ||
defaults() { | ||
return { | ||
claim: '', | ||
}; | ||
} | ||
|
||
url() { | ||
return app.getServerUrl('ob/opendispute/'); | ||
} | ||
|
||
get idAttribute() { | ||
return 'orderId'; | ||
} | ||
|
||
sync(method, model, options) { | ||
if (method === 'create' || method === 'update') { | ||
options.type = 'POST'; | ||
} | ||
|
||
return super.sync(method, model, options); | ||
} | ||
} |
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,83 @@ | ||
import app from '../../app'; | ||
import BaseModel from '../BaseModel'; | ||
|
||
export default class extends BaseModel { | ||
defaults() { | ||
return { | ||
resolution: '', | ||
}; | ||
} | ||
|
||
url() { | ||
return app.getServerUrl('ob/closedispute/'); | ||
} | ||
|
||
get idAttribute() { | ||
return 'orderId'; | ||
} | ||
|
||
validate(attrs) { | ||
const errObj = {}; | ||
|
||
const addError = (fieldName, error) => { | ||
errObj[fieldName] = errObj[fieldName] || []; | ||
errObj[fieldName].push(error); | ||
}; | ||
|
||
let vendorPercentageOk = false; | ||
let buyerPercentageOk = false; | ||
|
||
if (typeof attrs.vendorPercentage === 'undefined' || attrs.vendorPercentage === '') { | ||
addError('vendorPercentage', | ||
app.polyglot.t('resolveDisputeModelErrors.provideAmount')); | ||
} else if (typeof attrs.vendorPercentage !== 'number') { | ||
addError('vendorPercentage', | ||
app.polyglot.t('resolveDisputeModelErrors.providePercentageAsNumber')); | ||
} else if (attrs.vendorPercentage < 0 || attrs.vendorPercentage > 100) { | ||
addError('vendorPercentage', | ||
app.polyglot.t('resolveDisputeModelErrors.vendorPercentageOutOfRange')); | ||
} else { | ||
vendorPercentageOk = true; | ||
} | ||
|
||
if (typeof attrs.buyerPercentage === 'undefined' || attrs.buyerPercentage === '') { | ||
addError('buyerPercentage', | ||
app.polyglot.t('resolveDisputeModelErrors.provideAmount')); | ||
} else if (typeof attrs.buyerPercentage !== 'number') { | ||
addError('buyerPercentage', | ||
app.polyglot.t('resolveDisputeModelErrors.providePercentageAsNumber')); | ||
} else if (attrs.buyerPercentage < 0 || attrs.buyerPercentage > 100) { | ||
addError('buyerPercentage', | ||
app.polyglot.t('resolveDisputeModelErrors.buyerPercentageOutOfRange')); | ||
} else { | ||
buyerPercentageOk = true; | ||
} | ||
|
||
if (vendorPercentageOk && buyerPercentageOk) { | ||
if (attrs.buyerPercentage + attrs.vendorPercentage > 100) { | ||
addError('buyerPercentage', | ||
app.polyglot.t('resolveDisputeModelErrors.totalPercentageOutOfRange')); | ||
} else if (attrs.buyerPercentage + attrs.vendorPercentage < 100) { | ||
addError('buyerPercentage', | ||
app.polyglot.t('resolveDisputeModelErrors.totalPercentageTooLow')); | ||
} | ||
} | ||
|
||
if (!attrs.resolution) { | ||
addError('resolution', | ||
app.polyglot.t('resolveDisputeModelErrors.provideResolution')); | ||
} | ||
|
||
if (Object.keys(errObj).length) return errObj; | ||
|
||
return undefined; | ||
} | ||
|
||
sync(method, model, options) { | ||
if (method === 'create' || method === 'update') { | ||
options.type = 'POST'; | ||
} | ||
|
||
return super.sync(method, model, options); | ||
} | ||
} |
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,6 @@ | ||
<% if (ob.showDisputeOrderButton) { %> | ||
<%= ob.processingButton({ | ||
className: 'flex btn clrErr clrBrDec1 clrTOnEmph js-openDispute', | ||
btnText: ob.polyT('orderDetail.actionBar.disputeOrderBtn'), | ||
}) %> | ||
<% } %> |
Oops, something went wrong.