diff --git a/app/controllers/products/unassigned_controller.rb b/app/controllers/products/unassigned_controller.rb index ed591dc5e20..a15ba97b12e 100644 --- a/app/controllers/products/unassigned_controller.rb +++ b/app/controllers/products/unassigned_controller.rb @@ -2,5 +2,7 @@ class Products::UnassignedController < ApplicationController before_action :require_staff_login - def index; end + def index + @product_deadline_day = ProductDeadline.first_or_create(alert_day: 4).alert_day + end end diff --git a/app/javascript/components/ElapsedDays.jsx b/app/javascript/components/ElapsedDays.jsx index c93cb4a8eed..207e4a7141b 100644 --- a/app/javascript/components/ElapsedDays.jsx +++ b/app/javascript/components/ElapsedDays.jsx @@ -1,6 +1,6 @@ import React from 'react' -export default function ElapsedDays({ countProductsGroupedBy }) { +export default function ElapsedDays({ countProductsGroupedBy, productDeadlineDay }) { const activeClass = (quantity) => { return quantity ? 'is-active' : 'is-inactive' } @@ -11,35 +11,35 @@ export default function ElapsedDays({ countProductsGroupedBy }) {
  1. - 6日以上経過{` (${countProductsGroupedBy(6)})`} + {productDeadlineDay + 2}日以上経過{` (${countProductsGroupedBy(productDeadlineDay + 2)})`}
  2. - 5日経過{` (${countProductsGroupedBy(5)})`} + {productDeadlineDay + 1}日経過{` (${countProductsGroupedBy(productDeadlineDay + 1)})`}
  3. - 4日経過{` (${countProductsGroupedBy(4)})`} + {productDeadlineDay}日経過{` (${countProductsGroupedBy(productDeadlineDay)})`}
  4. - {[3, 2, 1].map((passedDay) => { + {Array.from({ length: productDeadlineDay - 1 }, (_, index) => index + 1).reverse().map((passedDay) => { return (
  5. { elapsedDays.push(group.elapsed_days) }) - return elapsedDays.every((day) => day < 4) + return elapsedDays.every((day) => day < productDeadlineDay) } const updateElapsedDays = (productsGroupedByElapsedDays) => { const updateElapsedDays = [] productsGroupedByElapsedDays.forEach((group) => { - const elapsedDays = group.elapsed_days >= 6 ? 6 : group.elapsed_days + const elapsedDays = group.elapsed_days >= productDeadlineDay + 2 ? productDeadlineDay + 2 : group.elapsed_days let existingGroup = updateElapsedDays.find( (g) => g.elapsed_days === elapsedDays ) @@ -123,7 +124,7 @@ export default function Products({
    -

    4日経過した提出物はありません

    +

    {productDeadlineDay}日経過した提出物はありません

    ) } else if (selectedTab !== 'unassigned') { @@ -188,7 +189,7 @@ export default function Products({
    {data.products_grouped_by_elapsed_days - .filter((group) => group.elapsed_days !== 7) + .filter((group) => group.elapsed_days !== 8) .map((productsNDaysPassed) => { return (
    @@ -221,7 +223,10 @@ export default function Products({
    - +
    ) @@ -231,21 +236,22 @@ export default function Products({ function ProductHeader({ productsNDaysPassed, elapsedDaysId, - countProductsGroupedBy + countProductsGroupedBy, + productDeadlineDay }) { let headerClass = 'card-header a-elapsed-days' - if (productsNDaysPassed.elapsed_days === 4) { + if (productsNDaysPassed.elapsed_days === productDeadlineDay) { headerClass += ' is-reply-warning' - } else if (productsNDaysPassed.elapsed_days === 5) { + } else if (productsNDaysPassed.elapsed_days === productDeadlineDay + 1) { headerClass += ' is-reply-alert' - } else if (productsNDaysPassed.elapsed_days >= 6) { + } else if (productsNDaysPassed.elapsed_days >= productDeadlineDay + 2) { headerClass += ' is-reply-deadline' } const headerLabel = () => { if (productsNDaysPassed.elapsed_days === 0) { return '今日提出' - } else if (productsNDaysPassed.elapsed_days === 6) { + } else if (productsNDaysPassed.elapsed_days === productDeadlineDay + 2) { return `${productsNDaysPassed.elapsed_days}日以上経過` } else { return `${productsNDaysPassed.elapsed_days}日経過` diff --git a/app/views/products/unassigned/index.html.slim b/app/views/products/unassigned/index.html.slim index 92a7a7e709f..00b3a6ab5a3 100644 --- a/app/views/products/unassigned/index.html.slim +++ b/app/views/products/unassigned/index.html.slim @@ -12,4 +12,4 @@ header.page-header .page-body .container.is-lg - = react_component('Products', title: title, selectedTab: 'unassigned', isMentor: mentor_login?, isAdmin: admin_login?, currentUserId: current_user.id) + = react_component('Products', title: title, selectedTab: 'unassigned', isMentor: mentor_login?, isAdmin: admin_login?, currentUserId: current_user.id, productDeadlineDay: @product_deadline_day)