package my.modules.web.user.controller;

import my.modules.web.user.model.Account;
import my.modules.web.user.model.PasswordChange;
import my.modules.web.user.model.PasswordReset;
import my.modules.web.user.model.ProfileChange;
import org.springframework.ui.ModelMap;
import org.springframework.validation.BindingResult;

/**
 * This interface allocates the view controller definitions.
 *
 * @author Kai Paroth
 */
public interface UserViewController extends UserController {
    /**
     * The home URI.
     */
    String URI_HOME = "/";

    /**
     * The list accounts URI.
     */
    String URI_LIST_ACCOUNTS = URI_ADMIN + "/listAccounts";

    /**
     * The password change URI.
     */
    String URI_PASSWORD_CHANGE = URI_USER + "/changePassword";

    /**
     * The profile change URI.
     */
    String URI_PROFILE_CHANGE = URI_USER + "/changeProfile";

    /**
     * The reset password URI.
     */
    String URI_RESET_PASSWORD = URI_USER + "/resetPassword";

    /**
     * Shows the home view.
     *
     * @return the view name.
     */
    String home();

    /**
     * Populates the authenticated account model.
     *
     * @return the instance or <code>null</code>.
     */
    Account populateAccount();

    /**
     * Returns a list of accounts.
     *
     * @param page  the page number.
     * @param size  the max entries to list.
     * @param model the view model.
     * @return the view name.
     */
    String listAccounts(int page, int size, ModelMap model);

    /**
     * Shows the password change view.
     *
     * @param model the view model.
     * @return the view name.
     */
    String changePassword(ModelMap model);

    /**
     * Changes the password.
     *
     * @param form   the password change form.
     * @param result the {@link BindingResult} to handle validation errors.
     * @return the view name.
     */
    String changePassword(PasswordChange form, BindingResult result);

    /**
     * Shows the profile change view.
     *
     * @param model the view model.
     * @return the view name.
     */
    String changeProfile(ModelMap model);

    /**
     * Changes the profile.
     *
     * @param form   the profile change form.
     * @param result the {@link BindingResult} to handle validation errors.
     * @return the view name.
     */
    String changeProfile(ProfileChange form, BindingResult result);

    /**
     * Shows the reset password view.
     *
     * @param model the view model.
     * @return the view name.
     */
    String resetPassword(ModelMap model);

    /**
     * Resets the password.
     *
     * @param form   the reset password form.
     * @param result the {@link BindingResult} to handle validation errors.
     * @return the view name.
     */
    String resetPassword(PasswordReset form, BindingResult result);
}
