Skip to content

Commit

Permalink
NEOS-295: updated to handle lowercase value names for sheet opening (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
evisdrenova authored Nov 6, 2023
1 parent a079a65 commit 57ced07
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
5 changes: 3 additions & 2 deletions frontend/components/jobs/SchemaTable/TransformerSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
} from '@/components/ui/popover';
import { cn } from '@/libs/utils';
import { CustomTransformer } from '@/neosync-api-client/mgmt/v1alpha1/transformer_pb';
import { ToTitleCase } from '@/util/util';
import { CaretSortIcon, CheckIcon } from '@radix-ui/react-icons';
import { ReactElement, useState } from 'react';

Expand Down Expand Up @@ -48,7 +49,7 @@ export default function TransformerSelect(props: Props): ReactElement {
aria-expanded={open}
className="justify-between w-[160px]"
>
<div className="whitespace-nowrap truncate">{value}</div>
<div className="whitespace-nowrap truncate">{ToTitleCase(value)}</div>

<CaretSortIcon className="ml-2 h-4 w-4 shrink-0 opacity-50" />
</Button>
Expand Down Expand Up @@ -89,7 +90,7 @@ export default function TransformerSelect(props: Props): ReactElement {
<CommandGroup heading="System">
{system.map((t, index) => (
<CommandItem
key={`${t?.name}-${index}`}
key={`${t?.name}s-${index}`}
onSelect={(currentValue) => {
onSelect(currentValue);
setOpen(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ const Row = memo(function Row({ data, index, style }: RowProps) {
<Cell value={row.table} />
<Cell value={row.column} />
<Cell value={row.dataType} />
<div className=" ">
<div>
<FormField
name={`mappings.${index}.transformer.value`}
render={({ field }) => (
Expand All @@ -234,7 +234,7 @@ const Row = memo(function Row({ data, index, style }: RowProps) {
</div>
<EditTransformerOptions
transformer={transformers?.find(
(item) => item.name == field.value
(item) => item.name.toLowerCase() == field.value
)}
index={index}
/>
Expand Down
25 changes: 16 additions & 9 deletions frontend/util/util.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { format } from 'date-fns';

interface Instance {
createdDate?: string;
}
// interface Instance {
// createdDate?: string;
// }

function formatDate(dateStr?: string): string | undefined {
if (!dateStr) {
return undefined;
}
return format(new Date(dateStr), 'MM/dd/yyyy');
}
// function formatDate(dateStr?: string): string | undefined {
// if (!dateStr) {
// return undefined;
// }
// return format(new Date(dateStr), 'MM/dd/yyyy');
// }

export function formatDateTime(
dateStr?: string | Date | number,
Expand Down Expand Up @@ -50,3 +50,10 @@ function isErrorWithMessage(error: unknown): error is { message: string } {
typeof error.message === 'string'
);
}

export const ToTitleCase = (str: string) => {
return str.replace(
/\w\S*/g,
(txt) => txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase()
);
};
2 changes: 1 addition & 1 deletion frontend/yup-validations/transformers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export function ToTransformerConfigOptions(
},
merged: CustomTransformer[]
): Transformer {
const val = merged.find((item) => item.name == t.value);
const val = merged.find((item) => item.name.toLowerCase() == t.value);

if (!t) {
return new Transformer();
Expand Down

0 comments on commit 57ced07

Please sign in to comment.