All files / components/PersonalSchedulesWeeklyView PersonalSchedulesWeeklyViewPanel.js

100% Statements 11/11
100% Branches 5/5
100% Functions 7/7
100% Lines 11/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186        2x                   2x                                                                   4x   4x         28x                               28x   5x                                           96x                               28x           644x                               2x                                                                                                        
import React from "react";
import { Container, Row, Col, Card } from "react-bootstrap";
import PersonalSectionsEvents from "./PersonalSchedulesWeeklyViewEvent";
 
const daysOfWeek = [
  "Monday",
  "Tuesday",
  "Wednesday",
  "Thursday",
  "Friday",
  "Saturday",
  "Sunday",
];
 
const hours = [
  "",
  "1 AM",
  "2 AM",
  "3 AM",
  "4 AM",
  "5 AM",
  "6 AM",
  "7 AM",
  "8 AM",
  "9 AM",
  "10 AM",
  "11 AM",
  "12 PM",
  "1 PM",
  "2 PM",
  "3 PM",
  "4 PM",
  "5 PM",
  "6 PM",
  "7 PM",
  "8 PM",
  "9 PM",
  "10 PM",
  "11 PM",
];
 
// Stryker disable all : no need to test default colors
export default function PersonalSchedulesWeeklyView({
  Events = [],
  eventColor = "#d1ecf188",
  borderColor = "#bee5eb",
}) {
  // Stryker restore all
  const testId = "PersonalSchedulesWeeklyView";
 
  return (
    <Container fluid style={styles.schedulerPanel}>
      <Row style={styles.headerRow}>
        <Col style={styles.timeColumn}></Col>
        {daysOfWeek.map((day) => (
          <Col
            key={day}
            style={styles.dayColumn}
            data-testid={`${testId}-${day}-column`}
          >
            <Card style={styles.dayCard}>
              <Card.Body>
                <Card.Title
                  style={styles.dayTitle}
                  data-testid={`${testId}-${day}-title`}
                >
                  {day}
                </Card.Title>
              </Card.Body>
              {Events.filter(
                // Stryker disable next-line all : no need to test startTime edge case
                (event) => event.day.includes(day) && event.startTime !== "",
              ).map((event) => (
                <PersonalSectionsEvents
                  key={event.id}
                  event={event}
                  eventColor={eventColor}
                  borderColor={borderColor}
                />
              ))}
            </Card>
          </Col>
        ))}
      </Row>
      <Row>
        <Col style={styles.timeColumn}>
          {
            /* Stryker disable all : no test needed for styling */
            <div
              style={{ ...styles.timeSlot, height: "30px", border: "0" }}
            ></div>
            // Stryker restore all
          }
          {hours.map((hour, index) => (
            /* Stryker disable all : no test needed for styling */
            <div
              key={index}
              style={{ ...styles.timeSlot, border: "0" }}
              data-testid={`${testId}-${hour.replace(" ", "-")}-title`}
              /* Stryker restore all */
            >
              <span
                style={styles.hourLabel}
                data-testid={`${testId}-${hour.replace(" ", "-")}-label`}
              >
                {hour}
              </span>
            </div>
          ))}
        </Col>
        {daysOfWeek.map((day) => (
          <Col key={day} style={styles.dayColumn}>
            {
              /* Stryker disable next-line all : no test needed for styling */
              <div style={{ ...styles.timeSlot, height: "30px" }}></div>
            }
            {hours.slice(0, hours.length - 1).map((hour) => (
              <div
                key={hour}
                style={styles.timeSlot}
                data-testid={`${testId}-base-slot`}
              >
                <Card style={styles.eventCard} />
              </div>
            ))}
          </Col>
        ))}
      </Row>
    </Container>
  );
}
 
// Stryker disable all: no need to test styles
const styles = {
  schedulerPanel: {
    backgroundColor: "#fff",
    padding: "20px",
  },
  headerRow: {
    textAlign: "center",
  },
  timeColumn: {
    textAlign: "right",
    borderRight: "1px solid #ddd",
    position: "relative",
  },
  dayColumn: {
    padding: 0,
    borderRight: "1px solid #ddd",
  },
  dayCard: {
    backgroundColor: "#ddd",
    borderRadius: "0",
  },
  dayTitle: {
    fontSize: "1.2rem",
    fontWeight: "bold",
  },
  timeSlot: {
    height: "60px" /* Full time slot height */,
    display: "flex",
    alignItems: "center",
    justifyContent: "center",
    position: "relative",
    borderBottom: "1px solid #ddd",
  },
  eventCard: {
    width: "100%",
    height: "100%",
    border: "0",
    // borderBottom: "1px solid #eeeeee",
    borderRadius: "0",
  },
  hourLabel: {
    height: "30px" /* Half of the full time slot height */,
    display: "flex",
    alignItems: "center",
    justifyContent: "right",
    position: "absolute",
    top: 0,
    right: "5px",
    transform: "translateY(-50%)",
  },
};
// Stryker restore all