Преглед изворни кода

chore(dashboard): Fix Sonar issues

Michael Bromley пре 2 месеци
родитељ
комит
f0b4a0e03b

+ 2 - 3
packages/dashboard/src/app/routes/_authenticated/_orders/components/use-transition-order-to-state.tsx

@@ -22,8 +22,7 @@ import { orderHistoryDocument, transitionOrderToStateDocument } from '../orders.
  */
 export function useTransitionOrderToState(orderId: string | undefined) {
     const [selectStateOpen, setSelectStateOpen] = useState(false);
-    const [onSuccessFn, setOnSuccessFn] = useState<() => void>(() => {
-    });
+    const [onSuccessFn, setOnSuccessFn] = useState<() => void>(() => {});
     const { data, isLoading, error } = useQuery({
         queryKey: ['orderPreModifyingState', orderId],
         queryFn: async () => {
@@ -142,7 +141,7 @@ export function useTransitionOrderToState(orderId: string | undefined) {
         transitionToPreModifyingState,
         transitionToState,
         ManuallySelectNextState,
-        selectNextState: ({ onSuccess }: { onSuccess?: () => void }) => {
+        selectNextState: ({ onSuccess }: { onSuccess?: () => void | Promise<void> }) => {
             setSelectStateOpen(true);
             if (onSuccess) {
                 setOnSuccessFn(() => onSuccess);

+ 1 - 1
packages/dashboard/src/lib/components/data-input/default-relation-input.tsx

@@ -567,11 +567,11 @@ export function DefaultRelationInput({
     entityType,
 }: Readonly<DefaultRelationInputProps>) {
     const { t } = useLingui();
+    const ENTITY_CONFIGS = useMemo(() => createEntityConfigs(t), [t]);
     if (!fieldDef || (!isRelationCustomFieldConfig(fieldDef) && !entityType)) {
         return null;
     }
     const entityName = entityType ?? (fieldDef as RelationCustomFieldConfig).entity;
-    const ENTITY_CONFIGS = useMemo(() => createEntityConfigs(t), [t]);
     const config = ENTITY_CONFIGS[entityName as keyof typeof ENTITY_CONFIGS];
 
     if (!config) {

+ 9 - 2
packages/dashboard/src/lib/components/data-input/string-list-input.tsx

@@ -75,6 +75,12 @@ function SortableItem({ id, item, isDisabled, isEditing, onRemove, onEdit, onSav
         }
     }, [isEditing]);
 
+    useEffect(() => {
+        if (item !== editValue) {
+            setEditValue(item);
+        }
+    }, [item]);
+
     return (
         <Badge
             ref={setNodeRef}
@@ -112,12 +118,13 @@ function SortableItem({ id, item, isDisabled, isEditing, onRemove, onEdit, onSav
                     style={{ width: `${Math.max(editValue.length * 8, 60)}px` }}
                 />
             ) : (
-                <span
+                <button
+                    type="button"
                     onClick={!isDisabled ? onEdit : undefined}
                     className={cn(!isDisabled && 'cursor-text hover:underline')}
                 >
                     {item}
-                </span>
+                </button>
             )}
             {!isDisabled && (
                 <button

+ 2 - 2
packages/dashboard/src/lib/components/data-table/data-table-filter-badge.tsx

@@ -20,7 +20,7 @@ export function DataTableFilterBadge({
     const [operator, value] = Object.entries(filter.value as Record<string, unknown>)[0];
     return (
         <Badge key={filter.id} className="flex gap-2 flex-wrap items-center" variant="outline">
-            <div
+            <button
                 className="flex gap-1 flex-wrap items-center cursor-pointer flex-1"
                 onClick={() => onClick?.(filter)}
             >
@@ -37,7 +37,7 @@ export function DataTableFilterBadge({
                 <div className="@xs:overflow-hidden @xs:text-ellipsis @xs:whitespace-nowrap flex flex-col @xl:flex-row @2xl:gap-1">
                     <FilterValue value={value} dataType={dataType} currencyCode={currencyCode} />
                 </div>
-            </div>
+            </button>
             <button className="border-l -mr-2" onClick={() => onRemove(filter)}>
                 <XIcon className="h-4 flex-shrink-0 cursor-pointer" />
             </button>

+ 0 - 1
packages/dashboard/src/lib/components/data-table/data-table.tsx

@@ -209,7 +209,6 @@ export function DataTable<TData>({
                 ...pagination,
                 pageIndex: 0,
             });
-            pagination.pageIndex;
         }
         prevColumnFiltersRef.current = columnFilters;
     }, [columnFilters]);