From 4f68a15c04392ca9d1195be60cdbf33e88e7c450 Mon Sep 17 00:00:00 2001 From: Barry Gitarts Date: Fri, 18 Jan 2019 16:14:33 -0500 Subject: [PATCH] add markAsCanceled method to profiles class remove mark state as updated method --- app/components/FunderProfilesTable.jsx | 9 +++++---- app/components/FundsManagement.jsx | 4 ++-- app/model/profiles.js | 8 +++++++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/app/components/FunderProfilesTable.jsx b/app/components/FunderProfilesTable.jsx index 5b958b6..d5950f0 100644 --- a/app/components/FunderProfilesTable.jsx +++ b/app/components/FunderProfilesTable.jsx @@ -14,7 +14,7 @@ const formatField = field => ({ commitTime: convertToHours(field.commitTime), canceled: cancelText(field.canceled) }) -const FunderProfilesTable = ({ cancelFundProfile, profiles }) => ( +const FunderProfilesTable = ({ profiles }) => ( {({ account }) => @@ -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)) diff --git a/app/components/FundsManagement.jsx b/app/components/FundsManagement.jsx index 9b7a069..bd4a44c 100644 --- a/app/components/FundsManagement.jsx +++ b/app/components/FundsManagement.jsx @@ -12,10 +12,10 @@ const FundsManagement = ({ open }) => { const WebkitTransition = 'all 0.25s ease-out 0s' return ( - {({ allPledges, appendPledges, appendFundProfile, transferPledgeAmounts, fundProfiles, cancelFundProfile }) => + {({ allPledges, appendPledges, appendFundProfile, transferPledgeAmounts, fundProfiles }) =>
- + diff --git a/app/model/profiles.js b/app/model/profiles.js index 58c1324..555efbb 100644 --- a/app/model/profiles.js +++ b/app/model/profiles.js @@ -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 + }) + } }