-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add referrals page if the refer gem is enabled (#1162)
* Add referrals page if the refer gem is enabled * Use refer 0.5+ * Standardize * Disable autocomplete on referral url input
- Loading branch information
Showing
8 changed files
with
78 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 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,7 @@ | ||
class Users::ReferralsController < ApplicationController | ||
before_action :authenticate_user! | ||
|
||
def index | ||
@referral_code = current_user.referral_codes.first_or_create | ||
end | ||
end |
This file contains 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 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 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,44 @@ | ||
<div class="flex flex-wrap my-4 lg:px-4"> | ||
<div class="w-full mb-4 lg:w-1/4 lg:p-4"> | ||
<%= render partial: "account_navbar" %> | ||
</div> | ||
|
||
<div class="w-full lg:w-3/4 lg:p-4"> | ||
<div class="p-4 bg-white border border-gray-200 dark:bg-gray-900 dark:border-gray-800 rounded-lg lg:p-10"> | ||
|
||
<div class="sm:flex items-center justify-between mb-3"> | ||
<h1 class="flex-1 h3"><%= t(".title") %></h1> | ||
</div> | ||
|
||
<p><%= t(".instructions") %></p> | ||
<div class="mt-2 flex items-center gap-1"> | ||
<%= text_field_tag nil, root_url(Refer.param_name => @referral_code.code), readonly: true, class: "form-control w-96", autocomplete: :off %> | ||
<%= button_tag "Copy", class: "btn btn-secondary", data: {controller: :clipboard, clipboard_text: root_url(Refer.param_name => @referral_code.code) } %> | ||
</div> | ||
|
||
<div class="mt-8 lg:max-w-4xl"> | ||
<h4><%= t(".stats") %></h4> | ||
|
||
<table class="w-full"> | ||
<tbody class="divide-y divide-gray-100"> | ||
<tr> | ||
<td class="font-bold"><%= t(".clicks") %></td> | ||
<td><%= t(".clicks_description") %></td> | ||
<td class="py-2 text-right tabular-nums"><%= @referral_code.visits_count %></td> | ||
</tr> | ||
<tr> | ||
<td class="font-bold"><%= t(".referrals") %></td> | ||
<td><%= t(".referrals_description") %></td> | ||
<td class="py-2 text-right tabular-nums"><%= @referral_code.referrals.count %></td> | ||
</tr> | ||
<tr> | ||
<td class="font-bold"><%= t(".completed") %></td> | ||
<td><%= t(".completed_description") %></td> | ||
<td class="py-2 text-right tabular-nums"><%= @referral_code.referrals.completed.count %></td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
This file contains 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 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 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 |
---|---|---|
|
@@ -30,4 +30,6 @@ | |
end | ||
end | ||
|
||
resources :referrals, module: :users if defined? Refer | ||
|
||
post :sudo, to: "users/sudo#create" |