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

% use Mojo::Util qw(dumper);

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

% my $new_name = $c->req->param('domain_name');
% my $domain_id = $c->req->param('domain_id') || 0;
% my $profile = $u->domain_profile($domain_id);

% if ($profile) {
    % my $name = $profile->{name};
    % my $cid = $u->domain_exist($new_name);
    % if ($cid) {
        <div class="callout warning">Domain <%= $new_name %> already exists, domain name <%= $name %> was not changed.</div>
    % }

    % unless ($cid) {
        % my $res = $u->domain_update($domain_id, name => $new_name);
        % if ($res) {
            <div class="callout success">Domain <%= $name %> has been renamed to <%= $new_name %>.</div>
        % }

        % unless ($res) {
            <div class="callout alert">Domain <%= $name %> was not updated.</div>
        % }
    % }
% }

% unless ($profile) {
        <div class="callout warning">Domain with id <%= $domain_id %> not exist</div>
% }

<a class="float-left button tiny" href="/domain/list">
    <i class="fi-arrow-left"></i>
</a>

%#EOF




