+ {free ? (
+ <>
+
+ Thank you for getting your first JamTrack
+ {jamtrack && (
+ <>
+ "{jamtrack.name}" free! Click the button below to start playing with your JamTrack in your
+ browser.
+ >
+ )}
+
+ {jamtrack && (
+
+ {t('open_jamtrack')}
+
+ )}
+ >
+ ) : (
+ <>
+
+ Thank you for your order! We'll send you an order confirmation email shortly.
+
+ Click the button below to start using your new JamTracks.
+
+
+
+ {t('my_jamtracks')}
+
+
+ >
+ )}
-export default JKCheckoutSuccess
\ No newline at end of file
+
+
+
+ );
+};
+
+export default JKCheckoutSuccess;
diff --git a/jam-ui/src/hooks/useShoppingCart.js b/jam-ui/src/hooks/useShoppingCart.js
index 0b190fc10..3e09b8a16 100644
--- a/jam-ui/src/hooks/useShoppingCart.js
+++ b/jam-ui/src/hooks/useShoppingCart.js
@@ -38,7 +38,7 @@ export const useShoppingCart = () => {
const resp = await addJamtrackToShoppingCart(options);
const data = await resp.json();
setShoppingCart([...shoppingCart, data]);
- return true;
+ return data;
} catch (error) {
console.log(error);
return false;
@@ -55,9 +55,13 @@ export const useShoppingCart = () => {
return false;
}
- }
+ }
+
+ const hasOnlyFreeItemsInShoppingCart = () => {
+ return shoppingCart.length === 0 || shoppingCart.every(item => item.product_info.free);
+ }
return{
- shoppingCart, error, loading, removeCartItem, addCartItem, cartTotal
+ shoppingCart, error, loading, removeCartItem, addCartItem, cartTotal, hasOnlyFreeItemsInShoppingCart
}
}
\ No newline at end of file
diff --git a/jam-ui/src/i18n/locales/en/checkout_success.json b/jam-ui/src/i18n/locales/en/checkout_success.json
index 44f1accbf..a68085710 100644
--- a/jam-ui/src/i18n/locales/en/checkout_success.json
+++ b/jam-ui/src/i18n/locales/en/checkout_success.json
@@ -1,4 +1,5 @@
{
"page_title": "Thank You!",
- "my_jamtracks": "My JamTracks"
+ "my_jamtracks": "My JamTracks",
+ "open_jamtrack": "Open JamTrack"
}
\ No newline at end of file
diff --git a/web/app/views/api_jam_tracks/show_for_client.rabl b/web/app/views/api_jam_tracks/show_for_client.rabl
index 9a528e03e..76a986d31 100644
--- a/web/app/views/api_jam_tracks/show_for_client.rabl
+++ b/web/app/views/api_jam_tracks/show_for_client.rabl
@@ -29,12 +29,14 @@ child(:jam_track_tracks => :tracks) {
node do |jam_track|
right = jam_track.right_for_user(current_user)
- {
- jam_track_right_id: right.id,
- purchased_at: right.created_at.to_i,
- last_mixdown_id: right.last_mixdown_id,
- last_stem_id: right.last_stem_id
- }
+ if right
+ {
+ jam_track_right_id: right.id,
+ purchased_at: right.created_at.to_i,
+ last_mixdown_id: right.last_mixdown_id,
+ last_stem_id: right.last_stem_id
+ }
+ end
end
node :mixdowns do |jam_track|