add markAsCanceled method to profiles class

remove mark state as updated method
This commit is contained in:
Barry Gitarts 2019-01-18 16:14:33 -05:00
parent 5cc4947399
commit 4f68a15c04
3 changed files with 14 additions and 7 deletions

View File

@ -14,7 +14,7 @@ const formatField = field => ({
commitTime: convertToHours(field.commitTime),
canceled: cancelText(field.canceled)
})
const FunderProfilesTable = ({ cancelFundProfile, profiles }) => (
const FunderProfilesTable = ({ profiles }) => (
<FundingContext.Consumer>
{({ account }) =>
<Fragment>
@ -39,9 +39,10 @@ const FunderProfilesTable = ({ cancelFundProfile, profiles }) => (
onClick: (event, rowData) => {
cancelProject(rowData.idProject || rowData.idProfile)
.send()
.then(res => {
.then(async res => {
console.log({res})
cancelFundProfile(rowData.idProfile)
const profile = profiles.find(p => p.idProfile == rowData.idProfile)
await profile.markAsCanceled()
})
}
})
@ -53,5 +54,5 @@ const FunderProfilesTable = ({ cancelFundProfile, profiles }) => (
)
export default withDatabase(withObservables([], ({ database }) => ({
profiles: database.collections.get('profiles').query().observe(),
profiles: database.collections.get('profiles').query().observeWithColumns(['canceled']),
}))(FunderProfilesTable))

View File

@ -12,10 +12,10 @@ const FundsManagement = ({ open }) => {
const WebkitTransition = 'all 0.25s ease-out 0s'
return (
<FundingContext.Consumer>
{({ allPledges, appendPledges, appendFundProfile, transferPledgeAmounts, fundProfiles, cancelFundProfile }) =>
{({ allPledges, appendPledges, appendFundProfile, transferPledgeAmounts, fundProfiles }) =>
<div style={{ maxWidth, WebkitTransition }}>
<PledgesTable data={allPledges} transferPledgeAmounts={transferPledgeAmounts} fundProfiles={fundProfiles} />
<FunderProfilesTable cancelFundProfile={cancelFundProfile}/>
<FunderProfilesTable />
<AddFunder appendFundProfile={appendFundProfile} />
<Divider variant="middle" />
<CreateFunding refreshTable={appendPledges} />

View File

@ -1,4 +1,4 @@
import { field } from '@nozbe/watermelondb/decorators'
import { action, field } from '@nozbe/watermelondb/decorators'
import { LiquidModel } from '../utils/models'
@ -12,4 +12,10 @@ export default class Profiles extends LiquidModel {
@field('name') name
@field('url') url
@field('id_profile') idProfile
@action async markAsCanceled() {
await this.update(profile => {
profile.canceled = true
})
}
}