%#
%# $Id$
%#
% layout 'default';
% title 'Maacom';

% use Mojo::Util qw(dumper);

% my $u = $c->app->user;

% my $new_name = $c->req->param('alias_name');
% my $alias_id = $c->req->param('alias_id') || 0;
% my $profile = $u->alias_profile($alias_id);

% if ($profile) {
    % my $domain_id = $profile->{domain_id};
    % my $address = $profile->{address};

    % my $cid = $u->alias_exist($new_name, $domain_id);
    % if ($cid) {
        <div class="callout warning">Alias with <%= $address %> already exists</div>
    % }

    % unless ($cid) {
        % my $res = $u->alias_update($alias_id, name => $new_name);
        % if ($res) {
            <div class="callout success">Alias <%= $address %> has been updated.</div>
        % }

        % unless ($res) {
            <div class="callout alert">Alias <%= $address %> was not updated.</div>
        % }
    % }
    <a class="float-left button tiny" href="/alias/list?domain_id=<%= $domain_id %>">
        <i class="fi-arrow-left"></i>
    </a>
% }

% unless ($profile) {
    <div class="callout warning">Alias with id <%= $alias_id %> not exist</div>
    <a class="float-left button tiny" href="/alias/list">
        <i class="fi-arrow-left"></i>
    </a>
% }
%#EOF




