Skip to content

Commit

Permalink
trip activity fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pinocchio-life-like committed Jan 5, 2025
1 parent dca780d commit bce6f94
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
10 changes: 6 additions & 4 deletions packages/app/components/trip/TripCards/TripActivityCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ import { Select as OriginalSelect } from '@packrat/ui';

const Select: any = OriginalSelect;

const ActivityOptions = Object.values(TripActivity).map((activity) => ({
label: formatTripActivityLabel(activity),
value: activity,
}));
const ActivityOptions = TripActivity
? Object.values(TripActivity).map((activity) => ({
label: formatTripActivityLabel(activity),
value: activity,
}))
: [];

interface TripActivityCardProps {
onChange: (activity: string) => void;
Expand Down
23 changes: 22 additions & 1 deletion packages/app/modules/item/hooks/useItem.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
import { useAuthUser } from 'app/modules/auth';
import { queryTrpc } from 'app/trpc';

type Item = {
id: string;
name: string;
weight: number;
unit: string;
categoryId: string;
ownerId: string;
global: boolean;
sku: string;
productUrl: string;
description: string;
productDetails: Record<string, string | number | boolean>;
seller: string;
createdAt: string;
updatedAt: string;
images: { url: string }[];
category: { id: string; name: string };
};

export const useItem = (itemId?: string) => {
const user = useAuthUser();
const { refetch, data, error, isLoading, isError } =
queryTrpc.getItemById.useQuery(
queryTrpc.getItemById.useQuery<Item>(
{ id: itemId ?? '' },
{
enabled: !!itemId, // to ensure the query runs only when packId is available
Expand All @@ -16,5 +35,7 @@ export const useItem = (itemId?: string) => {
);
const isOwner = data && user && data.ownerId === user.id;

console.log('useItem', { data });

return { refetch, data, error, isLoading, isOwner, isError };
};
2 changes: 1 addition & 1 deletion packages/app/modules/item/screens/ItemDetailsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function ItemDetailsScreen() {

{Platform.OS === 'web' ? (
<RLink to={`/products`}>
<RText style={styles.breadcrumbLink}>{item?.categoryId}</RText>
<RText style={styles.breadcrumbLink}>{item?.category?.name}</RText>
</RLink>
) : (
<TouchableOpacity onPress={() => router.push('/products')}>
Expand Down

0 comments on commit bce6f94

Please sign in to comment.