diff --git a/packages/common/index.ts b/packages/common/index.ts index c5756a6eb..eea303dd5 100644 --- a/packages/common/index.ts +++ b/packages/common/index.ts @@ -989,7 +989,15 @@ export enum QueueTypes { export enum ExtraTAStatus { HELPING_IN_ANOTHER_QUEUE = 'Helping student in another queue', HELPING_IN_ANOTHER_COURSE = 'Helping student in another course', + AWAY = 'Away', } + +export class SetTAExtraStatusParams { + @IsOptional() + @IsEnum(ExtraTAStatus) + status?: ExtraTAStatus | null +} + export interface StaffMember { id: number name: string @@ -1087,6 +1095,7 @@ export type StaffForStaffList = { name: string photoURL?: string questionHelpedAt?: Date + extraStatus?: ExtraTAStatus } // Represents a list of office hours wait times of each hour of the week. diff --git a/packages/frontend/app/(dashboard)/course/[cid]/queue/[qid]/components/QueueInfoColumn.tsx b/packages/frontend/app/(dashboard)/course/[cid]/queue/[qid]/components/QueueInfoColumn.tsx index 681dda88d..ed23f8263 100644 --- a/packages/frontend/app/(dashboard)/course/[cid]/queue/[qid]/components/QueueInfoColumn.tsx +++ b/packages/frontend/app/(dashboard)/course/[cid]/queue/[qid]/components/QueueInfoColumn.tsx @@ -10,7 +10,7 @@ import { UpOutlined, EnvironmentOutlined, } from '@ant-design/icons' -import { Button, Popconfirm, Row, Switch, Tooltip } from 'antd' +import { Button, Popconfirm, Row, Switch, Tooltip, message } from 'antd' import moment from 'moment' import React, { ReactNode, useState } from 'react' import { useQueue } from '@/app/hooks/useQueue' @@ -28,7 +28,11 @@ import RenderEvery from '@/app/components/RenderEvery' import TagGroupSwitch from './TagGroupSwitch' import StaffList from './StaffList' import { getQueueTypeLabel } from '../utils/commonQueueFunctions' -import { QueuePartial, GetQueueChatsResponse } from '@koh/common' +import { QueuePartial, GetQueueChatsResponse, ExtraTAStatus } from '@koh/common' +import { useUserInfo } from '@/app/contexts/userContext' +import { API } from '@/app/api' +import { getErrorMessage } from '@/app/utils/generalUtils' +import { useMediaQuery } from '@/app/hooks/useMediaQuery' interface QueueInfoColumnProps { cid: number @@ -58,15 +62,26 @@ const QueueInfoColumn: React.FC = ({ queueChats, }) => { const router = useRouter() + const { userInfo } = useUserInfo() + const isMobile = useMediaQuery('(max-width: 768px)') - // const [away, setAway] = useState(false); - // const checkAway = (checked: boolean) => { - // if (!checked) { - // setAway(true); - // } else { - // setAway(false); - // } - // }; + const me = queue?.staffList?.find((s) => s.id === userInfo?.id) + const isAway = me?.extraStatus === ExtraTAStatus.AWAY + const [savingAway, setSavingAway] = useState(false) + const awaySwitchId = `away-switch-${queueId}` + const toggleAway = async (checked: boolean) => { + // checked = Away; unchecked = Answering + const newStatus = checked ? ExtraTAStatus.AWAY : null + try { + setSavingAway(true) + await API.taStatus.setExtraStatus(cid, queueId, newStatus) + } catch (err) { + const errorMessage = getErrorMessage(err) + message.error(errorMessage) + } finally { + setSavingAway(false) + } + } return (
{/* only show the queue title and warning here on desktop, it's moved further down on mobile (and placed in queue page.tsx) */} @@ -116,8 +131,23 @@ const QueueInfoColumn: React.FC = ({ {buttons}
-
+

Staff

+ {isStaff && ( +
+ + + +
+ )} {/* Button to hide staff list on mobile */}