#include "..\script_component.hpp"

/*
 * Author: IDSolutions
 * Adds a new member to an organization if added by the owner
 *
 * Arguments:
 * 0: Player UID <STRING> - Unique identifier of the player to add
 * 1: Player Name <STRING> - Display name of the player to add
 *
 * Return Value:
 * Success <BOOLEAN> - True if member was added successfully, false otherwise
 *
 * Example:
 * ["76561198012345678", "John Doe"] call forge_client_org_fnc_addMember
 *
 * Public: Yes
 */

params [["_uid", "", [""]], ["_name", "", [""]]];

// Validate input parameters
if (_uid == "" || _name == "") exitWith { 
    ["Invalid parameters for organization invitation", "error", 5, "right"] call forge_client_misc_fnc_notify;
    false 
};

// Get the organization store interface
private _store = call FUNC(verifyOrgStore);

// Add the member to the organization
// This will validate ownership permissions and handle database updates
private _result = _store call ["addMember", [_uid, _name]];

// Provide feedback based on success or failure
if (_result) then {
    [format ["%1 added to organization", _name], "success", 5, "right"] call forge_client_misc_fnc_notify;
} else {
    ["Failed to add member to organization", "error", 5, "right"] call forge_client_misc_fnc_notify;
};

// Return the result for further operations
_result