Index_backup.cshtml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. @model WeekPlannerViewModel
  2. @{
  3. ViewData["Title"] = "Week Planner";
  4. }
  5. <div class="container-fluid">
  6. <h1 class="mb-4">📅 Week Planner</h1>
  7. <!-- Debug info -->
  8. <div class="alert alert-warning">
  9. <p>Debug: Model is @(Model == null ? "NULL" : "NOT NULL")</p>
  10. @if (Model != null)
  11. {
  12. <p>StartDate: @Model.StartDate</p>
  13. <p>CurrentWeekPlan is @(Model.CurrentWeekPlan == null ? "NULL" : "NOT NULL")</p>
  14. }
  15. </div>
  16. @if (Model?.CurrentWeekPlan == null)
  17. {
  18. <div class="alert alert-info">
  19. <h4>No meal plan for this week yet!</h4>
  20. <p>Create a new week plan to start planning your meals.</p>
  21. <form asp-action="CreateWeekPlan" method="post" class="d-inline">
  22. <input type="hidden" name="startDate"
  23. value="@(Model?.StartDate.ToString("yyyy-MM-dd") ?? DateTime.Today.ToString("yyyy-MM-dd"))" />
  24. <button type="submit" class="btn btn-primary">
  25. <i class="fas fa-plus"></i> Create Week Plan
  26. </button>
  27. </form>
  28. </div>
  29. }
  30. else
  31. {
  32. <div class="week-header mb-4">
  33. <h2>@Model!.CurrentWeekPlan!.Name</h2>
  34. <p class="text-muted">Week of @Model!.StartDate.ToString("MMMM dd, yyyy")</p>
  35. </div>
  36. <div class="row">
  37. @foreach (var dayPlan in Model!.CurrentWeekPlan!.DayPlans.OrderBy(dp => dp.Date))
  38. {
  39. <div class="col-xl-3 col-lg-4 col-md-6 mb-4">
  40. <div class="card h-100">
  41. <div class="card-header d-flex justify-content-between align-items-center">
  42. <h5 class="mb-0">@dayPlan.DayOfWeek</h5>
  43. <small class="text-muted">@dayPlan.Date.ToString("MMM dd")</small>
  44. </div>
  45. <div class="card-body">
  46. @if (dayPlan.Recipe != null)
  47. {
  48. <div class="recipe-preview">
  49. <h6>@dayPlan.Recipe.Title</h6>
  50. <div class="recipe-info">
  51. @if (!string.IsNullOrEmpty(dayPlan.MainIngredient))
  52. {
  53. <span class="badge bg-primary mb-2">@dayPlan.MainIngredient</span>
  54. }
  55. @if (!string.IsNullOrEmpty(dayPlan.Recipe.Time))
  56. {
  57. <span class="badge bg-info mb-2">@dayPlan.Recipe.Time min</span>
  58. }
  59. <p class="small text-muted">@(dayPlan.Recipe.Description?.Length > 80 ?
  60. dayPlan.Recipe.Description.Substring(0, 80) + "..." :
  61. dayPlan.Recipe.Description)</p>
  62. </div>
  63. </div>
  64. }
  65. else
  66. {
  67. <div class="text-center text-muted">
  68. <i class="fas fa-utensils fa-3x mb-3" style="color: #dee2e6;"></i>
  69. <p>No recipe selected</p>
  70. @if (!string.IsNullOrEmpty(dayPlan.MainIngredient))
  71. {
  72. <span class="badge bg-secondary">@dayPlan.MainIngredient</span>
  73. }
  74. </div>
  75. }
  76. </div>
  77. <div class="card-footer">
  78. <div class="btn-group w-100" role="group">
  79. <a href="@Url.Action("ConfigureDay", new { weekPlanId = Model.CurrentWeekPlan.Id, dayOfWeek = dayPlan.DayOfWeek })"
  80. class="btn btn-outline-primary btn-sm">
  81. <i class="fas fa-cog"></i> Configure
  82. </a>
  83. <form asp-action="RandomizeRecipe" method="post" class="d-inline" style="flex: 1;">
  84. <input type="hidden" name="dayPlanId" value="@dayPlan.Id" />
  85. <button type="submit" class="btn btn-outline-success btn-sm w-100">
  86. <i class="fas fa-dice"></i> Random
  87. </button>
  88. </form>
  89. </div>
  90. @if (dayPlan.Recipe != null)
  91. {
  92. <div class="mt-2">
  93. <a href="@Url.Action("Details", "Recipe", new { id = dayPlan.Recipe.Id })"
  94. class="btn btn-sm btn-outline-secondary w-100">
  95. <i class="fas fa-eye"></i> View Recipe
  96. </a>
  97. </div>
  98. }
  99. </div>
  100. </div>
  101. </div>
  102. }
  103. </div>
  104. <div class="week-actions mt-4">
  105. <div class="row">
  106. <div class="col-md-6">
  107. <form asp-action="CreateWeekPlan" method="post" class="d-inline">
  108. <input type="hidden" name="startDate" value="@Model.StartDate.AddDays(7).ToString("yyyy-MM-dd")" />
  109. <button type="submit" class="btn btn-success">
  110. <i class="fas fa-plus"></i> Create Next Week
  111. </button>
  112. </form>
  113. </div>
  114. <div class="col-md-6 text-end">
  115. <form asp-action="CreateWeekPlan" method="post" class="d-inline">
  116. <input type="hidden" name="startDate" value="@Model.StartDate.AddDays(-7).ToString("yyyy-MM-dd")" />
  117. <button type="submit" class="btn btn-outline-secondary">
  118. <i class="fas fa-arrow-left"></i> Create Previous Week
  119. </button>
  120. </form>
  121. </div>
  122. </div>
  123. </div>
  124. }
  125. </div>
  126. <style>
  127. .recipe-suggestion:hover {
  128. box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  129. }
  130. .card-footer .btn-group {
  131. gap: 0;
  132. }
  133. .card-footer .btn-group .btn {
  134. border-radius: 0;
  135. }
  136. .card-footer .btn-group .btn:first-child {
  137. border-top-left-radius: 0.375rem;
  138. border-bottom-left-radius: 0.375rem;
  139. }
  140. .card-footer .btn-group .btn:last-child {
  141. border-top-right-radius: 0.375rem;
  142. border-bottom-right-radius: 0.375rem;
  143. }
  144. </style>