Skip to content

Commit

Permalink
-[x] Sent organization type to activity controller
Browse files Browse the repository at this point in the history
-[x] Created route for completing activity status for onboarding
-[x] Put expects json check for reporting org form
-[x] Added API Calls
-[x] Changed API To receive Data in Body
-[x] Integrated API For All Steps
-[x] Fixed Sizes of Steps
-[x] Showing Toast Message For Errors
-[x] WIP Issues Solving
-[x] Fix Completed State Not Removing
-[x] Redesigned Complete Screens
-[x] Onboarding Completed Sidebar Addition
-[x] Fixed Null Handling
-[x] Changed UI
  • Loading branch information
Sanilblank authored and Yash Maharjan committed Sep 24, 2024
1 parent def259e commit 18779d1
Show file tree
Hide file tree
Showing 35 changed files with 7,910 additions and 614 deletions.
7 changes: 6 additions & 1 deletion app/Http/Controllers/Admin/Activity/ActivityController.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,11 @@ public function index(): View|JsonResponse
// User onboarding part
$organization = Auth::user()->organization;
$organizationOnboarding = $this->organizationOnboardingService->getOrganizationOnboarding($organization->id);
$isFirstTime = false;

if (!$organizationOnboarding) {
$organizationOnboarding = $this->organizationOnboardingService->createOrganizationOnboarding($organization);
$isFirstTime = true;
DB::commit();
}

Expand All @@ -137,6 +139,7 @@ public function index(): View|JsonResponse
$defaultFinanceType = getCodeList('FinanceType', 'Activity', filterDeprecated: true);
$defaultAidType = getCodeList('AidType', 'Activity', filterDeprecated: true);
$defaultTiedStatus = getCodeList('TiedStatus', 'Activity', filterDeprecated: true);
$organizationType = getCodeList('OrganizationType', 'Organization', filterDeprecated: true);

return view(
'admin.activity.index',
Expand All @@ -151,7 +154,9 @@ public function index(): View|JsonResponse
'defaultFlowType',
'defaultFinanceType',
'defaultAidType',
'defaultTiedStatus'
'defaultTiedStatus',
'organizationType',
'isFirstTime',
)
);
} catch (Exception $e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Http\Controllers\Admin\Organization;

use App\Http\Controllers\Controller;
use App\IATI\Models\Organization\OrganizationOnboarding;
use App\IATI\Services\Organization\OrganizationOnboardingService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
Expand All @@ -26,28 +27,48 @@ public function __construct(
* Toggles don't show if required.
*
* @param Request $request
* @param $value
*
* @return JsonResponse
*/
public function toggleDontShow(Request $request, $value): JsonResponse
public function toggleDontShow(Request $request): JsonResponse
{
try {
DB::beginTransaction();

if (!is_bool($value)) {
return response()->json(['success' => false, 'message' => 'Invalid value']);
}
$request->validate([
'value' => 'required|boolean',
]);

$this->organizationOnboardingService->updateDontShowAgain(Auth::user()->organization_id, $value);
$this->organizationOnboardingService->updateDontShowAgain(Auth::user()->organization_id, $request->value);
DB::commit();

return response()->json(['success' => true, 'message' => 'Dont show again updated successfully']);
} catch (\Exception $e) {
DB::rollBack();
logger()->error($e->getMessage());

return response()->json(['success' => false, 'message' => 'Error occurred while storing setting']);
return response()->json(['success' => false, 'message' => 'Error occurred while updating dont show again']);
}
}

/**
* Updates activity status to complete.
*
* @return JsonResponse
*/
public function completeActivityForOnboarding(): JsonResponse
{
try {
DB::beginTransaction();
$this->organizationOnboardingService->updateOrganizationOnboardingStepToComplete(Auth::user()->organization_id, OrganizationOnboarding::ACTIVITY, true);
DB::commit();

return response()->json(['success' => true, 'message' => 'Activity status updated successfully']);
} catch (\Exception $e) {
DB::rollBack();
logger()->error($e->getMessage());

return response()->json(['success' => false, 'message' => 'Error occurred while storing updating activity status']);
}
}
}
17 changes: 12 additions & 5 deletions app/Http/Controllers/Admin/Organization/ReportingOrgController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use App\Http\Requests\Organization\ReportingOrg\ReportingOrgRequest;
use App\IATI\Services\Organization\ReportingOrgService;
use Illuminate\Contracts\View\View;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Auth;
Expand Down Expand Up @@ -60,25 +61,31 @@ public function edit(): View|RedirectResponse
*
* @param ReportingOrgRequest $request
*
* @return RedirectResponse
* @return RedirectResponse|JsonResponse
*/
public function update(ReportingOrgRequest $request): RedirectResponse
public function update(ReportingOrgRequest $request): JsonResponse|RedirectResponse
{
try {
DB::beginTransaction();

if (!$this->reportingOrgService->update(Auth::user()->organization_id, $request->all())) {
return redirect()->route('admin.organisation.index')->with('error', 'Error has occurred while updating organization reporting_org.');
return $request->expectsJson() ?
response()->json(['success' => false, 'error' => 'Error has occurred while updating organization reporting_org.'], 500) :
redirect()->route('admin.organisation.index')->with('error', 'Error has occurred while updating organization reporting_org.');
}

DB::commit();

return redirect()->route('admin.organisation.index')->with('success', 'Organization reporting_org updated successfully.');
return $request->expectsJson() ?
response()->json(['success' => true, 'message' => 'Organization reporting_org updated successfully.']) :
redirect()->route('admin.organisation.index')->with('success', 'Organization reporting_org updated successfully.');
} catch (\Exception $e) {
DB::rollBack();
logger()->error($e->getMessage());

return redirect()->route('admin.organisation.index')->with('error', 'Error has occurred while updating organization reporting_org.');
return $request->expectsJson() ?
response()->json(['success' => false, 'error' => 'Error has occurred while updating organization reporting_org.'], 500) :
redirect()->route('admin.organisation.index')->with('error', 'Error has occurred while updating organization reporting_org.');
}
}
}
2 changes: 1 addition & 1 deletion app/IATI/Models/Organization/Organization.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,6 @@ public function activityPublished(): HasOne
*/
public function onboarding(): HasOne
{
return $$this->hasOne(OrganizationOnboarding::class, 'org_id', 'id');
return $this->hasOne(OrganizationOnboarding::class, 'org_id', 'id');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function getOrganizationOnboardingStepsStatus($organization): array
$array[] = [
'step' => 4,
'title' => OrganizationOnboarding::ACTIVITY,
'complete' => true,
'complete' => false,
];

return $array;
Expand Down Expand Up @@ -150,7 +150,7 @@ public function create($data): Model
*
* @return void
*/
public function updateOrganizationOnboardingStepToComplete($organizationId, $stepName, $value = true): void
public function updateOrganizationOnboardingStepToComplete($organizationId, $stepName, bool $value = true): void
{
$update = false;
$organizationOnboarding = $this->getOrganizationOnboarding($organizationId);
Expand Down
Loading

0 comments on commit 18779d1

Please sign in to comment.