@@ -696,25 +696,27 @@ Command.new(
"referral codes",
"👥 Refer a friend for free credit"
) {
- Command.customer.then(&:unused_invites).then do |invites|
+ repo = InvitesRepo.new
+ Command.customer.then { |customer|
+ EMPromise.all([
+ repo.find_or_create_group_code(customer.customer_id),
+ repo.unused_invites(customer.customer_id)
+ ])
+ }.then do |(group_code, invites)|
if invites.empty?
Command.finish(
- "You have no more referral codes right now, " \- "try again later."
+ "This code will provide credit equivalent to one month of service " \
+ "to anyone after they sign up and pay: #{group_code}\n\n" \
+ "You will receive credit equivalent to one month of service once " \
+ "their payment clears."
)
else
Command.finish do |reply|
- reply.form.type = :result- reply.form.title = "Unused Referral Codes"- reply.form.instructions =- "Each of these codes is single use and gives the person using " \- "them a free month of JMP service. You will receive credit " \- "equivalent to one month of free service if they later become " \- "a paying customer."- FormTable.new(- invites.map { |i| [i] },- code: "Invite Code"- ).add_to_form(reply.form)
+ reply.command << FormTemplate.render(
+ "codes",
+ invites: invites,
+ group_code: group_code
+ )
end
end
end