Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/components/table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import { order } from '@/utils/orderable';
import copilotTheme from '@/utils/copilotTheme';
import NoRowsOverlay from './NoRowsOverlay';
import Loading from '@/app/loading';
import { getWorkspaceLabels } from '@/utils/getWorkspaceLabels';

export const TableCore = () => {
const appState = useAppState();

// Row Data: The data to be displayed.
const [rowData, setRowData] = useState<any>([]);
//
Expand Down Expand Up @@ -80,7 +80,7 @@ export const TableCore = () => {
colDefs = [
...colDefs,
{
field: 'client',
field: getWorkspaceLabels(appState?.workspace).individualTerm,
cellRenderer: ClientCellRenderer,
flex: 1,
comparator: comparatorTypeI,
Expand Down Expand Up @@ -110,7 +110,7 @@ export const TableCore = () => {
colDefs = [
...colDefs,
{
field: 'company',
field: getWorkspaceLabels(appState?.workspace).groupTerm,
cellRenderer: CompanyCellRenderer,
flex: 1,
comparator: comparatorTypeI,
Expand Down
9 changes: 9 additions & 0 deletions src/types/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ export type MeResponse = z.infer<typeof MeResponseSchema>;
export const WorkspaceResponseSchema = z.object({
id: z.string(),
isCompaniesEnabled: z.boolean().optional(),
labels: z
.object({
individualTerm: z.string().optional(),
individualTermPlural: z.string().optional(),
groupTerm: z.string().optional(),
groupTermPlural: z.string().optional(),
})
.optional(),

// For future use
// industry: z.string().optional(),
// isClientDirectSignUpEnabled: z.boolean().optional(),
Expand Down
25 changes: 25 additions & 0 deletions src/utils/getWorkspaceLabels.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { WorkspaceResponse } from '@/types/common';

type WorkspaceLabels = {
individualTerm: string;
individualTermPlural: string;
groupTerm: string;
groupTermPlural: string;
};

export const getWorkspaceLabels = (workspace?: WorkspaceResponse, shouldCapitalize: boolean = false): WorkspaceLabels => {
const capitalize = (str: string) => str.charAt(0).toUpperCase() + str.slice(1);
const deCapitalize = (str: string) => str.charAt(0).toLowerCase() + str.slice(1);

const format = (value: string | undefined, fallback: string) => {
if (!value) return shouldCapitalize ? capitalize(fallback) : deCapitalize(fallback);
return shouldCapitalize ? capitalize(value) : deCapitalize(value);
};

return {
individualTerm: format(workspace?.labels?.individualTerm, 'client'),
individualTermPlural: format(workspace?.labels?.individualTermPlural, 'clients'),
groupTerm: format(workspace?.labels?.groupTerm, 'company'),
groupTermPlural: format(workspace?.labels?.groupTermPlural, 'companies'),
};
};