<commit_before>/**
    ViewBooking activity
    
    It manages links to booking card given at emails.
    Because the app has different URLs for client and professional profiles,
    and sometimes the same URL needs to be provided, this behaves as the common URL
    for both that redirects to any specific depending on the booking data.
**/
'use strict';

var Activity = require('../components/Activity');

var A = Activity.extend(function ViewBookingActivity() {
    
    Activity.apply(this, arguments);

    this.accessLevel = this.app.UserType.loggedUser;
});

exports.init = A.init;

A.prototype.show = function show(state) {
    Activity.prototype.show.call(this, state);
    
    var bookingID = state && state.route.segments && state.route.segments[0];
    var currentUserID = this.app.model.userProfile.data.userID();
    this.app.model.bookings.getBooking(bookingID)
    .then(function(booking) {
        if (booking.serviceProfessionalUserID === currentUserID) {
            this.app.shell.go('/appointment/' + booking.serviceDateID);
        }
        else {
            this.app.shell.go('/clientAppointment/' + bookingID);
        }
    }.bind(this));
};
<commit_msg>Fixed erro at viewBooking not redirecting properly to professional appointment #1002<commit_after>/**
    ViewBooking activity
    
    It manages links to booking card given at emails.
    Because the app has different URLs for client and professional profiles,
    and sometimes the same URL needs to be provided, this behaves as the common URL
    for both that redirects to any specific depending on the booking data.
**/
'use strict';

var Activity = require('../components/Activity');

var A = Activity.extend(function ViewBookingActivity() {
    
    Activity.apply(this, arguments);

    this.accessLevel = this.app.UserType.loggedUser;
});

exports.init = A.init;

A.prototype.show = function show(state) {
    Activity.prototype.show.call(this, state);
    
    var bookingID = state && state.route.segments && state.route.segments[0];
    var currentUserID = this.app.model.userProfile.data.userID();
    this.app.model.bookings.getBooking(bookingID)
    .then(function(booking) {
        if (booking.serviceProfessionalUserID() === currentUserID) {
            this.app.shell.go('/appointment/' + booking.serviceDateID());
        }
        else {
            this.app.shell.go('/clientAppointment/' + bookingID);
        }
    }.bind(this));
};

{'fraction_non_alphanumeric': 0.1134780827529701, 'fraction_numerical': 0.0024580090126997134, 'mean_word_length': 3.174358974358974, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1674720', 'n_tokens_mistral': 706, 'n_tokens_neox': 688, 'n_words': 188}