Skip to content

Commit

Permalink
Merge main into sweep/make_sure_dna_matching_in_dna_resources
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] authored Mar 20, 2024
2 parents b6296df + a1c5b3c commit 76fbc88
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/Filament/Pages/HenryReportPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ public static function getNavigationIcon(): string

public function mount(): void
{
Livewire::mount(static::$view);
\Livewire\Livewire::mount(\App\Http\Livewire\HenryReport::class);
}
}
33 changes: 24 additions & 9 deletions app/Http/Livewire/DescendantChartComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,31 @@ public function mount()

private function processDescendantData($data)
{
// Transforming data into a hierarchical structure for D3.js
$hierarchy = [];
foreach ($data as $person) {
$hierarchy[] = [ // Mocking up a simplified hierarchical structure
'id' => $person['id'],
'name' => $person['name'],
'children' => [] // Assuming children can be populated elsewhere
];

$tree = [];
foreach ($data as $item) {
if (!isset($tree[$item['id']])) {
$tree[$item['id']] = ['id' => $item['id'], 'name' => $item['name'], 'children' => []];
}
if ($item['parent_id']) {
$tree[$item['parent_id']]['children'][] = &$tree[$item['id']];
}
}
return $hierarchy;
return array_filter($tree, function ($item) {
return empty($item['parent_id']);
});












}

public function render()
Expand Down
42 changes: 42 additions & 0 deletions app/Http/Livewire/HenryReport.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace App\Http\Livewire;

use Livewire\Component;
use App\Models\Person;

class HenryReport extends Component
{
public $selectedPersonId;
public $reportData = [];

public function render()
{
return view('livewire.henry-report', ['reportData' => $this->reportData]);
}

public function generateReport($personId)
{
$this->selectedPersonId = $personId;
$person = Person::find($personId);
if ($person) {
$this->reportData = [];
$this->processHenryReportData($person);
}
}

private function processHenryReportData($person)
{
$this->reportData[$person->id] = [
'name' => $person->fullname(),
'birth' => optional($person->birth())->date,
'death' => optional($person->death())->date,
];

$childNumber = 1;
foreach ($person->child_in_family as $child) {
$this->processHenryReportData($child, $childNumber);
$childNumber++;
}
}
}
46 changes: 46 additions & 0 deletions resources/views/livewire/henry-report.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<div>
<form wire:submit.prevent="generateReport(selectedPersonId)">
<div class="form-group">
<label for="personSelect">Select a Person:</label>
<select id="personSelect" class="form-control" wire:model="selectedPersonId">
<option value="">--Choose--</option>
@foreach(\App\Models\Person::all() as $person)
<option value="{{ $person->id }}">{{ $person->name }}</option>
@endforeach
</select>
</div>
<button type="submit" class="btn btn-primary">Generate Report</button>
</form>

<div wire:loading>
Generating report...
</div>

@if(!empty($reportData))
<table class="table mt-4">
<thead>
<tr>
<th>Name</th>
<th>Birth Date</th>
<th>Death Date</th>
</tr>
</thead>
<tbody>
@foreach($reportData as $data)
<tr>
<td>{{ $data['name'] }}</td>
<td>{{ $data['birth'] }}</td>
<td>{{ $data['death'] }}</td>
</tr>
@endforeach
</tbody>
</table>
@endif
</div>
@extends('layouts.app')

@section('content')
<div>
<!-- The content of the view goes here, following the structure above -->
</div>
@endsection

0 comments on commit 76fbc88

Please sign in to comment.