package Daje::Controller::Companies::CompaniesSignup;
use Mojo::Base 'Mojolicious::Controller', -base, -signatures;
use v5.42;

# NAME
# ====
#
# Daje::Controller::Companies::CompaniesSignup; - Controller class for signing new customers
#
# SYNOPSIS
# ========
#
#       use Daje::Controller::Companies::CompaniesSignup;
#
# DESCRIPTION
# ===========
#
# Daje::Controller::Companies::CompaniesSignup; is a new company controller
#
# METHODS
# =======
#
#
# LICENSE
# =======
#
# Copyright (C) janeskil1525.
#
# This library is free software; you can redistribute it and/or modify
# it under the same terms as Perl itself.
#
# AUTHOR
# ======
#
# janeskil1525 E<lt>janeskil1525@gmail.com
#
# This file is generated automatically by Daje Tools 2026-02-02 15:02:14.
# It will be re-generated by Daje Tools again.
# <!-- Autogenerated file 2026-02-02 15:02:14 -->

use Data::Dumper;
use Mojo::JSON qw {decode_json};

sub signup($self) {

    $self->app->log->debug('Daje::Controller::Companies::CompaniesSignup:signup '  . Dumper($self->req->body));
    my $data->{context} = decode_json( $self->req->body );
    try {
        $self->workflow_engine->workflow_pkey(0);
        $self->workflow_engine->workflow_name('companies_companies');
        $self->workflow_engine->context($data);
        $self->workflow_engine->process('save_new_companies_companies');
        if($self->workflow_engine->error->has_error() == 0) {
            $self->render(json => {result => 1, data => 'OK'});
        } else {
            $self->app->log->error('Daje::Controller::Companies::CompaniesSignup::signup ' . $self->workflow_engine->error->error());
            $self->render(json =>
                {result => 0, data => $self->workflow_engine->error->error()}
            );
        }
    } catch ($e) {
        $self->app->log->error('Daje::Controller::Companies::CompaniesSignup::signup ' . $e);
        $self->render(json => {result => 0, data => $e});
    };
    $self->app->log->debug('Daje::Controller::Companies::CompaniesSignup::signup ends');
}
1;