Skip to content

Commit

Permalink
Resolve PR reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
sazanrjb committed Dec 19, 2023
1 parent f5fc7c8 commit af8633d
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/app/components/AutoResponder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ const AutoResponder = ({ onSave, activeSettings }: Props) => {
);
}
}
}, [autoRespond]);
}, [autoRespond, isDirty, setValue]);

const toggleSelectedDay = (day: DAY_VALUE) => {
const selectedDayIndex = selectedDays.fields.findIndex((selectedDay) => selectedDay.day === day);
Expand Down
7 changes: 4 additions & 3 deletions src/app/components/Days.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Typography from './Typography';
import { DAYS, SelectedDay, DAY_KEY, DAY_VALUE } from '@/constants';
import { keys } from '@/utils/common';

interface Props {
selectedDays: SelectedDay[];
Expand All @@ -9,12 +10,12 @@ interface Props {
const Days = ({ selectedDays, onDayClick }: Props) => {
return (
<ul className="flex flex-wrap items-center gap-4">
{Object.keys(DAYS).map((day: DAY_KEY | string) => {
const isSelected = !!selectedDays.find((selectedDay) => DAYS[day as DAY_KEY] === selectedDay.day);
{keys(DAYS).map((day) => {
const isSelected = !!selectedDays.find((selectedDay) => DAYS[day] === selectedDay.day);
return (
<li
key={day}
onClick={() => onDayClick(DAYS[day as DAY_KEY])}
onClick={() => onDayClick(DAYS[day])}
className={`w-8 h-8 flex items-center justify-center rounded-full
uppercase text-center leading-8 ${isSelected ? 'bg-text' : 'bg-border'} ${
isSelected ? 'text-white' : 'text-text'
Expand Down
7 changes: 4 additions & 3 deletions src/app/components/WorkingHours.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Typography from './Typography';
import SelectField from './Select';
import { DAYS, DAY_KEY, HOUR, HOURS_SELECT_OPTIONS, SelectedDay } from '@/constants';
import React, { useMemo } from 'react';
import { keys } from '@/utils/common';

interface Props {
selectedDays: SelectedDay[];
Expand All @@ -12,16 +13,16 @@ interface Props {

const WorkingHours = ({ selectedDays, errors }: Props) => {
const daysToRender = useMemo(() => {
return Object.keys(DAYS).map((day: DAY_KEY | string) => {
return keys(DAYS).map((day) => {
const selectedDayIndex = selectedDays.findIndex((selectedDay) => {
return selectedDay.day === DAYS[day as DAY_KEY];
return selectedDay.day === DAYS[day];
});

if (selectedDayIndex < 0) {
return null;
}

const error = errors[DAYS[day as DAY_KEY]];
const error = errors[DAYS[day]];

return (
<li key={day}>
Expand Down
2 changes: 1 addition & 1 deletion src/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

* {
box-sizing: border-box;
font-family: 'Inter', 'Helvetica', 'Arial', san-serif;
font-family: 'Inter', 'Helvetica', 'Arial', sans-serif, serif;
}

:root {
Expand Down
4 changes: 3 additions & 1 deletion src/config/app.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export default {
const appConfig = {
copilotApiKey: process.env.COPILOT_API_KEY || '',
webhookSigningSecret: process.env.WEBHOOK_SIGNING_SECRET || '',
};

export default appConfig;
2 changes: 1 addition & 1 deletion src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const DAYS = {
THURSDAY: 4,
FRIDAY: 5,
SATURDAY: 6,
};
} as const;

export enum HOUR {
'0:00-AM' = '00:00',
Expand Down
8 changes: 8 additions & 0 deletions src/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,11 @@ export function isWithinWorkingHours(timezone: string, workingHours: WorkingHour
currentTime.isAfter(LocalTime.parse(workingDay.startTime)) && currentTime.isBefore(LocalTime.parse(workingDay.endTime))
);
}

export function keys<T extends Record<string, unknown>>(obj: T): (keyof T)[] {
const result: (keyof T)[] = [];
for (const key in obj) {
result.push(key);
}
return result;
}

0 comments on commit af8633d

Please sign in to comment.