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
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { useActionSheet } from '@expo/react-native-action-sheet';
import { isArray } from '@packrat/guards';
import { Button, Text } from '@packrat/ui/nativewindui';
import { Icon } from '@roninoss/icons';
import { appAlert } from 'expo-app/app/_layout';
import { WeightBadge } from 'expo-app/components/initial/WeightBadge';
import { useColorScheme } from 'expo-app/lib/hooks/useColorScheme';
import { useTranslation } from 'expo-app/lib/hooks/useTranslation';
import { router } from 'expo-router';
import { isArray } from 'radash';
import { Image, Pressable, View } from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { useDeletePackTemplate, usePackTemplateDetails } from '../hooks';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import { useMutation } from '@tanstack/react-query';
import axiosInstance, { handleApiError } from 'expo-app/lib/api/client';
import { obs } from 'expo-app/lib/store';
import { isWeightUnit } from 'expo-app/lib/utils/itemCalculations';
import { packTemplateItemsStore } from '../store/packTemplateItems';
import { packTemplatesStore } from '../store/packTemplates';
import type { PackTemplateInStore, PackTemplateItem, WeightUnit } from '../types';

const WEIGHT_UNITS: ReadonlySet<WeightUnit> = new Set(['g', 'kg', 'oz', 'lb']);
const isWeightUnit = (value: string): value is WeightUnit =>
(WEIGHT_UNITS as ReadonlySet<string>).has(value);
import type { PackTemplateInStore, PackTemplateItem } from '../types';

export interface GenerateFromOnlineContentInput {
contentUrl: string;
Expand Down
2 changes: 1 addition & 1 deletion apps/expo/features/packs/components/PackCard.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { useActionSheet } from '@expo/react-native-action-sheet';
import { isArray } from '@packrat/guards';
import { Button, Text } from '@packrat/ui/nativewindui';
import { Icon } from '@roninoss/icons';
import { WeightBadge } from 'expo-app/components/initial/WeightBadge';
import { useColorScheme } from 'expo-app/lib/hooks/useColorScheme';
import { router } from 'expo-router';
import { isArray } from 'radash';
import { Alert, Image, Pressable, View } from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { useDeletePack, usePackDetailsFromStore } from '../hooks';
Expand Down
8 changes: 4 additions & 4 deletions apps/expo/lib/utils/itemCalculations.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { makeEnumGuard } from '@packrat/guards';
import type { CatalogItem } from 'expo-app/features/catalog/types';
import type { PackTemplateItem } from 'expo-app/features/pack-templates';
import type { PackItem, WeightUnit } from 'expo-app/features/packs';

type Item = CatalogItem | PackItem | PackTemplateItem;

const WEIGHT_UNITS = ['g', 'kg', 'oz', 'lb'] as const satisfies readonly WeightUnit[];
export const isWeightUnit = makeEnumGuard(WEIGHT_UNITS);

/**
* Checks if an item is a catalog item
*/
Expand Down Expand Up @@ -43,10 +47,6 @@ export function getWeightUnit(item: Item): WeightUnit {
return item.weightUnit;
}

function isWeightUnit(value: string): value is WeightUnit {
return ['g', 'oz', 'kg', 'lb'].includes(value);
}

/** Gets the notes of an item */
export function getNotes(item: Item): string | undefined {
return isCatalogItem(item) ? undefined : item.notes;
Expand Down
Loading