Render missing-value unassigned labels in italic.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Yared Yemane 2026-08-01 00:31:16 -07:00
parent ab8d487016
commit e1d262cdf5
44 changed files with 250 additions and 159 deletions

View File

@ -3,6 +3,7 @@ import { Plus, Trash2 } from "lucide-react"
import { Button } from "../ui/button" import { Button } from "../ui/button"
import { Input } from "../ui/input" import { Input } from "../ui/input"
import { cn } from "../../lib/utils" import { cn } from "../../lib/utils"
import { UnassignedLabel } from "../../lib/displayValue"
import { import {
createEmptyTable, createEmptyTable,
parseTableSlotValue, parseTableSlotValue,
@ -236,7 +237,7 @@ export function DynamicTableBuilder({
key={`preview-c-${ri}-${ci}`} key={`preview-c-${ri}-${ci}`}
className="border border-grayScale-100 px-3 py-2 text-sm" className="border border-grayScale-100 px-3 py-2 text-sm"
> >
{cell || <span className="text-grayScale-300">unassigned</span>} {cell || <span className="text-grayScale-300"><UnassignedLabel /></span>}
</td> </td>
))} ))}
</tr> </tr>

View File

@ -18,6 +18,7 @@ import {
type Notification, type Notification,
} from "../../types/notification.types"; } from "../../types/notification.types";
import { cn } from "../../lib/utils"; import { cn } from "../../lib/utils";
import { UnassignedLabel } from "../../lib/displayValue"
type NotificationDetailDialogProps = { type NotificationDetailDialogProps = {
open: boolean; open: boolean;
@ -187,9 +188,9 @@ function DetailsTab({
<div className="space-y-0 divide-y divide-grayScale-100"> <div className="space-y-0 divide-y divide-grayScale-100">
{[ {[
{ k: "Type", v: formatNotificationTypeLabel(notification.type) }, { k: "Type", v: formatNotificationTypeLabel(notification.type) },
{ k: "Channel", v: notification.delivery_channel || "unassigned" }, { k: "Channel", v: notification.delivery_channel || <UnassignedLabel /> },
{ k: "Status", v: notification.is_read ? "Read" : "Unread" }, { k: "Status", v: notification.is_read ? "Read" : "Unread" },
{ k: "Delivery", v: notification.delivery_status || "unassigned" }, { k: "Delivery", v: notification.delivery_status || <UnassignedLabel /> },
...(notification.receiver_type ...(notification.receiver_type
? [{ k: "Receiver", v: notification.receiver_type }] ? [{ k: "Receiver", v: notification.receiver_type }]
: []), : []),

View File

@ -1,19 +0,0 @@
export const UNASSIGNED_LABEL = "unassigned"
/** @deprecated Prefer UNASSIGNED_LABEL */
export const NOT_ASSIGNED_LABEL = UNASSIGNED_LABEL
const LEGACY_EMPTY_LABELS = new Set(["—", "-", "Not assigned", "not assigned"])
export function displayValue(value: string | null | undefined): string {
const trimmed = value?.trim()
if (!trimmed || LEGACY_EMPTY_LABELS.has(trimmed) || trimmed === UNASSIGNED_LABEL) {
return UNASSIGNED_LABEL
}
return trimmed
}
export function isUnassignedLabel(value: string | null | undefined): boolean {
const trimmed = value?.trim()
return !trimmed || trimmed === UNASSIGNED_LABEL || LEGACY_EMPTY_LABELS.has(trimmed)
}

50
src/lib/displayValue.tsx Normal file
View File

@ -0,0 +1,50 @@
import type { ReactNode } from "react"
import { cn } from "./utils"
export const UNASSIGNED_LABEL = "unassigned"
/** @deprecated Prefer UNASSIGNED_LABEL */
export const NOT_ASSIGNED_LABEL = UNASSIGNED_LABEL
const LEGACY_EMPTY_LABELS = new Set(["—", "-", "Not assigned", "not assigned"])
export function isUnassignedLabel(value: string | null | undefined): boolean {
const trimmed = value?.trim()
return !trimmed || trimmed === UNASSIGNED_LABEL || LEGACY_EMPTY_LABELS.has(trimmed)
}
export function displayValue(value: string | null | undefined): string {
const trimmed = value?.trim()
if (!trimmed || LEGACY_EMPTY_LABELS.has(trimmed) || trimmed === UNASSIGNED_LABEL) {
return UNASSIGNED_LABEL
}
return trimmed
}
export function UnassignedLabel({ className }: { className?: string }) {
return (
<span className={cn("italic text-grayScale-400", className)}>{UNASSIGNED_LABEL}</span>
)
}
/** Renders a value, or an italic "unassigned" label when empty/missing. */
export function DisplayValue({
value,
className,
unassignedClassName,
}: {
value: string | number | null | undefined
className?: string
unassignedClassName?: string
}): ReactNode {
if (typeof value === "number") {
if (!Number.isFinite(value)) {
return <UnassignedLabel className={unassignedClassName} />
}
return <span className={className}>{value}</span>
}
if (isUnassignedLabel(value)) {
return <UnassignedLabel className={unassignedClassName} />
}
return <span className={className}>{value!.trim()}</span>
}

View File

@ -24,6 +24,7 @@ import { cn } from "../lib/utils";
import type { TeamMeProfile } from "../types/team.types"; import type { TeamMeProfile } from "../types/team.types";
import { ProfileAvatarUpload } from "../components/profile/ProfileAvatarUpload"; import { ProfileAvatarUpload } from "../components/profile/ProfileAvatarUpload";
import { PersonaProfilePictureUploadField } from "./personas/components/PersonaProfilePictureUploadField"; import { PersonaProfilePictureUploadField } from "./personas/components/PersonaProfilePictureUploadField";
import { UnassignedLabel, isUnassignedLabel, DisplayValue } from "../lib/displayValue"
function formatDate(dateStr: string | null | undefined): string { function formatDate(dateStr: string | null | undefined): string {
if (!dateStr) return "unassigned"; if (!dateStr) return "unassigned";
@ -69,7 +70,7 @@ function FieldGroup({
mono, mono,
}: { }: {
label: string; label: string;
value: string; value: React.ReactNode;
mono?: boolean; mono?: boolean;
}) { }) {
return ( return (
@ -81,7 +82,11 @@ function FieldGroup({
mono && "font-mono text-xs", mono && "font-mono text-xs",
)} )}
> >
{value} {typeof value === "string" && isUnassignedLabel(value) ? (
<UnassignedLabel />
) : (
value
)}
</p> </p>
</div> </div>
); );
@ -329,7 +334,7 @@ export function ProfilePage() {
<FieldGroup label="Email address" value={profile.email} /> <FieldGroup label="Email address" value={profile.email} />
<FieldGroup label="Phone" value={profile.phone_number} /> <FieldGroup label="Phone" value={profile.phone_number} />
<div className="sm:col-span-2"> <div className="sm:col-span-2">
<FieldGroup label="Bio" value={displayValue(profile.bio)} /> <FieldGroup label="Bio" value={<DisplayValue value={profile.bio} />} />
</div> </div>
</div> </div>
</SectionCard> </SectionCard>
@ -339,15 +344,15 @@ export function ProfilePage() {
<div className="grid gap-x-8 gap-y-5 sm:grid-cols-2"> <div className="grid gap-x-8 gap-y-5 sm:grid-cols-2">
<FieldGroup <FieldGroup
label="Department" label="Department"
value={displayValue(profile.department)} value={<DisplayValue value={profile.department} />}
/> />
<FieldGroup <FieldGroup
label="Job Title" label="Job Title"
value={displayValue(profile.job_title)} value={<DisplayValue value={profile.job_title} />}
/> />
<FieldGroup <FieldGroup
label="Work Phone" label="Work Phone"
value={displayValue(profile.work_phone)} value={<DisplayValue value={profile.work_phone} />}
/> />
<FieldGroup label="Member ID" value={String(profile.id)} mono /> <FieldGroup label="Member ID" value={String(profile.id)} mono />
</div> </div>

View File

@ -16,6 +16,7 @@ import { Card } from "../../components/ui/card"
import { Input } from "../../components/ui/input" import { Input } from "../../components/ui/input"
import { SpinnerIcon } from "../../components/ui/spinner-icon" import { SpinnerIcon } from "../../components/ui/spinner-icon"
import type { QuestionOption } from "../../types/course.types" import type { QuestionOption } from "../../types/course.types"
import { UnassignedLabel } from "../../lib/displayValue"
type Step = 1 | 2 | 3 | 4 type Step = 1 | 2 | 3 | 4
type QuestionType = "MCQ" | "TRUE_FALSE" | "SHORT" | "AUDIO" | "DYNAMIC" type QuestionType = "MCQ" | "TRUE_FALSE" | "SHORT" | "AUDIO" | "DYNAMIC"
@ -606,16 +607,16 @@ export function AddNewLessonPage() {
<div className="flex items-center justify-between px-4 py-3 text-sm"> <div className="flex items-center justify-between px-4 py-3 text-sm">
<span className="text-grayScale-500">Description</span> <span className="text-grayScale-500">Description</span>
<span className="max-w-[55%] truncate text-right font-medium text-grayScale-800"> <span className="max-w-[55%] truncate text-right font-medium text-grayScale-800">
{lessonDescription || "unassigned"} {lessonDescription || <UnassignedLabel />}
</span> </span>
</div> </div>
<div className="flex items-center justify-between px-4 py-3 text-sm"> <div className="flex items-center justify-between px-4 py-3 text-sm">
<span className="text-grayScale-500">Intro video URL</span> <span className="text-grayScale-500">Intro video URL</span>
<span className="max-w-[55%] truncate text-right font-medium text-grayScale-800">{introVideoUrl || "unassigned"}</span> <span className="max-w-[55%] truncate text-right font-medium text-grayScale-800">{introVideoUrl || <UnassignedLabel />}</span>
</div> </div>
<div className="flex items-center justify-between px-4 py-3 text-sm"> <div className="flex items-center justify-between px-4 py-3 text-sm">
<span className="text-grayScale-500">Sub-module</span> <span className="text-grayScale-500">Sub-module</span>
<span className="font-medium text-grayScale-800">{subModuleId ?? "unassigned"}</span> <span className="font-medium text-grayScale-800">{subModuleId ?? <UnassignedLabel />}</span>
</div> </div>
</div> </div>
</div> </div>

View File

@ -58,6 +58,7 @@ import { AddModuleModal } from "./components/AddModuleModal";
import { ModuleIconUploadField } from "./components/ModuleIconUploadField"; import { ModuleIconUploadField } from "./components/ModuleIconUploadField";
import { ModulePracticeCard } from "./components/ModulePracticeCard"; import { ModulePracticeCard } from "./components/ModulePracticeCard";
import { PublishPracticeButton } from "./components/PublishPracticeButton"; import { PublishPracticeButton } from "./components/PublishPracticeButton";
import { UnassignedLabel } from "../../lib/displayValue"
const MODULE_CARD_GRADIENT = "from-[#8E44AD] to-[#C39BD3]" as const; const MODULE_CARD_GRADIENT = "from-[#8E44AD] to-[#C39BD3]" as const;
@ -787,7 +788,7 @@ export function CourseDetailPage() {
<p className="text-[12px] font-medium leading-snug text-grayScale-400 line-clamp-3"> <p className="text-[12px] font-medium leading-snug text-grayScale-400 line-clamp-3">
{module.description?.trim() {module.description?.trim()
? module.description ? module.description
: "unassigned"} : <UnassignedLabel />}
</p> </p>
</div> </div>
</div> </div>

View File

@ -47,6 +47,7 @@ import { ContentAccessTierChip } from "./components/ContentAccessTierChip";
import { ContentListSearchFilterBar } from "./components/ContentListSearchFilterBar"; import { ContentListSearchFilterBar } from "./components/ContentListSearchFilterBar";
import { ContentPageDescription } from "./components/ContentPageDescription"; import { ContentPageDescription } from "./components/ContentPageDescription";
import type { ContentAccessTier, PracticePublishStatus } from "../../types/course.types"; import type { ContentAccessTier, PracticePublishStatus } from "../../types/course.types";
import { UnassignedLabel } from "../../lib/displayValue"
import { import {
filterBySearchAndPublishStatus, filterBySearchAndPublishStatus,
type PublishStatusFilter, type PublishStatusFilter,
@ -166,7 +167,7 @@ export function CourseManagementPage() {
list.map((row, index) => ({ list.map((row, index) => ({
id: Number(row.id), id: Number(row.id),
name: row.name?.trim() || `Unit ${row.id}`, name: row.name?.trim() || `Unit ${row.id}`,
description: row.description?.trim() || "unassigned", description: row.description?.trim() || <UnassignedLabel />,
thumbnail: row.thumbnail?.trim() || "", thumbnail: row.thumbnail?.trim() || "",
sortOrder: Number(row.sort_order ?? 0), sortOrder: Number(row.sort_order ?? 0),
publishStatus: row.publish_status ?? null, publishStatus: row.publish_status ?? null,

View File

@ -46,6 +46,7 @@ import type {
import { ContentListSearchFilterBar } from "./components/ContentListSearchFilterBar"; import { ContentListSearchFilterBar } from "./components/ContentListSearchFilterBar";
import { ContentPageDescription } from "./components/ContentPageDescription"; import { ContentPageDescription } from "./components/ContentPageDescription";
import { ContentPublishStatusChip } from "./components/ContentPublishStatusChip"; import { ContentPublishStatusChip } from "./components/ContentPublishStatusChip";
import { UnassignedLabel } from "../../lib/displayValue"
import { import {
filterBySearchAndPublishStatus, filterBySearchAndPublishStatus,
type PublishStatusFilter, type PublishStatusFilter,
@ -173,7 +174,7 @@ export function CourseModuleDetailPage() {
const row = list.find((m) => Number(m.id) === parsedModuleId); const row = list.find((m) => Number(m.id) === parsedModuleId);
if (row) { if (row) {
setModuleTitle(row.name?.trim() || `Module ${parsedModuleId}`); setModuleTitle(row.name?.trim() || `Module ${parsedModuleId}`);
setModuleDescription(row.description?.trim() || "unassigned"); setModuleDescription(row.description?.trim() || <UnassignedLabel />);
setModulePublishStatus(row.publish_status ?? null); setModulePublishStatus(row.publish_status ?? null);
} else { } else {
setModuleTitle(`Module ${parsedModuleId}`); setModuleTitle(`Module ${parsedModuleId}`);

View File

@ -41,6 +41,7 @@ import {
import type { CategorySubCategoryListItem, CourseCategory } from "../../types/course.types" import type { CategorySubCategoryListItem, CourseCategory } from "../../types/course.types"
import { cn } from "../../lib/utils" import { cn } from "../../lib/utils"
import { TABLE_PAGE_SIZE_OPTIONS } from "../../lib/tablePagination" import { TABLE_PAGE_SIZE_OPTIONS } from "../../lib/tablePagination"
import { UnassignedLabel } from "../../lib/displayValue"
export function CoursesPage() { export function CoursesPage() {
const { categoryId } = useParams<{ categoryId: string }>() const { categoryId } = useParams<{ categoryId: string }>()
@ -415,7 +416,7 @@ export function CoursesPage() {
</TableCell> </TableCell>
<TableCell> <TableCell>
<p className="max-w-md truncate text-sm text-grayScale-600" title={sub.description || undefined}> <p className="max-w-md truncate text-sm text-grayScale-600" title={sub.description || undefined}>
{sub.description?.trim() ? sub.description : "unassigned"} {sub.description?.trim() ? sub.description : <UnassignedLabel />}
</p> </p>
</TableCell> </TableCell>
<TableCell className="hidden xl:table-cell tabular-nums text-sm text-grayScale-600"> <TableCell className="hidden xl:table-cell tabular-nums text-sm text-grayScale-600">

View File

@ -24,6 +24,7 @@ import {
softDeleteSubModuleLesson, softDeleteSubModuleLesson,
updateSubModuleLesson, updateSubModuleLesson,
} from "../../api/courses.api" } from "../../api/courses.api"
import { UnassignedLabel } from "../../lib/displayValue"
import type { import type {
QuestionSet, QuestionSet,
QuestionSetStatus, QuestionSetStatus,
@ -526,12 +527,12 @@ export function HumanLanguageSubModulePage() {
<TableCell>{questionSetStatusBadge(item.status)}</TableCell> <TableCell>{questionSetStatusBadge(item.status)}</TableCell>
<TableCell> <TableCell>
<p className="max-w-[280px] truncate text-sm text-grayScale-600"> <p className="max-w-[280px] truncate text-sm text-grayScale-600">
{item.description?.trim() ? item.description : "unassigned"} {item.description?.trim() ? item.description : <UnassignedLabel />}
</p> </p>
</TableCell> </TableCell>
<TableCell className="hidden lg:table-cell"> <TableCell className="hidden lg:table-cell">
<p className="max-w-[140px] truncate text-sm text-grayScale-600"> <p className="max-w-[140px] truncate text-sm text-grayScale-600">
{item.persona?.trim() ? item.persona : "unassigned"} {item.persona?.trim() ? item.persona : <UnassignedLabel />}
</p> </p>
</TableCell> </TableCell>
<TableCell className="hidden md:table-cell"> <TableCell className="hidden md:table-cell">
@ -673,7 +674,7 @@ export function HumanLanguageSubModulePage() {
<TableCell>{lessonStatusBadge(lesson.is_active)}</TableCell> <TableCell>{lessonStatusBadge(lesson.is_active)}</TableCell>
<TableCell> <TableCell>
<p className="max-w-[280px] truncate text-sm text-grayScale-600"> <p className="max-w-[280px] truncate text-sm text-grayScale-600">
{lesson.description?.trim() ? lesson.description : "unassigned"} {lesson.description?.trim() ? lesson.description : <UnassignedLabel />}
</p> </p>
</TableCell> </TableCell>
<TableCell className="hidden lg:table-cell"> <TableCell className="hidden lg:table-cell">
@ -985,7 +986,7 @@ export function HumanLanguageSubModulePage() {
</TableCell> </TableCell>
<TableCell> <TableCell>
<p className="max-w-[280px] truncate text-sm text-grayScale-600"> <p className="max-w-[280px] truncate text-sm text-grayScale-600">
{v.description?.trim() ? v.description : "unassigned"} {v.description?.trim() ? v.description : <UnassignedLabel />}
</p> </p>
</TableCell> </TableCell>
<TableCell className="hidden sm:table-cell"> <TableCell className="hidden sm:table-cell">
@ -1031,7 +1032,7 @@ export function HumanLanguageSubModulePage() {
</a> </a>
</Button> </Button>
) : ( ) : (
<span className="text-sm text-grayScale-400">unassigned</span> <span className="text-sm text-grayScale-400"><UnassignedLabel /></span>
)} )}
</TableCell> </TableCell>
</TableRow> </TableRow>

View File

@ -46,6 +46,7 @@ import { Textarea } from "../../components/ui/textarea"
import { ToggleSwitch } from "../../components/ui/toggle-switch" import { ToggleSwitch } from "../../components/ui/toggle-switch"
import { cn } from "../../lib/utils" import { cn } from "../../lib/utils"
import type { QuestionSetDetail } from "../../types/course.types" import type { QuestionSetDetail } from "../../types/course.types"
import { UnassignedLabel } from "../../lib/displayValue"
type TabId = "set" | "questions" | "thresholds" type TabId = "set" | "questions" | "thresholds"
type DraftQuestionType = "MCQ" | "TRUE_FALSE" type DraftQuestionType = "MCQ" | "TRUE_FALSE"
@ -817,13 +818,15 @@ export function InitialAssessmentPage() {
> >
{(() => { {(() => {
const value = String(q.difficultyLevel ?? "").trim() const value = String(q.difficultyLevel ?? "").trim()
if (!value || value === "unassigned" || value === "-") return "unassigned" if (!value || value === "unassigned" || value === "-") {
return <UnassignedLabel />
}
return value.toLowerCase() return value.toLowerCase()
})()} })()}
</span> </span>
</TableCell> </TableCell>
<TableCell className="hidden text-right font-medium text-grayScale-700 lg:table-cell"> <TableCell className="hidden text-right font-medium text-grayScale-700 lg:table-cell">
{Number.isFinite(q.points) ? q.points : "unassigned"} {Number.isFinite(q.points) ? q.points : <UnassignedLabel />}
</TableCell> </TableCell>
<TableCell onClick={(e) => e.stopPropagation()}> <TableCell onClick={(e) => e.stopPropagation()}>
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">

View File

@ -42,6 +42,7 @@ import {
} from "../../lib/contentListFilters"; } from "../../lib/contentListFilters";
import { refreshFileUrl, uploadImageFile } from "../../api/files.api"; import { refreshFileUrl, uploadImageFile } from "../../api/files.api";
import type { LearningProgramListItem } from "../../types/course.types"; import type { LearningProgramListItem } from "../../types/course.types";
import { UnassignedLabel } from "../../lib/displayValue"
/** Presigned MinIO/S3 URLs and our storage hosts — safe to send to POST /files/refresh-url. */ /** Presigned MinIO/S3 URLs and our storage hosts — safe to send to POST /files/refresh-url. */
function looksLikeRefreshableFileUrl(url: string): boolean { function looksLikeRefreshableFileUrl(url: string): boolean {
@ -732,7 +733,7 @@ export function LearnEnglishPage() {
<p className="mt-2 text-sm leading-relaxed text-grayScale-500 line-clamp-4"> <p className="mt-2 text-sm leading-relaxed text-grayScale-500 line-clamp-4">
{program.description?.trim() {program.description?.trim()
? program.description ? program.description
: "unassigned"} : <UnassignedLabel />}
</p> </p>
</div> </div>
<Link <Link

View File

@ -48,6 +48,7 @@ import { ModulePracticeCard } from "./components/ModulePracticeCard";
import { VideoCard } from "./components/VideoCard"; import { VideoCard } from "./components/VideoCard";
import { ContentListSearchFilterBar } from "./components/ContentListSearchFilterBar"; import { ContentListSearchFilterBar } from "./components/ContentListSearchFilterBar";
import { ContentPageDescription } from "./components/ContentPageDescription"; import { ContentPageDescription } from "./components/ContentPageDescription";
import { UnassignedLabel } from "../../lib/displayValue"
import { import {
filterBySearchAndPublishStatus, filterBySearchAndPublishStatus,
type PublishStatusFilter, type PublishStatusFilter,
@ -157,13 +158,13 @@ export function ModuleDetailPage() {
const displayModuleDescription = (() => { const displayModuleDescription = (() => {
if (hasNavName) { if (hasNavName) {
return navState?.moduleDescription?.trim() || "unassigned"; return navState?.moduleDescription?.trim() || <UnassignedLabel />;
} }
if (!moduleListResolved) { if (!moduleListResolved) {
return "Loading…"; return "Loading…";
} }
if (loadedModuleDescription !== null) { if (loadedModuleDescription !== null) {
return loadedModuleDescription.trim() || "unassigned"; return loadedModuleDescription.trim() || <UnassignedLabel />;
} }
return "unassigned"; return "unassigned";
})(); })();

View File

@ -41,6 +41,7 @@ import { CreatePracticeWizard } from "./components/CreatePracticeWizard"
import type { PracticeParentKind } from "../../types/course.types" import type { PracticeParentKind } from "../../types/course.types"
import { cn } from "../../lib/utils" import { cn } from "../../lib/utils"
import { PageBackLink } from "../../components/navigation/PageBackLink" import { PageBackLink } from "../../components/navigation/PageBackLink"
import { UnassignedLabel } from "../../lib/displayValue"
type ParentTab = "course" | "module" | "lesson" type ParentTab = "course" | "module" | "lesson"
@ -994,7 +995,7 @@ export function PracticeDetailsPage() {
<div> <div>
<p className="text-xs font-bold uppercase tracking-wider text-grayScale-500">Story</p> <p className="text-xs font-bold uppercase tracking-wider text-grayScale-500">Story</p>
<p className="mt-1.5 whitespace-pre-wrap text-sm leading-relaxed text-grayScale-700"> <p className="mt-1.5 whitespace-pre-wrap text-sm leading-relaxed text-grayScale-700">
{practice.story_description?.trim() || "unassigned"} {practice.story_description?.trim() || <UnassignedLabel />}
</p> </p>
</div> </div>
{quickTipParts.length > 0 && ( {quickTipParts.length > 0 && (

View File

@ -21,6 +21,7 @@ import { Select } from "../../components/ui/select"
import { Textarea } from "../../components/ui/textarea" import { Textarea } from "../../components/ui/textarea"
import type { PracticeQuestion, QuestionSetQuestion, QuestionDetail } from "../../types/course.types" import type { PracticeQuestion, QuestionSetQuestion, QuestionDetail } from "../../types/course.types"
import { DEFAULT_TABLE_PAGE_SIZE, TABLE_PAGE_SIZE_OPTIONS } from "../../lib/tablePagination" import { DEFAULT_TABLE_PAGE_SIZE, TABLE_PAGE_SIZE_OPTIONS } from "../../lib/tablePagination"
import { UnassignedLabel } from "../../lib/displayValue"
type QuestionType = "MCQ" | "TRUE_FALSE" | "SHORT" | "AUDIO" type QuestionType = "MCQ" | "TRUE_FALSE" | "SHORT" | "AUDIO"
type DifficultyLevel = "EASY" | "MEDIUM" | "HARD" type DifficultyLevel = "EASY" | "MEDIUM" | "HARD"
@ -647,7 +648,7 @@ export function PracticeQuestionsPage() {
Points: {question.points ?? 0} Points: {question.points ?? 0}
</span> </span>
<span className="rounded-md bg-grayScale-100 px-2 py-1"> <span className="rounded-md bg-grayScale-100 px-2 py-1">
Difficulty: {question.difficulty_level || "unassigned"} Difficulty: {question.difficulty_level || <UnassignedLabel />}
</span> </span>
</div> </div>
</div> </div>

View File

@ -46,6 +46,7 @@ import type {
ProgramCourseListItem, ProgramCourseListItem,
} from "../../types/course.types"; } from "../../types/course.types";
import { PublishPracticeButton } from "./components/PublishPracticeButton"; import { PublishPracticeButton } from "./components/PublishPracticeButton";
import { UnassignedLabel } from "../../lib/displayValue"
export function ProgramCoursesPage() { export function ProgramCoursesPage() {
const navigate = useNavigate(); const navigate = useNavigate();
@ -759,7 +760,7 @@ export function ProgramCoursesPage() {
{course.name} {course.name}
</h3> </h3>
<p className="mt-2 text-[13px] leading-relaxed text-grayScale-500 line-clamp-2"> <p className="mt-2 text-[13px] leading-relaxed text-grayScale-500 line-clamp-2">
{course.description?.trim() ? course.description : "unassigned"} {course.description?.trim() ? course.description : <UnassignedLabel />}
</p> </p>
<div className="my-6 grid grid-cols-3 gap-4 border-y border-grayScale-50 py-4"> <div className="my-6 grid grid-cols-3 gap-4 border-y border-grayScale-50 py-4">

View File

@ -44,6 +44,7 @@ import {
} from "../../lib/contentListFilters"; } from "../../lib/contentListFilters";
import { uploadImageFile } from "../../api/files.api"; import { uploadImageFile } from "../../api/files.api";
import uploadIcon from "../../assets/icons/upload.png"; import uploadIcon from "../../assets/icons/upload.png";
import { UnassignedLabel } from "../../lib/displayValue"
export function ProgramDetailPage() { export function ProgramDetailPage() {
const navigate = useNavigate(); const navigate = useNavigate();
@ -116,7 +117,7 @@ export function ProgramDetailPage() {
list.map((row) => ({ list.map((row) => ({
id: Number(row.id), id: Number(row.id),
name: row.name?.trim() || `Course ${row.id}`, name: row.name?.trim() || `Course ${row.id}`,
description: row.description?.trim() || "unassigned", description: row.description?.trim() || <UnassignedLabel />,
thumbnail: row.thumbnail?.trim() || null, thumbnail: row.thumbnail?.trim() || null,
sortOrder: Number(row.sort_order ?? 0), sortOrder: Number(row.sort_order ?? 0),
publishStatus: row.publish_status ?? null, publishStatus: row.publish_status ?? null,
@ -310,7 +311,7 @@ export function ProgramDetailPage() {
{ {
id: row.id, id: row.id,
name: row.name ?? name, name: row.name ?? name,
description: row.description?.trim() || "unassigned", description: row.description?.trim() || <UnassignedLabel />,
thumbnail: row.thumbnail?.trim() || null, thumbnail: row.thumbnail?.trim() || null,
sortOrder: Number(row.sort_order ?? 0), sortOrder: Number(row.sort_order ?? 0),
unitsCount: Number(row.units_count ?? 0), unitsCount: Number(row.units_count ?? 0),
@ -409,7 +410,7 @@ export function ProgramDetailPage() {
? { ? {
...course, ...course,
name: row?.name ?? name, name: row?.name ?? name,
description: row?.description?.trim() || preservedDescription || "unassigned", description: row?.description?.trim() || preservedDescription || <UnassignedLabel />,
thumbnail: row?.thumbnail?.trim() || null, thumbnail: row?.thumbnail?.trim() || null,
sortOrder: Number(row?.sort_order ?? sortOrderNum), sortOrder: Number(row?.sort_order ?? sortOrderNum),
unitsCount: Number(row?.units_count ?? course.unitsCount ?? 0), unitsCount: Number(row?.units_count ?? course.unitsCount ?? 0),

View File

@ -23,6 +23,7 @@ import type { QuestionDetail } from "../../types/course.types"
import { cn } from "../../lib/utils" import { cn } from "../../lib/utils"
import { PageBackLink } from "../../components/navigation/PageBackLink" import { PageBackLink } from "../../components/navigation/PageBackLink"
import { TABLE_PAGE_SIZE_OPTIONS } from "../../lib/tablePagination" import { TABLE_PAGE_SIZE_OPTIONS } from "../../lib/tablePagination"
import { UnassignedLabel } from "../../lib/displayValue"
type QuestionTypeFilter = "all" | "MCQ" | "TRUE_FALSE" | "SHORT_ANSWER" | "AUDIO" type QuestionTypeFilter = "all" | "MCQ" | "TRUE_FALSE" | "SHORT_ANSWER" | "AUDIO"
type DifficultyFilter = "all" | "EASY" | "MEDIUM" | "HARD" type DifficultyFilter = "all" | "EASY" | "MEDIUM" | "HARD"
@ -523,7 +524,7 @@ export function QuestionsPage() {
)} )}
</TableCell> </TableCell>
<TableCell className="hidden py-3.5 text-sm text-grayScale-500 md:table-cell"> <TableCell className="hidden py-3.5 text-sm text-grayScale-500 md:table-cell">
{question.status || "unassigned"} {question.status || <UnassignedLabel />}
</TableCell> </TableCell>
<TableCell className="py-3.5 text-sm font-semibold text-grayScale-600"> <TableCell className="py-3.5 text-sm font-semibold text-grayScale-600">
{question.points ?? 0} {question.points ?? 0}
@ -696,10 +697,10 @@ export function QuestionsPage() {
<div className="grid grid-cols-1 gap-3 text-sm sm:grid-cols-2"> <div className="grid grid-cols-1 gap-3 text-sm sm:grid-cols-2">
<p><span className="font-medium">ID:</span> {detailData.id}</p> <p><span className="font-medium">ID:</span> {detailData.id}</p>
<p><span className="font-medium">Type:</span> {typeLabels[detailData.question_type] || detailData.question_type}</p> <p><span className="font-medium">Type:</span> {typeLabels[detailData.question_type] || detailData.question_type}</p>
<p><span className="font-medium">Difficulty:</span> {detailData.difficulty_level || "unassigned"}</p> <p><span className="font-medium">Difficulty:</span> {detailData.difficulty_level || <UnassignedLabel />}</p>
<p><span className="font-medium">Points:</span> {detailData.points ?? 0}</p> <p><span className="font-medium">Points:</span> {detailData.points ?? 0}</p>
<p><span className="font-medium">Status:</span> {detailData.status || "unassigned"}</p> <p><span className="font-medium">Status:</span> {detailData.status || <UnassignedLabel />}</p>
<p><span className="font-medium">Created:</span> {detailData.created_at || "unassigned"}</p> <p><span className="font-medium">Created:</span> {detailData.created_at || <UnassignedLabel />}</p>
</div> </div>
{detailData.explanation ? ( {detailData.explanation ? (
<div> <div>
@ -755,7 +756,7 @@ export function QuestionsPage() {
: (answer as { acceptable_answer?: string }).acceptable_answer || "" : (answer as { acceptable_answer?: string }).acceptable_answer || ""
return ( return (
<p key={`${value}-${index}`} className="rounded-md border border-grayScale-200 bg-grayScale-50 px-2 py-1"> <p key={`${value}-${index}`} className="rounded-md border border-grayScale-200 bg-grayScale-50 px-2 py-1">
{value || "unassigned"} {value || <UnassignedLabel />}
</p> </p>
) )
})} })}

View File

@ -38,6 +38,7 @@ import { toast } from "sonner"
import { countActiveFilters } from "../../lib/adminFilterUtils" import { countActiveFilters } from "../../lib/adminFilterUtils"
import { fetchAllOffsetPages } from "../../lib/fetchAllOffsetPages" import { fetchAllOffsetPages } from "../../lib/fetchAllOffsetPages"
import { DEFAULT_TABLE_PAGE_SIZE, TABLE_PAGE_SIZE_OPTIONS } from "../../lib/tablePagination" import { DEFAULT_TABLE_PAGE_SIZE, TABLE_PAGE_SIZE_OPTIONS } from "../../lib/tablePagination"
import { UnassignedLabel } from "../../lib/displayValue"
const MAX_AUDIO_SIZE_BYTES = 50 * 1024 * 1024 const MAX_AUDIO_SIZE_BYTES = 50 * 1024 * 1024
const ALLOWED_AUDIO_EXTENSIONS = new Set(["mp3", "wav", "ogg", "m4a", "aac", "webm", "flac"]) const ALLOWED_AUDIO_EXTENSIONS = new Set(["mp3", "wav", "ogg", "m4a", "aac", "webm", "flac"])
@ -1275,7 +1276,7 @@ export function SpeakingPage() {
const groupedAudioQuestions = useMemo(() => { const groupedAudioQuestions = useMemo(() => {
const groups = new Map<string, { practiceId: number | null; practiceTitle: string; questions: AudioListQuestion[] }>() const groups = new Map<string, { practiceId: number | null; practiceTitle: string; questions: AudioListQuestion[] }>()
for (const q of audioQuestions) { for (const q of audioQuestions) {
const key = q.practice_id ? String(q.practice_id) : "unassigned" const key = q.practice_id ? String(q.practice_id) : <UnassignedLabel />
const title = q.practice_title || "Unknown practice" const title = q.practice_title || "Unknown practice"
if (!groups.has(key)) { if (!groups.has(key)) {
groups.set(key, { practiceId: q.practice_id, practiceTitle: title, questions: [] }) groups.set(key, { practiceId: q.practice_id, practiceTitle: title, questions: [] })
@ -1498,13 +1499,13 @@ export function SpeakingPage() {
<div className="mt-2 flex flex-wrap items-center gap-2 text-xs"> <div className="mt-2 flex flex-wrap items-center gap-2 text-xs">
<span className="rounded-md bg-brand-100 px-2 py-0.5 font-medium text-brand-800">AUDIO</span> <span className="rounded-md bg-brand-100 px-2 py-0.5 font-medium text-brand-800">AUDIO</span>
<span className="rounded-md bg-grayScale-100 px-2 py-1 text-grayScale-600"> <span className="rounded-md bg-grayScale-100 px-2 py-1 text-grayScale-600">
Difficulty: {question.difficulty_level || "unassigned"} Difficulty: {question.difficulty_level || <UnassignedLabel />}
</span> </span>
<span className="rounded-md bg-grayScale-100 px-2 py-1 text-grayScale-600"> <span className="rounded-md bg-grayScale-100 px-2 py-1 text-grayScale-600">
Points: {question.points ?? 0} Points: {question.points ?? 0}
</span> </span>
<span className="rounded-md bg-grayScale-100 px-2 py-1 text-grayScale-600"> <span className="rounded-md bg-grayScale-100 px-2 py-1 text-grayScale-600">
Status: {question.status || "unassigned"} Status: {question.status || <UnassignedLabel />}
</span> </span>
</div> </div>
{question.image_url && imagePreviewByQuestionId[question.id] ? ( {question.image_url && imagePreviewByQuestionId[question.id] ? (
@ -1788,19 +1789,19 @@ export function SpeakingPage() {
<div className="grid grid-cols-1 gap-3 text-sm sm:grid-cols-2"> <div className="grid grid-cols-1 gap-3 text-sm sm:grid-cols-2">
<div> <div>
<p className="text-xs font-medium text-grayScale-500">Status</p> <p className="text-xs font-medium text-grayScale-500">Status</p>
<p className="mt-1 text-grayScale-700">{selectedQuestionDetail.status || "unassigned"}</p> <p className="mt-1 text-grayScale-700">{selectedQuestionDetail.status || <UnassignedLabel />}</p>
</div> </div>
<div> <div>
<p className="text-xs font-medium text-grayScale-500">Points</p> <p className="text-xs font-medium text-grayScale-500">Points</p>
<p className="mt-1 text-grayScale-700">{selectedQuestionDetail.points ?? "unassigned"}</p> <p className="mt-1 text-grayScale-700">{selectedQuestionDetail.points ?? <UnassignedLabel />}</p>
</div> </div>
<div> <div>
<p className="text-xs font-medium text-grayScale-500">Difficulty</p> <p className="text-xs font-medium text-grayScale-500">Difficulty</p>
<p className="mt-1 text-grayScale-700">{selectedQuestionDetail.difficulty_level || "unassigned"}</p> <p className="mt-1 text-grayScale-700">{selectedQuestionDetail.difficulty_level || <UnassignedLabel />}</p>
</div> </div>
<div> <div>
<p className="text-xs font-medium text-grayScale-500">Type</p> <p className="text-xs font-medium text-grayScale-500">Type</p>
<p className="mt-1 text-grayScale-700">{selectedQuestionDetail.question_type || "unassigned"}</p> <p className="mt-1 text-grayScale-700">{selectedQuestionDetail.question_type || <UnassignedLabel />}</p>
</div> </div>
</div> </div>
{selectedQuestionDetail.audio_correct_answer_text ? ( {selectedQuestionDetail.audio_correct_answer_text ? (
@ -2440,11 +2441,11 @@ export function SpeakingPage() {
<div className="rounded-xl border border-grayScale-200 bg-white p-5 shadow-sm"> <div className="rounded-xl border border-grayScale-200 bg-white p-5 shadow-sm">
<h3 className="mb-3 text-sm font-semibold uppercase tracking-wide text-grayScale-500">Practice</h3> <h3 className="mb-3 text-sm font-semibold uppercase tracking-wide text-grayScale-500">Practice</h3>
<div className="grid grid-cols-1 gap-3 text-sm text-grayScale-600 sm:grid-cols-2"> <div className="grid grid-cols-1 gap-3 text-sm text-grayScale-600 sm:grid-cols-2">
<p><span className="font-medium">Title:</span> {setTitle || "unassigned"}</p> <p><span className="font-medium">Title:</span> {setTitle || <UnassignedLabel />}</p>
<p><span className="font-medium">Course ID:</span> {subCourseId || "unassigned"}</p> <p><span className="font-medium">Course ID:</span> {subCourseId || <UnassignedLabel />}</p>
<p className="sm:col-span-2"><span className="font-medium">Description:</span> {setDescription || "unassigned"}</p> <p className="sm:col-span-2"><span className="font-medium">Description:</span> {setDescription || <UnassignedLabel />}</p>
<p className="sm:col-span-2 break-all"> <p className="sm:col-span-2 break-all">
<span className="font-medium">Intro video URL:</span> {introVideoUrl.trim() || "unassigned"} <span className="font-medium">Intro video URL:</span> {introVideoUrl.trim() || <UnassignedLabel />}
</p> </p>
<p><span className="font-medium">Status:</span> {setStatus}</p> <p><span className="font-medium">Status:</span> {setStatus}</p>
</div> </div>
@ -2467,27 +2468,27 @@ export function SpeakingPage() {
<p><span className="font-medium text-grayScale-700">Status:</span> {setStatus}</p> <p><span className="font-medium text-grayScale-700">Status:</span> {setStatus}</p>
<p className="sm:col-span-2"> <p className="sm:col-span-2">
<span className="font-medium text-grayScale-700">Voice Prompt:</span>{" "} <span className="font-medium text-grayScale-700">Voice Prompt:</span>{" "}
{draft.voicePrompt.trim() || "unassigned"} {draft.voicePrompt.trim() || <UnassignedLabel />}
</p> </p>
<p className="sm:col-span-2"> <p className="sm:col-span-2">
<span className="font-medium text-grayScale-700">Sample Answer Voice Prompt:</span>{" "} <span className="font-medium text-grayScale-700">Sample Answer Voice Prompt:</span>{" "}
{draft.sampleAnswerVoicePrompt.trim() || "unassigned"} {draft.sampleAnswerVoicePrompt.trim() || <UnassignedLabel />}
</p> </p>
<p className="sm:col-span-2"> <p className="sm:col-span-2">
<span className="font-medium text-grayScale-700">Image URL:</span>{" "} <span className="font-medium text-grayScale-700">Image URL:</span>{" "}
{draft.imageUrl.trim() || "unassigned"} {draft.imageUrl.trim() || <UnassignedLabel />}
</p> </p>
<p className="sm:col-span-2"> <p className="sm:col-span-2">
<span className="font-medium text-grayScale-700">Audio Correct Answer Text:</span>{" "} <span className="font-medium text-grayScale-700">Audio Correct Answer Text:</span>{" "}
{draft.audioCorrectAnswerText.trim() || "unassigned"} {draft.audioCorrectAnswerText.trim() || <UnassignedLabel />}
</p> </p>
<p className="sm:col-span-2"> <p className="sm:col-span-2">
<span className="font-medium text-grayScale-700">Tips:</span>{" "} <span className="font-medium text-grayScale-700">Tips:</span>{" "}
{draft.tips.trim() || "unassigned"} {draft.tips.trim() || <UnassignedLabel />}
</p> </p>
<p className="sm:col-span-2"> <p className="sm:col-span-2">
<span className="font-medium text-grayScale-700">Explanation:</span>{" "} <span className="font-medium text-grayScale-700">Explanation:</span>{" "}
{draft.explanation.trim() || "unassigned"} {draft.explanation.trim() || <UnassignedLabel />}
</p> </p>
</div> </div>
<div className="mt-2 flex flex-wrap gap-3"> <div className="mt-2 flex flex-wrap gap-3">

View File

@ -32,6 +32,7 @@ import type {
} from "../../types/course.types" } from "../../types/course.types"
import type { Rating } from "../../types/ratings.types" import type { Rating } from "../../types/ratings.types"
import { SpinnerIcon } from "../../components/ui/spinner-icon" import { SpinnerIcon } from "../../components/ui/spinner-icon"
import { UnassignedLabel } from "../../lib/displayValue"
type TabType = "video" | "practice" | "ratings" type TabType = "video" | "practice" | "ratings"
type StatusFilter = "all" | "published" | "draft" | "archived" type StatusFilter = "all" | "published" | "draft" | "archived"
@ -625,7 +626,7 @@ export function SubModuleContentPage() {
day: "numeric", day: "numeric",
year: "numeric", year: "numeric",
}) })
: "unassigned"} : <UnassignedLabel />}
</span> </span>
<div className="flex gap-0.5" onClick={(e) => e.stopPropagation()}> <div className="flex gap-0.5" onClick={(e) => e.stopPropagation()}>
<button <button

View File

@ -50,6 +50,7 @@ import {
import { PracticeActionButton } from "./components/PracticeActionButton"; import { PracticeActionButton } from "./components/PracticeActionButton";
import { UnitPracticesPanel } from "./components/UnitPracticesPanel"; import { UnitPracticesPanel } from "./components/UnitPracticesPanel";
import { cn } from "../../lib/utils"; import { cn } from "../../lib/utils";
import { UnassignedLabel } from "../../lib/displayValue"
export function UnitManagementPage() { export function UnitManagementPage() {
const navigate = useNavigate(); const navigate = useNavigate();
@ -209,7 +210,7 @@ export function UnitManagementPage() {
list.map((row, index) => ({ list.map((row, index) => ({
id: Number(row.id), id: Number(row.id),
name: row.name?.trim() || `Module ${row.id}`, name: row.name?.trim() || `Module ${row.id}`,
description: row.description?.trim() || "unassigned", description: row.description?.trim() || <UnassignedLabel />,
thumbnail: row.thumbnail?.trim() || "", thumbnail: row.thumbnail?.trim() || "",
icon: row.icon?.trim() || "", icon: row.icon?.trim() || "",
sortOrder: Number(row.sort_order ?? 0), sortOrder: Number(row.sort_order ?? 0),

View File

@ -3,6 +3,7 @@ import { Badge } from "../../../components/ui/badge"
import { Card } from "../../../components/ui/card" import { Card } from "../../../components/ui/card"
import { Button } from "../../../components/ui/button" import { Button } from "../../../components/ui/button"
import { cn } from "../../../lib/utils" import { cn } from "../../../lib/utils"
import { UnassignedLabel, isUnassignedLabel } from "../../../lib/displayValue"
export interface QuestionTypeDefinitionCardModel { export interface QuestionTypeDefinitionCardModel {
id: number id: number
@ -70,7 +71,7 @@ export function QuestionTypeCard({
isActive ? "bg-[#F0FDF4] text-[#16A34A]" : "bg-grayScale-50 text-grayScale-600", isActive ? "bg-[#F0FDF4] text-[#16A34A]" : "bg-grayScale-50 text-grayScale-600",
)} )}
> >
{statusLabel} {isUnassignedLabel(statusLabel) ? <UnassignedLabel /> : statusLabel}
</Badge> </Badge>
<div className="flex items-center gap-1"> <div className="flex items-center gap-1">
{onCreatePractice ? ( {onCreatePractice ? (

View File

@ -21,6 +21,7 @@ import {
isQuestionTypeDefinitionPracticeUnlinked, isQuestionTypeDefinitionPracticeUnlinked,
} from "../../../lib/questionTypeDefinitionPractices" } from "../../../lib/questionTypeDefinitionPractices"
import { DEFAULT_TABLE_PAGE_SIZE, TABLE_PAGE_SIZE_OPTIONS } from "../../../lib/tablePagination" import { DEFAULT_TABLE_PAGE_SIZE, TABLE_PAGE_SIZE_OPTIONS } from "../../../lib/tablePagination"
import { UnassignedLabel } from "../../../lib/displayValue"
import type { import type {
QuestionTypeDefinition, QuestionTypeDefinition,
QuestionTypeDefinitionPractice, QuestionTypeDefinitionPractice,
@ -234,7 +235,7 @@ export function QuestionTypeDefinitionPracticesDialog({
publishStatusClass(practice.publish_status), publishStatusClass(practice.publish_status),
)} )}
> >
{practice.publish_status || "unassigned"} {practice.publish_status || <UnassignedLabel />}
</Badge> </Badge>
<Badge variant="secondary" className="font-mono text-[10px] uppercase tracking-wider"> <Badge variant="secondary" className="font-mono text-[10px] uppercase tracking-wider">
{practice.matching_question_count} matching question {practice.matching_question_count} matching question

View File

@ -4,6 +4,7 @@ import { PersonaAvatar } from "../../../../components/personas/PersonaAvatar";
import { Button } from "../../../../components/ui/button"; import { Button } from "../../../../components/ui/button";
import { Card } from "../../../../components/ui/card"; import { Card } from "../../../../components/ui/card";
import { cn } from "../../../../lib/utils"; import { cn } from "../../../../lib/utils";
import { UnassignedLabel, isUnassignedLabel } from "../../../../lib/displayValue"
export type PracticeReviewQuestion = { export type PracticeReviewQuestion = {
id: string; id: string;
@ -278,7 +279,7 @@ export function PracticeSequentialReview({
</div> </div>
<div className="rounded-xl border border-grayScale-200 bg-white px-5 py-4 shadow-sm"> <div className="rounded-xl border border-grayScale-200 bg-white px-5 py-4 shadow-sm">
<p className="text-sm leading-relaxed text-grayScale-600"> <p className="text-sm leading-relaxed text-grayScale-600">
{guidanceText.trim() || "unassigned"} {isUnassignedLabel(guidanceText) ? <UnassignedLabel /> : guidanceText}
</p> </p>
</div> </div>
</div> </div>
@ -303,7 +304,7 @@ export function PracticeSequentialReview({
Text prompt Text prompt
</p> </p>
<p className="text-sm leading-relaxed text-grayScale-800"> <p className="text-sm leading-relaxed text-grayScale-800">
{question.questionText.trim() || "unassigned"} {question.questionText.trim() || <UnassignedLabel />}
</p> </p>
</div> </div>
{question.voicePrompt.trim() ? ( {question.voicePrompt.trim() ? (
@ -358,7 +359,7 @@ export function PracticeSequentialReview({
/> />
</div> </div>
) : ( ) : (
<p className="text-xs text-grayScale-400">unassigned</p> <p className="text-xs text-grayScale-400"><UnassignedLabel /></p>
)} )}
</div> </div>
))} ))}

View File

@ -13,6 +13,7 @@ import { DEFAULT_TABLE_PAGE_SIZE, TABLE_PAGE_SIZE_OPTIONS } from "../../../../li
import type { ParentContextPractice, PracticeParent } from "../../../../types/course.types" import type { ParentContextPractice, PracticeParent } from "../../../../types/course.types"
import { cn } from "../../../../lib/utils" import { cn } from "../../../../lib/utils"
import { SearchHighlight, getSearchTokens } from "../../../../components/SearchHighlight" import { SearchHighlight, getSearchTokens } from "../../../../components/SearchHighlight"
import { UnassignedLabel } from "../../../../lib/displayValue"
interface SelectPracticeToAttachStepProps { interface SelectPracticeToAttachStepProps {
targetParent: PracticeParent targetParent: PracticeParent
@ -254,7 +255,11 @@ export function SelectPracticeToAttachStep({
publishStatusClass(practice.publish_status), publishStatusClass(practice.publish_status),
)} )}
> >
{(practice.publish_status || "unassigned").toString()} {practice.publish_status?.trim() ? (
practice.publish_status
) : (
<UnassignedLabel />
)}
</span> </span>
{alreadyLinked ? ( {alreadyLinked ? (
<span className="text-[11px] font-semibold text-brand-600"> <span className="text-[11px] font-semibold text-brand-600">

View File

@ -20,6 +20,7 @@ import {
} from "../../lib/questionTypeDefinitionValidation" } from "../../lib/questionTypeDefinitionValidation"
import { slotLabel } from "./componentKindUi" import { slotLabel } from "./componentKindUi"
import { questionTypeGroupLabels } from "../../../../lib/questionTypeGroupIds" import { questionTypeGroupLabels } from "../../../../lib/questionTypeGroupIds"
import { UnassignedLabel } from "../../../../lib/displayValue"
interface QuestionTypeReviewPublishStepProps { interface QuestionTypeReviewPublishStepProps {
draft: QuestionTypeDefinitionCreatePayload draft: QuestionTypeDefinitionCreatePayload
@ -131,11 +132,11 @@ export function QuestionTypeReviewPublishStep({
</div> </div>
<div className="sm:col-span-2"> <div className="sm:col-span-2">
<dt className="text-grayScale-400 font-semibold uppercase text-[11px] tracking-wide">Description</dt> <dt className="text-grayScale-400 font-semibold uppercase text-[11px] tracking-wide">Description</dt>
<dd className="font-medium text-grayScale-800 dark:text-grayScale-500 mt-1">{payload.description || "unassigned"}</dd> <dd className="font-medium text-grayScale-800 dark:text-grayScale-500 mt-1">{payload.description || <UnassignedLabel />}</dd>
</div> </div>
<div> <div>
<dt className="text-grayScale-400 font-semibold uppercase text-[11px] tracking-wide">Groups</dt> <dt className="text-grayScale-400 font-semibold uppercase text-[11px] tracking-wide">Groups</dt>
<dd className="font-medium text-grayScale-900 dark:text-grayScale-600 mt-1">{groupName || "unassigned"}</dd> <dd className="font-medium text-grayScale-900 dark:text-grayScale-600 mt-1">{groupName || <UnassignedLabel />}</dd>
</div> </div>
<div> <div>
<dt className="text-grayScale-400 font-semibold uppercase text-[11px] tracking-wide">Status</dt> <dt className="text-grayScale-400 font-semibold uppercase text-[11px] tracking-wide">Status</dt>
@ -143,15 +144,15 @@ export function QuestionTypeReviewPublishStep({
</div> </div>
<div> <div>
<dt className="text-grayScale-400 font-semibold uppercase text-[11px] tracking-wide">Runtime type</dt> <dt className="text-grayScale-400 font-semibold uppercase text-[11px] tracking-wide">Runtime type</dt>
<dd className="font-medium text-grayScale-900 dark:text-grayScale-600 mt-1">{runtime ?? "unassigned"}</dd> <dd className="font-medium text-grayScale-900 dark:text-grayScale-600 mt-1">{runtime ?? <UnassignedLabel />}</dd>
</div> </div>
<div> <div>
<dt className="text-grayScale-400 font-semibold uppercase text-[11px] tracking-wide">Stimulus kinds</dt> <dt className="text-grayScale-400 font-semibold uppercase text-[11px] tracking-wide">Stimulus kinds</dt>
<dd className="font-medium text-grayScale-900 dark:text-grayScale-600 mt-1">{payload.stimulus_component_kinds.join(", ") || "unassigned"}</dd> <dd className="font-medium text-grayScale-900 dark:text-grayScale-600 mt-1">{payload.stimulus_component_kinds.join(", ") || <UnassignedLabel />}</dd>
</div> </div>
<div> <div>
<dt className="text-grayScale-400 font-semibold uppercase text-[11px] tracking-wide">Response kinds</dt> <dt className="text-grayScale-400 font-semibold uppercase text-[11px] tracking-wide">Response kinds</dt>
<dd className="font-medium text-grayScale-900 dark:text-grayScale-600 mt-1">{payload.response_component_kinds.join(", ") || "unassigned"}</dd> <dd className="font-medium text-grayScale-900 dark:text-grayScale-600 mt-1">{payload.response_component_kinds.join(", ") || <UnassignedLabel />}</dd>
</div> </div>
</dl> </dl>

View File

@ -11,6 +11,7 @@ import {
} from "../../lib/questionTypeDefinitionValidation" } from "../../lib/questionTypeDefinitionValidation"
import { DefinitionRuntimeHint } from "./DefinitionRuntimeHint" import { DefinitionRuntimeHint } from "./DefinitionRuntimeHint"
import { QuestionTypeStepFooter } from "./QuestionTypeStepFooter" import { QuestionTypeStepFooter } from "./QuestionTypeStepFooter"
import { UnassignedLabel } from "../../../../lib/displayValue"
interface QuestionTypeValidatePreviewStepProps { interface QuestionTypeValidatePreviewStepProps {
draft: QuestionTypeDefinitionCreatePayload draft: QuestionTypeDefinitionCreatePayload
@ -118,13 +119,13 @@ export function QuestionTypeValidatePreviewStep({
<div> <div>
<dt className="text-[11px] font-bold uppercase text-grayScale-400">Stimulus kinds</dt> <dt className="text-[11px] font-bold uppercase text-grayScale-400">Stimulus kinds</dt>
<dd className="mt-1 font-medium text-grayScale-800"> <dd className="mt-1 font-medium text-grayScale-800">
{payload.stimulus_component_kinds.join(", ") || "unassigned"} {payload.stimulus_component_kinds.join(", ") || <UnassignedLabel />}
</dd> </dd>
</div> </div>
<div> <div>
<dt className="text-[11px] font-bold uppercase text-grayScale-400">Response kinds</dt> <dt className="text-[11px] font-bold uppercase text-grayScale-400">Response kinds</dt>
<dd className="mt-1 font-medium text-grayScale-800"> <dd className="mt-1 font-medium text-grayScale-800">
{payload.response_component_kinds.join(", ") || "unassigned"} {payload.response_component_kinds.join(", ") || <UnassignedLabel />}
</dd> </dd>
</div> </div>
<div> <div>
@ -132,7 +133,7 @@ export function QuestionTypeValidatePreviewStep({
<dd className="mt-1 font-medium text-grayScale-800"> <dd className="mt-1 font-medium text-grayScale-800">
{payload.stimulus_schema.length {payload.stimulus_schema.length
? payload.stimulus_schema.map((r) => r.label).join(" · ") ? payload.stimulus_schema.map((r) => r.label).join(" · ")
: "unassigned"} : <UnassignedLabel />}
</dd> </dd>
</div> </div>
<div> <div>
@ -140,7 +141,7 @@ export function QuestionTypeValidatePreviewStep({
<dd className="mt-1 font-medium text-grayScale-800"> <dd className="mt-1 font-medium text-grayScale-800">
{payload.response_schema.length {payload.response_schema.length
? payload.response_schema.map((r) => r.label).join(" · ") ? payload.response_schema.map((r) => r.label).join(" · ")
: "unassigned"} : <UnassignedLabel />}
</dd> </dd>
</div> </div>
</dl> </dl>

View File

@ -11,6 +11,7 @@ import {
resolveThumbnailForPreview, resolveThumbnailForPreview,
} from "../../../../lib/videoPreview"; } from "../../../../lib/videoPreview";
import { PreviewLimitedFileVideo } from "../PreviewLimitedFileVideo"; import { PreviewLimitedFileVideo } from "../PreviewLimitedFileVideo";
import { UnassignedLabel } from "../../../../lib/displayValue"
interface ReviewPublishStepProps { interface ReviewPublishStepProps {
formData: AddLessonFormData; formData: AddLessonFormData;
@ -115,7 +116,7 @@ export function ReviewPublishStep({
</div> </div>
</div> </div>
) : ( ) : (
<p className="text-grayScale-400 text-sm">unassigned</p> <p className="text-grayScale-400 text-sm"><UnassignedLabel /></p>
)} )}
</div> </div>
@ -148,7 +149,7 @@ export function ReviewPublishStep({
</p> </p>
</div> </div>
) : ( ) : (
<p className="text-grayScale-400 text-sm">unassigned</p> <p className="text-grayScale-400 text-sm"><UnassignedLabel /></p>
)} )}
</div> </div>
</div> </div>
@ -176,7 +177,7 @@ export function ReviewPublishStep({
Title Title
</span> </span>
<p className="text-[15px] font-medium text-grayScale-900"> <p className="text-[15px] font-medium text-grayScale-900">
{formData.title || "unassigned"} {formData.title || <UnassignedLabel />}
</p> </p>
</div> </div>
@ -187,7 +188,7 @@ export function ReviewPublishStep({
<p className="text-[15px] font-medium text-grayScale-900"> <p className="text-[15px] font-medium text-grayScale-900">
{formData.sortOrder.trim() !== "" {formData.sortOrder.trim() !== ""
? formData.sortOrder.trim() ? formData.sortOrder.trim()
: "unassigned"} : <UnassignedLabel />}
</p> </p>
</div> </div>
@ -199,7 +200,8 @@ export function ReviewPublishStep({
className="text-[14px] text-grayScale-600 leading-relaxed max-w-4xl" className="text-[14px] text-grayScale-600 leading-relaxed max-w-4xl"
dangerouslySetInnerHTML={{ dangerouslySetInnerHTML={{
__html: __html:
formData.description || "<p class='text-grayScale-400'>unassigned</p>", formData.description ||
"<p class='text-grayScale-400 italic'>unassigned</p>",
}} }}
/> />
</div> </div>

View File

@ -48,6 +48,7 @@ import { CreateFaqDialog } from "./components/CreateFaqDialog"
import { FaqDeleteDialog } from "./components/FaqDeleteDialog" import { FaqDeleteDialog } from "./components/FaqDeleteDialog"
import { FaqAccessDenied } from "./components/FaqAccessDenied" import { FaqAccessDenied } from "./components/FaqAccessDenied"
import { FaqPublicPreviewDialog } from "./components/FaqPublicPreviewDialog" import { FaqPublicPreviewDialog } from "./components/FaqPublicPreviewDialog"
import { UnassignedLabel } from "../../lib/displayValue"
type StatusFilter = "all" | FAQStatus type StatusFilter = "all" | FAQStatus
@ -339,7 +340,7 @@ export function FaqsPage() {
{faq.category ? ( {faq.category ? (
<Badge variant="secondary">{faq.category}</Badge> <Badge variant="secondary">{faq.category}</Badge>
) : ( ) : (
<span className="text-xs text-grayScale-400">unassigned</span> <span className="text-xs text-grayScale-400"><UnassignedLabel /></span>
)} )}
</TableCell> </TableCell>
<TableCell className="text-center text-sm text-grayScale-600"> <TableCell className="text-center text-sm text-grayScale-600">

View File

@ -2,6 +2,7 @@ import { Button } from "../../../components/ui/button"
import { Input } from "../../../components/ui/input" import { Input } from "../../../components/ui/input"
import { Textarea } from "../../../components/ui/textarea" import { Textarea } from "../../../components/ui/textarea"
import type { FAQStatus } from "../../../types/faq.types" import type { FAQStatus } from "../../../types/faq.types"
import { UnassignedLabel } from "../../../lib/displayValue"
export type FaqFormDraft = { export type FaqFormDraft = {
question: string question: string
@ -127,10 +128,10 @@ export function FaqForm({
Preview Preview
</p> </p>
<p className="mt-2 text-sm font-medium text-grayScale-900"> <p className="mt-2 text-sm font-medium text-grayScale-900">
{draft.question || "unassigned"} {draft.question || <UnassignedLabel />}
</p> </p>
<p className="mt-1 whitespace-pre-wrap text-xs leading-relaxed text-grayScale-600"> <p className="mt-1 whitespace-pre-wrap text-xs leading-relaxed text-grayScale-600">
{draft.answer || "unassigned"} {draft.answer || <UnassignedLabel />}
</p> </p>
{(draft.category || draft.display_order) && ( {(draft.category || draft.display_order) && (
<div className="mt-2.5 flex items-center gap-2 text-[11px] text-grayScale-400"> <div className="mt-2.5 flex items-center gap-2 text-[11px] text-grayScale-400">
@ -149,10 +150,10 @@ export function FaqForm({
Preview Preview
</p> </p>
<p className="mt-2 text-sm font-medium text-grayScale-900"> <p className="mt-2 text-sm font-medium text-grayScale-900">
{draft.question || "unassigned"} {draft.question || <UnassignedLabel />}
</p> </p>
<p className="mt-1 whitespace-pre-wrap text-xs leading-relaxed text-grayScale-600"> <p className="mt-1 whitespace-pre-wrap text-xs leading-relaxed text-grayScale-600">
{draft.answer || "unassigned"} {draft.answer || <UnassignedLabel />}
</p> </p>
{(draft.category || draft.display_order) && ( {(draft.category || draft.display_order) && (
<div className="mt-2.5 flex items-center gap-2 text-[11px] text-grayScale-400"> <div className="mt-2.5 flex items-center gap-2 text-[11px] text-grayScale-400">

View File

@ -51,6 +51,7 @@ import {
createIssue, createIssue,
} from "../../api/issues.api"; } from "../../api/issues.api";
import type { Issue } from "../../types/issue.types"; import type { Issue } from "../../types/issue.types";
import { UnassignedLabel } from "../../lib/displayValue"
// ── Status configuration ─────────────────────────────────────────── // ── Status configuration ───────────────────────────────────────────
const STATUSES = ["pending", "in_progress", "resolved", "rejected"] as const; const STATUSES = ["pending", "in_progress", "resolved", "rejected"] as const;
@ -532,7 +533,7 @@ export function IssuesPage() {
</div> </div>
<div className="min-w-0"> <div className="min-w-0">
<p className="text-sm font-medium text-grayScale-600 truncate"> <p className="text-sm font-medium text-grayScale-600 truncate">
{issue.subject?.trim() ? issue.subject : "unassigned"} {issue.subject?.trim() ? issue.subject : <UnassignedLabel />}
</p> </p>
<p className="text-xs text-grayScale-400 truncate mt-0.5"> <p className="text-xs text-grayScale-400 truncate mt-0.5">
{issue.description?.trim() ? issue.description : "No description"} {issue.description?.trim() ? issue.description : "No description"}

View File

@ -32,6 +32,7 @@ import { cn } from "../../lib/utils"
import { import {
DEFAULT_TABLE_PAGE_SIZE, DEFAULT_TABLE_PAGE_SIZE,
} from "../../lib/tablePagination" } from "../../lib/tablePagination"
import { UnassignedLabel } from "../../lib/displayValue"
import { import {
getNotificationMessage, getNotificationMessage,
getNotificationTitle, getNotificationTitle,
@ -72,7 +73,7 @@ function recipientLabel(notification: Notification): string {
if (notification.reciever) { if (notification.reciever) {
parts.push(notification.reciever) parts.push(notification.reciever)
} }
return parts.length > 0 ? parts.join(" · ") : "unassigned" return parts.length > 0 ? parts.join(" · ") : <UnassignedLabel />
} }
export function AllNotificationsPage() { export function AllNotificationsPage() {
@ -355,14 +356,14 @@ export function AllNotificationsPage() {
</TableCell> </TableCell>
<TableCell className="max-w-[260px]"> <TableCell className="max-w-[260px]">
<p className="truncate text-sm font-medium text-grayScale-700"> <p className="truncate text-sm font-medium text-grayScale-700">
{getNotificationTitle(notification) || "unassigned"} {getNotificationTitle(notification) || <UnassignedLabel />}
</p> </p>
<p className="truncate text-xs text-grayScale-400"> <p className="truncate text-xs text-grayScale-400">
{getNotificationMessage(notification) || "unassigned"} {getNotificationMessage(notification) || <UnassignedLabel />}
</p> </p>
</TableCell> </TableCell>
<TableCell className="text-xs capitalize text-grayScale-600"> <TableCell className="text-xs capitalize text-grayScale-600">
{channelLabel(notification.delivery_channel) || "unassigned"} {channelLabel(notification.delivery_channel) || <UnassignedLabel />}
</TableCell> </TableCell>
<TableCell className="hidden text-xs text-grayScale-600 md:table-cell"> <TableCell className="hidden text-xs text-grayScale-600 md:table-cell">
{formatNotificationTypeLabel(notification.type)} {formatNotificationTypeLabel(notification.type)}
@ -372,7 +373,7 @@ export function AllNotificationsPage() {
variant={getNotificationLevelBadge(notification.level)} variant={getNotificationLevelBadge(notification.level)}
className="text-[10px]" className="text-[10px]"
> >
{notification.level || "unassigned"} {notification.level || <UnassignedLabel />}
</Badge> </Badge>
</TableCell> </TableCell>
<TableCell> <TableCell>
@ -381,7 +382,7 @@ export function AllNotificationsPage() {
</Badge> </Badge>
</TableCell> </TableCell>
<TableCell className="hidden text-xs capitalize text-grayScale-500 sm:table-cell"> <TableCell className="hidden text-xs capitalize text-grayScale-500 sm:table-cell">
{notification.delivery_status || "unassigned"} {notification.delivery_status || <UnassignedLabel />}
</TableCell> </TableCell>
<TableCell className="hidden text-xs text-grayScale-500 sm:table-cell"> <TableCell className="hidden text-xs text-grayScale-500 sm:table-cell">
{formatNotificationTimestamp(notification.timestamp)} {formatNotificationTimestamp(notification.timestamp)}

View File

@ -53,6 +53,7 @@ import { NOTIFICATION_REALTIME_EVENT } from "../../lib/notificationsWebSocket"
import { toast } from "sonner" import { toast } from "sonner"
import { TablePagination } from "../../components/admin/TablePagination" import { TablePagination } from "../../components/admin/TablePagination"
import { DEFAULT_TABLE_PAGE_SIZE } from "../../lib/tablePagination" import { DEFAULT_TABLE_PAGE_SIZE } from "../../lib/tablePagination"
import { UnassignedLabel } from "../../lib/displayValue"
function NotificationItem({ function NotificationItem({
notification, notification,
@ -520,7 +521,7 @@ export function NotificationsPage() {
<div> <div>
<p className="text-xs font-medium text-grayScale-500">Channels used</p> <p className="text-xs font-medium text-grayScale-500">Channels used</p>
<p className="mt-1 text-xl font-semibold text-grayScale-700"> <p className="mt-1 text-xl font-semibold text-grayScale-700">
{Array.from(new Set(notifications.map((n) => n.delivery_channel))).length || "unassigned"} {Array.from(new Set(notifications.map((n) => n.delivery_channel))).length || <UnassignedLabel />}
</p> </p>
</div> </div>
<div className="grid h-11 w-11 shrink-0 place-items-center rounded-xl bg-brand-100/60 text-brand-600"> <div className="grid h-11 w-11 shrink-0 place-items-center rounded-xl bg-brand-100/60 text-brand-600">

View File

@ -37,6 +37,7 @@ import {
import { countActiveFilters } from "../../lib/adminFilterUtils" import { countActiveFilters } from "../../lib/adminFilterUtils"
import { cn } from "../../lib/utils" import { cn } from "../../lib/utils"
import { DEFAULT_TABLE_PAGE_SIZE } from "../../lib/tablePagination" import { DEFAULT_TABLE_PAGE_SIZE } from "../../lib/tablePagination"
import { UnassignedLabel } from "../../lib/displayValue"
import type { import type {
NotificationChannel, NotificationChannel,
ScheduledNotification, ScheduledNotification,
@ -261,7 +262,7 @@ export function ScheduledNotificationsPage() {
<TableCell>{channelLabel(job.channel)}</TableCell> <TableCell>{channelLabel(job.channel)}</TableCell>
<TableCell className="max-w-[240px]"> <TableCell className="max-w-[240px]">
<p className="truncate text-sm font-medium text-grayScale-700"> <p className="truncate text-sm font-medium text-grayScale-700">
{job.title || "unassigned"} {job.title || <UnassignedLabel />}
</p> </p>
<p className="truncate text-xs text-grayScale-400">{job.message}</p> <p className="truncate text-xs text-grayScale-400">{job.message}</p>
{job.channel === "email" && job.email_template_slug ? ( {job.channel === "email" && job.email_template_slug ? (

View File

@ -15,6 +15,7 @@ import { Card, CardContent } from "../../../components/ui/card"
import { channelLabel, formatScheduledAtLabel } from "../../../lib/notificationBulk" import { channelLabel, formatScheduledAtLabel } from "../../../lib/notificationBulk"
import { cn } from "../../../lib/utils" import { cn } from "../../../lib/utils"
import type { NotificationChannel } from "../../../types/notification.types" import type { NotificationChannel } from "../../../types/notification.types"
import { UnassignedLabel } from "../../../lib/displayValue"
export type BulkSendSummary = export type BulkSendSummary =
| { | {
@ -177,9 +178,9 @@ export function BulkSendSummaryPanel({ summary, onDismiss }: BulkSendSummaryPane
Content Content
</p> </p>
<p className="mt-1 truncate text-sm font-medium text-grayScale-800"> <p className="mt-1 truncate text-sm font-medium text-grayScale-800">
{summary.titlePreview || "unassigned"} {summary.titlePreview || <UnassignedLabel />}
</p> </p>
<p className="truncate text-xs text-grayScale-500">{summary.messagePreview || "unassigned"}</p> <p className="truncate text-xs text-grayScale-500">{summary.messagePreview || <UnassignedLabel />}</p>
{!isImmediate && summary.emailTemplateSlug ? ( {!isImmediate && summary.emailTemplateSlug ? (
<p className="mt-1 text-[10px] text-grayScale-400"> <p className="mt-1 text-[10px] text-grayScale-400">
Template: {summary.emailTemplateSlug} Template: {summary.emailTemplateSlug}

View File

@ -61,6 +61,7 @@ import type {
} from "../../types/payment.types" } from "../../types/payment.types"
import { DEFAULT_TABLE_PAGE_SIZE, TABLE_PAGE_SIZE_OPTIONS } from "../../lib/tablePagination" import { DEFAULT_TABLE_PAGE_SIZE, TABLE_PAGE_SIZE_OPTIONS } from "../../lib/tablePagination"
import { UnassignedLabel } from "../../lib/displayValue"
const STATUS_FILTERS: { value: PaymentStatus; label: string }[] = [ const STATUS_FILTERS: { value: PaymentStatus; label: string }[] = [
{ value: "PENDING", label: "Pending" }, { value: "PENDING", label: "Pending" },
@ -518,7 +519,7 @@ export function PaymentsPage() {
<td className="whitespace-nowrap px-3 py-2.5 sm:px-4"> <td className="whitespace-nowrap px-3 py-2.5 sm:px-4">
<p className="font-semibold text-grayScale-900">#{payment.id}</p> <p className="font-semibold text-grayScale-900">#{payment.id}</p>
<p className="mt-0.5 max-w-[140px] truncate font-mono text-[11px] text-grayScale-500"> <p className="mt-0.5 max-w-[140px] truncate font-mono text-[11px] text-grayScale-500">
{payment.transaction_id || payment.session_id || "unassigned"} {payment.transaction_id || payment.session_id || <UnassignedLabel />}
</p> </p>
</td> </td>
<td className="px-3 py-2.5 sm:px-4"> <td className="px-3 py-2.5 sm:px-4">
@ -716,11 +717,11 @@ export function PaymentsPage() {
<div className="mt-5 space-y-0 divide-y divide-grayScale-100"> <div className="mt-5 space-y-0 divide-y divide-grayScale-100">
{[ {[
{ k: "Customer", v: paymentCustomerName(selected) }, { k: "Customer", v: paymentCustomerName(selected) },
{ k: "Email", v: selected.user_email || "unassigned" }, { k: "Email", v: selected.user_email || <UnassignedLabel /> },
{ k: "Plan", v: selected.plan_name || `Plan #${selected.plan_id}` }, { k: "Plan", v: selected.plan_name || `Plan #${selected.plan_id}` },
{ k: "Category", v: formatPaymentPlanCategory(selected.plan_category) }, { k: "Category", v: formatPaymentPlanCategory(selected.plan_category) },
{ k: "Transaction", v: selected.transaction_id || "unassigned", mono: true }, { k: "Transaction", v: selected.transaction_id || <UnassignedLabel />, mono: true },
{ k: "Session", v: selected.session_id || "unassigned", mono: true }, { k: "Session", v: selected.session_id || <UnassignedLabel />, mono: true },
{ k: "Subscription", v: `#${selected.subscription_id}` }, { k: "Subscription", v: `#${selected.subscription_id}` },
{ k: "Paid", v: formatPaymentDate(selected.paid_at ?? selected.created_at) }, { k: "Paid", v: formatPaymentDate(selected.paid_at ?? selected.created_at) },
...(selected.expires_at ? [{ k: "Expires", v: formatPaymentDate(selected.expires_at) }] : []), ...(selected.expires_at ? [{ k: "Expires", v: formatPaymentDate(selected.expires_at) }] : []),

View File

@ -32,6 +32,7 @@ import { toast } from "sonner";
import { InviteTeamMemberDialog } from "../role-management/components/InviteTeamMemberDialog"; import { InviteTeamMemberDialog } from "../role-management/components/InviteTeamMemberDialog";
import { EXPORT_PERMISSIONS, EXPORT_ROUTES } from "../../lib/csv-export"; import { EXPORT_PERMISSIONS, EXPORT_ROUTES } from "../../lib/csv-export";
import { teamMemberExportQuery } from "../../lib/csvExportFilters"; import { teamMemberExportQuery } from "../../lib/csvExportFilters";
import { UnassignedLabel } from "../../lib/displayValue"
function formatDate(dateStr: string): string { function formatDate(dateStr: string): string {
return new Date(dateStr).toLocaleDateString("en-US", { return new Date(dateStr).toLocaleDateString("en-US", {
@ -388,10 +389,10 @@ export function TeamManagementPage() {
</span> </span>
</TableCell> </TableCell>
<TableCell className="hidden md:table-cell text-sm text-grayScale-600"> <TableCell className="hidden md:table-cell text-sm text-grayScale-600">
{member.department || "unassigned"} {member.department || <UnassignedLabel />}
</TableCell> </TableCell>
<TableCell className="hidden lg:table-cell text-sm text-grayScale-600"> <TableCell className="hidden lg:table-cell text-sm text-grayScale-600">
{member.job_title || "unassigned"} {member.job_title || <UnassignedLabel />}
</TableCell> </TableCell>
<TableCell className="hidden sm:table-cell"> <TableCell className="hidden sm:table-cell">
{member.last_login ? ( {member.last_login ? (
@ -406,7 +407,7 @@ export function TeamManagementPage() {
) : ( ) : (
<div> <div>
<div className="text-sm text-grayScale-600">Never</div> <div className="text-sm text-grayScale-600">Never</div>
<div className="text-xs text-grayScale-400">unassigned</div> <div className="text-xs text-grayScale-400"><UnassignedLabel /></div>
</div> </div>
)} )}
</TableCell> </TableCell>

View File

@ -20,7 +20,7 @@ import { Separator } from "../../components/ui/separator"
import { cn } from "../../lib/utils" import { cn } from "../../lib/utils"
import { notifyApiError } from "../../lib/apiErrors" import { notifyApiError } from "../../lib/apiErrors"
import { formatTeamRoleLabel } from "../../lib/teamRoles" import { formatTeamRoleLabel } from "../../lib/teamRoles"
import { displayValue, NOT_ASSIGNED_LABEL } from "../../lib/displayValue" import { DisplayValue, NOT_ASSIGNED_LABEL, UnassignedLabel, displayValue, isUnassignedLabel } from "../../lib/displayValue"
import { getTeamMemberById, updateTeamMemberStatus } from "../../api/team.api" import { getTeamMemberById, updateTeamMemberStatus } from "../../api/team.api"
import type { TeamMemberDetail } from "../../types/team.types" import type { TeamMemberDetail } from "../../types/team.types"
import { ActivityLogListPanel } from "../user-log/components/ActivityLogListPanel" import { ActivityLogListPanel } from "../user-log/components/ActivityLogListPanel"
@ -132,22 +132,26 @@ function LoadingSkeleton() {
) )
} }
function InfoItem({ label, value }: { label: string; value: string }) { function InfoItem({ label, value }: { label: string; value: React.ReactNode }) {
return ( return (
<div> <div>
<p className="mb-1 text-[11px] font-medium uppercase tracking-wider text-grayScale-400"> <p className="mb-1 text-[11px] font-medium uppercase tracking-wider text-grayScale-400">
{label} {label}
</p> </p>
<p className="text-sm text-grayScale-700">{value}</p> <p className="text-sm text-grayScale-700">
{typeof value === "string" && isUnassignedLabel(value) ? <UnassignedLabel /> : value}
</p>
</div> </div>
) )
} }
function InfoRow({ label, value }: { label: string; value: string }) { function InfoRow({ label, value }: { label: string; value: React.ReactNode }) {
return ( return (
<div className="flex items-center justify-between gap-3"> <div className="flex items-center justify-between gap-3">
<span className="text-sm text-grayScale-500">{label}</span> <span className="text-sm text-grayScale-500">{label}</span>
<span className="text-right text-sm font-medium text-grayScale-700">{value}</span> <span className="text-right text-sm font-medium text-grayScale-700">
{typeof value === "string" && isUnassignedLabel(value) ? <UnassignedLabel /> : value}
</span>
</div> </div>
) )
} }
@ -159,7 +163,7 @@ function ContactField({
}: { }: {
icon: React.ComponentType<{ className?: string }> icon: React.ComponentType<{ className?: string }>
label: string label: string
value: string value: React.ReactNode
}) { }) {
return ( return (
<div className="flex items-center gap-3"> <div className="flex items-center gap-3">
@ -170,7 +174,9 @@ function ContactField({
<p className="text-[11px] font-medium uppercase tracking-wider text-grayScale-400"> <p className="text-[11px] font-medium uppercase tracking-wider text-grayScale-400">
{label} {label}
</p> </p>
<p className="truncate text-sm text-grayScale-700">{value}</p> <p className="truncate text-sm text-grayScale-700">
{typeof value === "string" && isUnassignedLabel(value) ? <UnassignedLabel /> : value}
</p>
</div> </div>
</div> </div>
) )
@ -312,7 +318,7 @@ export function TeamMemberDetailPage() {
<div className="min-w-0"> <div className="min-w-0">
<h2 className="truncate text-lg font-semibold text-grayScale-800">{fullName}</h2> <h2 className="truncate text-lg font-semibold text-grayScale-800">{fullName}</h2>
<p className="truncate text-sm text-grayScale-500"> <p className="truncate text-sm text-grayScale-500">
{displayValue(member.job_title)} <DisplayValue value={member.job_title} />
</p> </p>
<div className="mt-2 flex flex-wrap gap-2"> <div className="mt-2 flex flex-wrap gap-2">
<span <span
@ -334,8 +340,8 @@ export function TeamMemberDetailPage() {
<Separator /> <Separator />
<div className="space-y-3"> <div className="space-y-3">
<ContactField icon={Mail} label="Email" value={displayValue(member.email)} /> <ContactField icon={Mail} label="Email" value={<DisplayValue value={member.email} />} />
<ContactField icon={Phone} label="Phone" value={displayValue(member.phone_number)} /> <ContactField icon={Phone} label="Phone" value={<DisplayValue value={member.phone_number} />} />
</div> </div>
<Separator /> <Separator />
@ -383,8 +389,8 @@ export function TeamMemberDetailPage() {
<CardContent className="space-y-5"> <CardContent className="space-y-5">
<div className="grid grid-cols-1 gap-x-6 gap-y-4 sm:grid-cols-2 lg:grid-cols-3"> <div className="grid grid-cols-1 gap-x-6 gap-y-4 sm:grid-cols-2 lg:grid-cols-3">
<InfoItem label="Team role" value={roleLabel} /> <InfoItem label="Team role" value={roleLabel} />
<InfoItem label="Department" value={displayValue(member.department)} /> <InfoItem label="Department" value={<DisplayValue value={member.department} />} />
<InfoItem label="Job title" value={displayValue(member.job_title)} /> <InfoItem label="Job title" value={<DisplayValue value={member.job_title} />} />
<InfoItem label="Member ID" value={String(member.id)} /> <InfoItem label="Member ID" value={String(member.id)} />
<InfoItem label="Joined" value={formatDate(member.created_at)} /> <InfoItem label="Joined" value={formatDate(member.created_at)} />
<InfoItem <InfoItem

View File

@ -65,6 +65,7 @@ import { TABLE_PAGE_SIZE_OPTIONS } from "../../../lib/tablePagination"
import type { ActivityLog, ActivityLogFilters } from "../../../types/activity-log.types" import type { ActivityLog, ActivityLogFilters } from "../../../types/activity-log.types"
import { ActorCell, ActorLabel } from "./ActorLabel" import { ActorCell, ActorLabel } from "./ActorLabel"
import { ActorHoverCard } from "./ActorHoverCard" import { ActorHoverCard } from "./ActorHoverCard"
import { UnassignedLabel } from "../../../lib/displayValue"
export interface ActivityLogListPanelProps { export interface ActivityLogListPanelProps {
/** When set, locks the list to actions by this actor (user profile audit tab). */ /** When set, locks the list to actions by this actor (user profile audit tab). */
@ -281,7 +282,7 @@ export function ActivityLogListPanel({
</div> </div>
<div> <div>
<p className="text-2xl font-bold text-grayScale-600"> <p className="text-2xl font-bold text-grayScale-600">
{logs[0]?.created_at ? getRelativeActivityTime(logs[0].created_at) : "unassigned"} {logs[0]?.created_at ? getRelativeActivityTime(logs[0].created_at) : <UnassignedLabel />}
</p> </p>
<p className="text-xs text-grayScale-400">Latest on this page</p> <p className="text-xs text-grayScale-400">Latest on this page</p>
</div> </div>
@ -450,7 +451,7 @@ export function ActivityLogListPanel({
scrollable ? "whitespace-nowrap" : "max-w-[280px] truncate", scrollable ? "whitespace-nowrap" : "max-w-[280px] truncate",
)} )}
> >
{log.message || "unassigned"} {log.message || <UnassignedLabel />}
</p> </p>
</TableCell> </TableCell>
{showActorColumn ? ( {showActorColumn ? (
@ -583,7 +584,7 @@ export function ActivityLogListPanel({
icon={<Shield className="h-4 w-4" />} icon={<Shield className="h-4 w-4" />}
label="Role" label="Role"
value={ value={
selectedLog.actor_role ? formatRoleLabel(selectedLog.actor_role) : "unassigned" selectedLog.actor_role ? formatRoleLabel(selectedLog.actor_role) : <UnassignedLabel />
} }
/> />
<DetailItem <DetailItem
@ -601,13 +602,13 @@ export function ActivityLogListPanel({
<DetailItem <DetailItem
icon={<Globe className="h-4 w-4" />} icon={<Globe className="h-4 w-4" />}
label="IP address" label="IP address"
value={selectedLog.ip_address || "unassigned"} value={selectedLog.ip_address || <UnassignedLabel />}
/> />
<DetailItem <DetailItem
icon={<Monitor className="h-4 w-4" />} icon={<Monitor className="h-4 w-4" />}
label="User agent" label="User agent"
value={ value={
selectedLog.user_agent ? truncateUA(selectedLog.user_agent) : "unassigned" selectedLog.user_agent ? truncateUA(selectedLog.user_agent) : <UnassignedLabel />
} }
title={selectedLog.user_agent ?? undefined} title={selectedLog.user_agent ?? undefined}
/> />

View File

@ -27,6 +27,7 @@ import type {
} from "../../types/user.types" } from "../../types/user.types"
import type { Role } from "../../types/rbac.types" import type { Role } from "../../types/rbac.types"
import { mapDeletionRequestApiItem } from "../../types/user.types" import { mapDeletionRequestApiItem } from "../../types/user.types"
import { UnassignedLabel } from "../../lib/displayValue"
const stateBadge: Record<string, string> = { const stateBadge: Record<string, string> = {
PENDING: "bg-amber-100 text-amber-700", PENDING: "bg-amber-100 text-amber-700",
@ -542,21 +543,21 @@ export function DeletionRequestsPage() {
{item.first_name} {item.last_name} {item.first_name} {item.last_name}
</p> </p>
<p className="text-xs text-grayScale-500">{item.email}</p> <p className="text-xs text-grayScale-500">{item.email}</p>
<p className="text-xs text-grayScale-500">{item.phone_number || "unassigned"}</p> <p className="text-xs text-grayScale-500">{item.phone_number || <UnassignedLabel />}</p>
</TableCell> </TableCell>
<TableCell className="py-3.5"> <TableCell className="py-3.5">
<p className="text-sm text-grayScale-700">{item.role || "unassigned"}</p> <p className="text-sm text-grayScale-700">{item.role || <UnassignedLabel />}</p>
<p className="text-xs text-grayScale-500">{item.status || "unassigned"}</p> <p className="text-xs text-grayScale-500">{item.status || <UnassignedLabel />}</p>
</TableCell> </TableCell>
<TableCell className="hidden py-3.5 text-sm text-grayScale-600 md:table-cell"> <TableCell className="hidden py-3.5 text-sm text-grayScale-600 md:table-cell">
{item.deletion_requested_at || "unassigned"} {item.deletion_requested_at || <UnassignedLabel />}
</TableCell> </TableCell>
<TableCell className="hidden py-3.5 text-sm text-grayScale-600 md:table-cell"> <TableCell className="hidden py-3.5 text-sm text-grayScale-600 md:table-cell">
{item.deletion_scheduled_at || "unassigned"} {item.deletion_scheduled_at || <UnassignedLabel />}
</TableCell> </TableCell>
<TableCell className="py-3.5"> <TableCell className="py-3.5">
<Badge className={stateBadge[item.deletion_state] || "bg-grayScale-200 text-grayScale-600"}> <Badge className={stateBadge[item.deletion_state] || "bg-grayScale-200 text-grayScale-600"}>
{item.deletion_state || "unassigned"} {item.deletion_state || <UnassignedLabel />}
</Badge> </Badge>
</TableCell> </TableCell>
</TableRow> </TableRow>

View File

@ -1,4 +1,4 @@
import { useEffect, useState } from "react"; import { useEffect, useState, type ReactNode } from "react";
import { import {
ArrowLeft, ArrowLeft,
BookOpen, BookOpen,
@ -35,7 +35,7 @@ import type { UserLearningActivityData, UserSubscriptionsData } from "../../type
import { UserLearningActivitySection } from "./components/UserLearningActivitySection"; import { UserLearningActivitySection } from "./components/UserLearningActivitySection";
import { UserAccountActivitySection } from "./components/UserAccountActivitySection"; import { UserAccountActivitySection } from "./components/UserAccountActivitySection";
import { UserSubscriptionsSection } from "./components/UserSubscriptionsSection"; import { UserSubscriptionsSection } from "./components/UserSubscriptionsSection";
import { displayValue, NOT_ASSIGNED_LABEL } from "../../lib/displayValue"; import { DisplayValue, NOT_ASSIGNED_LABEL, UnassignedLabel, displayValue, isUnassignedLabel } from "../../lib/displayValue"
const activityIcons = { const activityIcons = {
completed: CheckCircle2, completed: CheckCircle2,
@ -413,9 +413,9 @@ export function UserDetailPage() {
<div className="grid gap-3 text-sm sm:grid-cols-2"> <div className="grid gap-3 text-sm sm:grid-cols-2">
<InfoRow label="Joined" value={formatDate(user.created_at)} /> <InfoRow label="Joined" value={formatDate(user.created_at)} />
<InfoRow label="Last login" value={formatDateTime(user.last_login, "Never")} /> <InfoRow label="Last login" value={formatDateTime(user.last_login, "Never")} />
<InfoRow label="Gender" value={displayValue(user.gender)} /> <InfoRow label="Gender" value={<DisplayValue value={user.gender} />} />
<InfoRow label="Birthday" value={formatDate(user.birth_day)} /> <InfoRow label="Birthday" value={formatDate(user.birth_day)} />
<InfoRow label="Occupation" value={displayValue(user.occupation)} /> <InfoRow label="Occupation" value={<DisplayValue value={user.occupation} />} />
</div> </div>
</CardContent> </CardContent>
</Card> </Card>
@ -439,7 +439,7 @@ export function UserDetailPage() {
/> />
<InfoRow <InfoRow
label="Preferred language" label="Preferred language"
value={displayValue(user.preferred_language)} value={<DisplayValue value={user.preferred_language} />}
/> />
</CardContent> </CardContent>
</Card> </Card>
@ -467,11 +467,11 @@ export function UserDetailPage() {
</CardHeader> </CardHeader>
<CardContent className="space-y-5"> <CardContent className="space-y-5">
<div className="grid grid-cols-1 gap-x-6 gap-y-4 sm:grid-cols-2"> <div className="grid grid-cols-1 gap-x-6 gap-y-4 sm:grid-cols-2">
<InfoItem label="Education level" value={displayValue(user.education_level)} /> <InfoItem label="Education level" value={<DisplayValue value={user.education_level} />} />
<InfoItem label="Age group" value={formatAgeGroup(user.age_group)} /> <InfoItem label="Age group" value={formatAgeGroup(user.age_group)} />
<InfoItem label="Favorite topic" value={displayValue(user.favoutite_topic)} /> <InfoItem label="Favorite topic" value={<DisplayValue value={user.favoutite_topic} />} />
<InfoItem label="Language goal" value={displayValue(user.language_goal)} /> <InfoItem label="Language goal" value={<DisplayValue value={user.language_goal} />} />
<InfoItem label="Challenge" value={displayValue(user.language_challange)} /> <InfoItem label="Challenge" value={<DisplayValue value={user.language_challange} />} />
<InfoItem label="Role" value={formatRoleLabel(user.role)} /> <InfoItem label="Role" value={formatRoleLabel(user.role)} />
</div> </div>
@ -598,20 +598,24 @@ export function UserDetailPage() {
); );
} }
function InfoItem({ label, value }: { label: string; value: string }) { function InfoItem({ label, value }: { label: string; value: ReactNode }) {
return ( return (
<div> <div>
<p className="mb-1 text-[11px] font-medium uppercase tracking-wider text-grayScale-400">{label}</p> <p className="mb-1 text-[11px] font-medium uppercase tracking-wider text-grayScale-400">{label}</p>
<p className="text-sm text-grayScale-700">{value}</p> <p className="text-sm text-grayScale-700">
{typeof value === "string" && isUnassignedLabel(value) ? <UnassignedLabel /> : value}
</p>
</div> </div>
); );
} }
function InfoRow({ label, value }: { label: string; value: string }) { function InfoRow({ label, value }: { label: string; value: ReactNode }) {
return ( return (
<div className="flex items-center justify-between gap-3"> <div className="flex items-center justify-between gap-3">
<span className="text-sm text-grayScale-500">{label}</span> <span className="text-sm text-grayScale-500">{label}</span>
<span className="text-sm font-medium text-grayScale-700">{value}</span> <span className="text-sm font-medium text-grayScale-700">
{typeof value === "string" && isUnassignedLabel(value) ? <UnassignedLabel /> : value}
</span>
</div> </div>
); );
} }

View File

@ -26,6 +26,7 @@ import axios from "axios"
import { USER_FILTER_COUNTRIES, USER_FILTER_ETHIOPIA_REGIONS } from "../../data/userFilterLocations" import { USER_FILTER_COUNTRIES, USER_FILTER_ETHIOPIA_REGIONS } from "../../data/userFilterLocations"
import { EXPORT_PERMISSIONS, EXPORT_ROUTES } from "../../lib/csv-export" import { EXPORT_PERMISSIONS, EXPORT_ROUTES } from "../../lib/csv-export"
import { usersExportQuery } from "../../lib/csvExportFilters" import { usersExportQuery } from "../../lib/csvExportFilters"
import { UnassignedLabel } from "../../lib/displayValue"
function formatJoinedAt(iso: string): string { function formatJoinedAt(iso: string): string {
if (!iso?.trim()) return "unassigned" if (!iso?.trim()) return "unassigned"
@ -365,7 +366,7 @@ export function UsersListPage() {
const hasPhone = Boolean(phone?.trim()) const hasPhone = Boolean(phone?.trim())
const hasEmail = Boolean(email?.trim()) const hasEmail = Boolean(email?.trim())
if (!hasPhone && !hasEmail) { if (!hasPhone && !hasEmail) {
return <span className="text-grayScale-400">unassigned</span> return <span className="text-grayScale-400"><UnassignedLabel /></span>
} }
return ( return (
<div className="space-y-1 text-sm text-grayScale-600"> <div className="space-y-1 text-sm text-grayScale-600">
@ -665,8 +666,8 @@ export function UsersListPage() {
<TableCell className="hidden md:table-cell align-top"> <TableCell className="hidden md:table-cell align-top">
{renderContactDetails(u.phoneNumber, u.email)} {renderContactDetails(u.phoneNumber, u.email)}
</TableCell> </TableCell>
<TableCell className="hidden md:table-cell text-grayScale-500">{u.country || "unassigned"}</TableCell> <TableCell className="hidden md:table-cell text-grayScale-500">{u.country || <UnassignedLabel />}</TableCell>
<TableCell className="hidden md:table-cell text-grayScale-500">{u.region || "unassigned"}</TableCell> <TableCell className="hidden md:table-cell text-grayScale-500">{u.region || <UnassignedLabel />}</TableCell>
<TableCell className="hidden md:table-cell text-sm text-grayScale-500 whitespace-nowrap"> <TableCell className="hidden md:table-cell text-sm text-grayScale-500 whitespace-nowrap">
{formatJoinedAt(u.createdAt)} {formatJoinedAt(u.createdAt)}
</TableCell> </TableCell>

View File

@ -12,7 +12,7 @@ import {
TableRow, TableRow,
} from "../../../components/ui/table" } from "../../../components/ui/table"
import { useTeamPermissions } from "../../../hooks/useTeamPermissions" import { useTeamPermissions } from "../../../hooks/useTeamPermissions"
import { displayValue, NOT_ASSIGNED_LABEL } from "../../../lib/displayValue" import { DisplayValue, NOT_ASSIGNED_LABEL, displayValue } from "../../../lib/displayValue"
import { import {
formatAdminPaymentMethod, formatAdminPaymentMethod,
hasSubscriptionAdminPermission, hasSubscriptionAdminPermission,
@ -559,7 +559,7 @@ export function UserSubscriptionsSection({
{recentPayments.map((payment) => ( {recentPayments.map((payment) => (
<TableRow key={payment.id}> <TableRow key={payment.id}>
<TableCell className="text-sm text-grayScale-700"> <TableCell className="text-sm text-grayScale-700">
{displayValue(payment.plan_name)} <DisplayValue value={payment.plan_name} />
</TableCell> </TableCell>
<TableCell className="text-sm text-grayScale-700"> <TableCell className="text-sm text-grayScale-700">
{formatMoney(payment.amount, payment.currency)} {formatMoney(payment.amount, payment.currency)}