-
Notifications
You must be signed in to change notification settings - Fork 4
Feature/create supplier profile #142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4b1dbe8
copied group profile tasks as basic supply tasks
b1871fd
towards adding supplier profile create hooks on orders
f060bf6
migration for order agent type ids
9b3ee10
supplier agent type is created before order, supplierAgentId is added…
cb57e7e
updated agentId to consumerAgentId hook data
d18e8a3
passed child params to define whether profile is group or supplier agent
b70f827
relationship recorded gets created after group and supplier agents ha…
061f0af
break out contextAgent into consumer and supplierAgent across the app
iainkirkpatrick 754ebb0
fix childtaskPlan params assignment
iainkirkpatrick File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
13 changes: 13 additions & 0 deletions
13
db/migrations/20170818142530_add-agent-type-ids-to-orders.js
This file contains hidden or 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,13 @@ | ||
| exports.up = function(knex, Promise) { | ||
| return knex.schema.table('orders', function(table){ | ||
| table.renameColumn('agentId', 'consumerAgentId') | ||
| table.integer('supplierAgentId').references('agents.id') | ||
| }) | ||
| }; | ||
|
|
||
| exports.down = function(knex, Promise) { | ||
| return knex.schema.table('orders', function(table){ | ||
| table.renameColumn('consumerAgentId', 'agentId') | ||
| table.dropColumn('supplierAgentId') | ||
| }) | ||
| }; | ||
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,6 +1,31 @@ | ||
| import React from 'react' | ||
| import h from 'react-hyperscript' | ||
| import { isNil, merge, isEmpty } from 'ramda' | ||
|
|
||
| import TaskStepper from './TaskStepper' | ||
| import Profile from '../../agents/components/Profile' | ||
| import MemberInvites from '../../agents/components/MemberInvites' | ||
|
|
||
| export default (props) => { | ||
| const { taskPlan } = props | ||
| return <div>Setup supplier yo!</div> | ||
| const { taskPlan, actions } = props | ||
| if (isNil(taskPlan)) return null | ||
| const { params: { supplierAgent } } = taskPlan | ||
| if (isNil(supplierAgent)) return null | ||
|
|
||
| const { profile, members } = supplierAgent | ||
|
|
||
| const steps = [ | ||
| { | ||
| id: 'tasks.steps.supplierProfile', | ||
| content: h(Profile, { | ||
| initialValues: profile, | ||
| updateProfile: (nextProfile) => { | ||
| actions.profiles.update(profile.id, merge(nextProfile, { agentId: supplierAgent.id })) | ||
| } | ||
| }) | ||
| }, | ||
| ] | ||
|
|
||
| return h(TaskStepper, { | ||
| steps | ||
| }) | ||
| } |
This file contains hidden or 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 hidden or 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,60 @@ | ||
| import { isNil, path, prop, pipe, values, any, forEach, either } from 'ramda' | ||
| import { connect as connectFeathers } from 'feathers-action-react' | ||
| import { compose } from 'recompose' | ||
|
|
||
| import { agents, profiles, relationships, credentials } from 'dogstack-agents/actions' | ||
| import getSetupGroupTaskProps from '../getters/getSetupGroupTaskProps' | ||
| import SetupSupplierTask from '../components/SetupSupplierTask' | ||
|
|
||
| const getSupplierAgentFromTaskPlan = path(['params', 'supplierAgent']) | ||
|
|
||
| export default compose( | ||
| connectFeathers({ | ||
| selector: getSetupGroupTaskProps, | ||
| actions: { | ||
| agents, | ||
| profiles, | ||
| relationships, | ||
| credentials | ||
| }, | ||
| // TODO can optimize `feathers-action-react` to de-dupe | ||
| // new queries by checking if deepEqual | ||
| query: (props) => { | ||
| var queries = [] | ||
| // once we have the task plan, query for the supplier agent | ||
| const { taskPlan } = props | ||
|
|
||
| if (taskPlan) { | ||
| const { params: { supplierAgentId } } = taskPlan | ||
| queries.push({ | ||
| service: 'agents', | ||
| id: supplierAgentId | ||
| }) | ||
| queries.push({ | ||
| service: 'profiles', | ||
| params: { | ||
| query: { | ||
| agentId: supplierAgentId | ||
| } | ||
| } | ||
| }) | ||
| } | ||
|
|
||
| return queries | ||
| }, | ||
| shouldQueryAgain: (props, status) => { | ||
| if (status.isPending) return false | ||
|
|
||
| const { taskPlan } = props.ownProps | ||
|
|
||
| // wait for task plan before re-query | ||
| if (isNil(taskPlan)) return false | ||
|
|
||
| // re-query when we haven't gotten back supplierAgent or taskWork | ||
| const supplierAgent = getSupplierAgentFromTaskPlan(taskPlan) | ||
| if (isNil(supplierAgent)) return true | ||
|
|
||
| return false | ||
| } | ||
| }) | ||
| )(SetupSupplierTask) |
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
nice