|
17 | 17 | <div class="gap-6 flex justify-between"> |
18 | 18 | <!-- First Column: List milestones --> |
19 | 19 | <div class="px-16 grid grid-cols-1 gap-4 col-span-1 w-1/2"> |
20 | | - <h2 class="text-lg font-semibold text-gray-900 dark:text-white mb-2">Milestones</h2> |
21 | | - <% if @product.milestones.any? %> |
22 | | - <ul class="space-y-3"> |
23 | | - <% @product.milestones.each do |milestone| %> |
24 | | - <li class="bg-gray-50 dark:bg-gray-700 p-4 rounded-md shadow-sm"> |
25 | | - <p class="text-sm text-gray-800 dark:text-white"> |
26 | | - <strong>Status:</strong> <%= milestone.status&.name || 'N/A' %> |
27 | | - </p> |
28 | | - <p class="text-sm text-gray-800 dark:text-white"> |
29 | | - <strong>Percentage:</strong> <%= milestone.percentage %>% |
30 | | - </p> |
31 | | - <% if @product.budget.present? %> |
32 | | - <p class="text-sm text-gray-800 dark:text-white"> |
33 | | - <strong>Amount:</strong> KES <%= number_with_precision(@product.budget * milestone.percentage.to_f / 100, precision: 2) %> |
34 | | - </p> |
35 | | - <% end %> |
| 20 | + <h2 class="text-lg font-semibold text-gray-900 dark:text-white mb-2">Milestones</h2> |
| 21 | + <% if @product.milestones.any? %> |
| 22 | + <ul class="space-y-3"> |
| 23 | + <% @product.milestones.each do |milestone| %> |
| 24 | + <li class="bg-gray-50 dark:bg-gray-700 p-4 rounded-md shadow-sm"> |
| 25 | + <p class="text-sm text-gray-800 dark:text-white"> |
| 26 | + <strong>Status:</strong> <%= milestone.status&.name || 'N/A' %> |
| 27 | + </p> |
| 28 | + <p class="text-sm text-gray-800 dark:text-white"> |
| 29 | + <strong>Percentage:</strong> <%= milestone.percentage %>% |
| 30 | + </p> |
| 31 | + <% if @product.budget.present? %> |
| 32 | + <p class="text-sm text-gray-800 dark:text-white"> |
| 33 | + <strong>Amount:</strong> KES <%= number_with_precision(@product.budget * milestone.percentage.to_f / 100, precision: 2) %> |
| 34 | + </p> |
| 35 | + <% end %> |
36 | 36 |
|
37 | | - <!-- Paid Toggle --> |
38 | | - <div class="mt-2"> |
39 | | - <%= form_with url: toggle_paid_milestone_path(milestone), method: :patch, local: true, remote: true do |form| %> |
40 | | - <div class="flex items-center"> |
41 | | - <label class="relative inline-block w-16 h-8"> |
42 | | - <%= form.check_box :paid, |
43 | | - checked: milestone.paid, |
44 | | - class: "hidden", |
45 | | - disabled: milestone.paid?, # lock once paid |
46 | | - onchange: milestone.paid? ? nil : 'this.form.submit()' %> |
47 | | - |
48 | | - <span class="absolute cursor-pointer top-0 left-0 right-0 bottom-0 bg-gray-300 rounded-full transition duration-300"></span> |
49 | | - <span class="absolute left-1 top-1 bg-white w-6 h-6 rounded-full transition duration-300 transform"></span> |
50 | | - </label> |
51 | | - <span class="ml-3 text-sm text-gray-800 dark:text-white"> |
52 | | - Paid |
53 | | - </span> |
| 37 | + <!-- Paid Toggle --> |
| 38 | + <div class="mt-2"> |
| 39 | + <%= form_with url: toggle_paid_milestone_path(milestone), method: :patch, local: true, remote: true do |form| %> |
| 40 | + <div class="flex items-center space-x-3"> |
| 41 | + |
| 42 | + <!-- Switch --> |
| 43 | + <label class="relative inline-block w-16 h-8"> |
| 44 | + <%= form.check_box :paid, |
| 45 | + checked: milestone.paid, |
| 46 | + class: "hidden peer", |
| 47 | + disabled: milestone.paid?, |
| 48 | + onchange: milestone.paid? ? nil : 'this.form.submit()' %> |
| 49 | + |
| 50 | + <!-- Background --> |
| 51 | + <span class="absolute top-0 left-0 right-0 bottom-0 bg-gray-300 rounded-full transition duration-300 peer-checked:bg-green-500"></span> |
| 52 | + |
| 53 | + <!-- Knob --> |
| 54 | + <span class="absolute left-1 top-1 bg-white w-6 h-6 rounded-full transition duration-300 transform peer-checked:translate-x-8"></span> |
| 55 | + </label> |
| 56 | + |
| 57 | + <!-- Label Text --> |
| 58 | + <span class="text-sm text-gray-800 dark:text-white"> |
| 59 | + Paid |
| 60 | + <span class="text-xs text-gray-500 block"> |
| 61 | + <% if milestone.paid? %> |
| 62 | + This milestone has been paid and cannot be changed. |
| 63 | + <% else %> |
| 64 | + Once marked as paid, it cannot be undone. |
| 65 | + <% end %> |
| 66 | + </span> |
| 67 | + </span> |
| 68 | + |
| 69 | + </div> |
| 70 | + <% end %> |
54 | 71 | </div> |
55 | | - <% end %> |
56 | | - </div> |
57 | 72 |
|
58 | 73 |
|
59 | | - </li> |
| 74 | + |
| 75 | + </li> |
| 76 | + <% end %> |
| 77 | + </ul> |
| 78 | + <% else %> |
| 79 | + <p class="text-gray-500 dark:text-gray-400">No milestones available for this product.</p> |
60 | 80 | <% end %> |
61 | | - </ul> |
62 | | - <% else %> |
63 | | - <p class="text-gray-500 dark:text-gray-400">No milestones available for this product.</p> |
64 | | - <% end %> |
65 | | -</div> |
| 81 | + </div> |
66 | 82 |
|
67 | 83 |
|
68 | 84 | <!-- Fourth Column: Documents --> |
|
0 commit comments