FIX_ISSUE
This commit is contained in:
parent
cfddad8485
commit
6a1e3519d2
@ -5501,9 +5501,15 @@ class EmployeeRestController extends AdminController
|
||||
// 🔐 Move this to .env in real projects
|
||||
$METABASE_SECRET_KEY = getenv('METABASE_SECRET_KEY');
|
||||
|
||||
$is_tpa_dashboard_enable = $this->clientPolicyModel
|
||||
->select('tpa.dashboard_id')
|
||||
->join('tpa', 'client_policy.tpa_id = tpa.id')
|
||||
->where('client_policy.id', $received_data['client_policy_id'])
|
||||
->where('tpa.dashboard_id IS NOT NULL')
|
||||
->first();
|
||||
|
||||
$payload = [
|
||||
'resource' => [
|
||||
// 'dashboard' => 1
|
||||
'dashboard' => 2
|
||||
],
|
||||
'params' => (object)['client_policy' => $received_data['client_policy_id']], // MUST be object for Metabase
|
||||
@ -5523,8 +5529,10 @@ class EmployeeRestController extends AdminController
|
||||
'status' => 'success',
|
||||
'message' => 'Form data received successfully!',
|
||||
'data' => [
|
||||
'metabaseToken' => $token,
|
||||
'metabaseUrl' => 'https://nsights.nhanceindia.in']
|
||||
'metabaseToken' => $token,
|
||||
'metabaseUrl' => 'https://nsights.nhanceindia.in'
|
||||
],
|
||||
'is_tpa_dashboard_enable' => !empty($is_tpa_dashboard_enable ?? []),
|
||||
]);
|
||||
// }
|
||||
|
||||
@ -5534,12 +5542,27 @@ class EmployeeRestController extends AdminController
|
||||
]);
|
||||
}
|
||||
|
||||
public function getHrTpaDashboard()
|
||||
public function getHrTpaDashboard($client_policy_id = null, $return_type = 'api')
|
||||
{
|
||||
$METABASE_SECRET_KEY = getenv('METABASE_SECRET_KEY');
|
||||
$received_data = $this->request->getJSON(true) ?? null;
|
||||
|
||||
$policy_id = $received_data['client_policy_id'] ?? 4687;
|
||||
if ($return_type === 'api') {
|
||||
|
||||
$received_data = $this->request->getJSON(true) ?? [];
|
||||
$policy_id = $received_data['client_policy_id'] ?? null;
|
||||
|
||||
} else {
|
||||
// Internal call
|
||||
$policy_id = $client_policy_id;
|
||||
}
|
||||
|
||||
if (empty($policy_id)) {
|
||||
return $this->respond([
|
||||
'status' => 'failed',
|
||||
'message' => 'Client Policy ID is required.',
|
||||
'data' => []
|
||||
]);
|
||||
}
|
||||
|
||||
$client_policy_data = $this->clientPolicyModel
|
||||
->select('tpa.dashboard_id')
|
||||
@ -5561,15 +5584,24 @@ class EmployeeRestController extends AdminController
|
||||
'resource' => [
|
||||
'dashboard' => $database_id
|
||||
],
|
||||
'exp' => time() + (10 * 60), // 10 minutes
|
||||
'exp' => time() + (10 * 60),
|
||||
'params' => (object)[]
|
||||
];
|
||||
|
||||
$token = JWT::encode($payload, $METABASE_SECRET_KEY, 'HS256');
|
||||
|
||||
if ($return_type === 'internal') {
|
||||
|
||||
// Return raw data for internal usage
|
||||
return [
|
||||
'metabaseToken' => $token,
|
||||
'metabaseUrl' => 'https://nsights.nhanceindia.in'
|
||||
];
|
||||
}
|
||||
|
||||
return $this->respond([
|
||||
'status' => 'success',
|
||||
'message' => 'Form data received successfully!',
|
||||
'message' => 'Dashboard fetched successfully.',
|
||||
'data' => [
|
||||
'metabaseToken' => $token,
|
||||
'metabaseUrl' => 'https://nsights.nhanceindia.in'
|
||||
|
||||
Loading…
Reference in New Issue
Block a user