 FlashMessage::template = -> "<span>#{@message}</span>"
 InquiryQuestionnaireView = require './view.coffee'
 analytics = require './analytics.coffee'
+
+closeWithError = (modal) ->
+  modal.close ->
+    new FlashMessage
+      message: 'There has been an error. Click here to contact support@artsy.net'
+      href: 'mailto:support@artsy.net'
+      autoclose: false
+
+closeWithSuccess = (modal) ->
+  modal.close ->
+    new FlashMessage message: '
+      Your inquiry has been sent.<br>
+      Thank you for completing your profile.
+    '
 
 module.exports = (options = {}) ->
   { user, inquiry } = options

        user.related().collectorProfile.findOrCreate()
      .then done
      .fail ->
        modal.close ->
          new FlashMessage
            message: 'There has been an error. Click here to contact support@artsy.net'
            href: 'mailto:support@artsy.net'
            autoclose: false
      .done()

  # Abort by clicking 'nevermind'

  # End of complete flow
  questionnaire.state.on 'done', ->
    # Send the inquiry
    inquiry.save {},
      error: ->
        closeWithError modal
      success: ->
        closeWithSuccess modal

  modal
