Skip to content

Commit

Permalink
Merge pull request #1332 from andrew-bierman/fix/similar-item-not-sho…
Browse files Browse the repository at this point in the history
…wing

Fix/similar item not showing
  • Loading branch information
taronaleksanian authored Nov 1, 2024
2 parents c5259bf + 075ea5d commit 5b01e51
Show file tree
Hide file tree
Showing 18 changed files with 312 additions and 157 deletions.
255 changes: 157 additions & 98 deletions packages/app/components/footer/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { theme } from '../../theme';
import useTheme from '../../hooks/useTheme';
Expand All @@ -24,7 +25,14 @@ export default function Footer() {
<NewsLetter />
</View>
<View style={styles.mainFirstContainer}>
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 10 }}>
<View
style={{
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'center',
gap: 10,
}}
>
<RImage
source={{
// TODO: Update this to use the PackRat logo from the assets folder
Expand All @@ -40,27 +48,60 @@ export default function Footer() {
navigate('/');
}}
/>
<RText style={{ fontSize: 25, fontWeight: 'bold', color: currentTheme.colors.logo }}>PackRat</RText>
<RText
style={{
fontSize: 25,
fontWeight: 'bold',
color: currentTheme.colors.logo,
}}
>
PackRat
</RText>
</View>
<View style={{ flexDirection: 'row', alignItems: 'flex-start', justifyContent: 'center', gap: 50 }}>
<View>{firstFootorLinksGroup.map((item) => {
return (
<RLink src={item.link}>
<RText style={styles.navItem}>{item.label}</RText>
</RLink>
);
})}</View>
<View>{secondFootorLinksGroup.map((item) => {
return (
<RLink src={item.link}>
<RText style={styles.navItem}>{item.label}</RText>
</RLink>
);
})}</View>
<View
style={{
flexDirection: 'row',
alignItems: 'flex-start',
justifyContent: 'center',
gap: 50,
}}
>
<View>
{firstFootorLinksGroup.map((item) => {
return (
<RLink key={item.label} src={item.link}>
<RText style={styles.navItem}>{item.label}</RText>
</RLink>
);
})}
</View>
<View>
{secondFootorLinksGroup.map((item) => {
return (
<RLink key={item.label} src={item.link}>
<RText style={styles.navItem}>{item.label}</RText>
</RLink>
);
})}
</View>
</View>
<View style={{ flexDirection: xs || sm || md ? 'row' : 'column', alignItems: 'flex-start', justifyContent: 'center', gap: xs || sm || md ? 10 : 0 }}>
<RLink >
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 5 }}>
<View
style={{
flexDirection: xs || sm || md ? 'row' : 'column',
alignItems: 'flex-start',
justifyContent: 'center',
gap: xs || sm || md ? 10 : 0,
}}
>
<RLink>
<View
style={{
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'center',
gap: 5,
}}
>
<MaterialCommunityIcons
name="facebook"
size={20}
Expand All @@ -69,8 +110,15 @@ export default function Footer() {
<RText>Facebook</RText>
</View>
</RLink>
<RLink >
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 5 }}>
<RLink>
<View
style={{
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'center',
gap: 5,
}}
>
<MaterialCommunityIcons
name="instagram"
size={20}
Expand All @@ -79,8 +127,15 @@ export default function Footer() {
<RText>Instagram</RText>
</View>
</RLink>
<RLink >
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 5 }}>
<RLink>
<View
style={{
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'center',
gap: 5,
}}
>
<MaterialCommunityIcons
name="twitter"
size={20}
Expand All @@ -89,8 +144,15 @@ export default function Footer() {
<RText>X</RText>
</View>
</RLink>
<RLink >
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 5 }}>
<RLink>
<View
style={{
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'center',
gap: 5,
}}
>
<MaterialCommunityIcons
name="github"
size={20}
Expand All @@ -111,76 +173,73 @@ export default function Footer() {
}

const loadStyles = (currentTheme, xs, sm, md) => {
{
return StyleSheet.create({
mainContainer: {
width: '100%',
flexDirection: 'column',
paddingTop: 80,
paddingBottom: 40,
alignSelf: 'center',
alignItems: 'center',
justifyContent: 'space-evenly',
position: 'relative',
bottom: 0,
},
mainFirstContainer: {
width: '100%',
flexDirection: xs || sm || md ? 'column' : 'row',
flexWrap: 'wrap',
paddingTop: 80,
paddingBottom: 40,
alignSelf: 'center',
alignItems: 'center',
justifyContent: 'space-evenly',
position: 'relative',
bottom: 0,
gap: xs || sm || md ? 10 : 0
},
firstMainContainer: {
width: '95%',
// justifyContent: 'center',
// alignItems: 'center',
},
firstContainer: {
width: '100%',
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'flex-start',
gap: 4,
paddingVertical: 18,
},
logo: {
backgroundColor: currentTheme.colors.tertiaryBlue,
borderRadius: 10,
cursor: 'pointer',
},
navLinks: {
flexDirection: 'row',
flexWrap: 'wrap',
gap: 16,
margin: 10,
fontSize: 14,
color: currentTheme.colors.textPrimary,
paddingBottom: 40,
},
navItem: { color: currentTheme.colors.textPrimary },
credit: {
color: currentTheme.colors.textPrimary,
fontSize: 13,
textAlign: xs ? 'center' : 'left',
fontWeight: 'normal',
paddingTop: sm || md ? 10 : 'auto',
},
lastContainer: {
display: 'flex',
flexWrap: 'wrap-reverse',
flexDirection: sm ? 'column-reverse' : 'row',
alignItems: 'center',
justifyContent: 'space-between',
width: sm || md ? 'auto' : '95%',

},
});
}
return StyleSheet.create({
mainContainer: {
width: '100%',
flexDirection: 'column',
paddingTop: 80,
paddingBottom: 40,
alignSelf: 'center',
alignItems: 'center',
justifyContent: 'space-evenly',
position: 'relative',
bottom: 0,
},
mainFirstContainer: {
width: '100%',
flexDirection: xs || sm || md ? 'column' : 'row',
flexWrap: 'wrap',
paddingTop: 80,
paddingBottom: 40,
alignSelf: 'center',
alignItems: 'center',
justifyContent: 'space-evenly',
position: 'relative',
bottom: 0,
gap: xs || sm || md ? 10 : 0,
},
firstMainContainer: {
width: '95%',
// justifyContent: 'center',
// alignItems: 'center',
},
firstContainer: {
width: '100%',
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'flex-start',
gap: 4,
paddingVertical: 18,
},
logo: {
backgroundColor: currentTheme.colors.tertiaryBlue,
borderRadius: 10,
cursor: 'pointer',
},
navLinks: {
flexDirection: 'row',
flexWrap: 'wrap',
gap: 16,
margin: 10,
fontSize: 14,
color: currentTheme.colors.textPrimary,
paddingBottom: 40,
},
navItem: { color: currentTheme.colors.textPrimary },
credit: {
color: currentTheme.colors.textPrimary,
fontSize: 13,
textAlign: xs ? 'center' : 'left',
fontWeight: 'normal',
paddingTop: sm || md ? 10 : 'auto',
},
lastContainer: {
display: 'flex',
flexWrap: 'wrap-reverse',
flexDirection: sm ? 'column-reverse' : 'row',
alignItems: 'center',
justifyContent: 'space-between',
width: sm || md ? 'auto' : '95%',
},
});
};
6 changes: 5 additions & 1 deletion packages/app/modules/feed/components/FeedCard/FeedCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,27 @@ import {
feedItemPackCardConverter,
feedItemTripCardConverter,
feedItemPackTemplateCardConverter,
feedItemCardConverter,
} from './utils';
import { PackCard } from 'app/modules/pack';
import { type CardType } from '@packrat/ui';
import { useAddFavorite } from 'app/modules/feed';
import { useAuthUser } from 'app/modules/auth';
import { TripCard } from 'app/modules/trip';
import { PackTemplateCard } from 'app/modules/pack-templates';
import { ItemCard } from 'app/modules/item';

const convertersByType = {
pack: feedItemPackCardConverter,
trip: feedItemTripCardConverter,
item: feedItemCardConverter,
packTemplate: feedItemPackTemplateCardConverter,
};

const cardComponentsByType = {
const cardComponentsByType: Record<FeedResource, React.FC<any>> = {
pack: PackCard,
trip: TripCard,
item: ItemCard,
packTemplate: PackTemplateCard,
};

Expand Down
9 changes: 8 additions & 1 deletion packages/app/modules/feed/components/FeedCard/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { type PackDetails } from 'app/modules/pack';
import { truncateString } from 'app/utils/truncateString';
import { type TripDetails } from 'modules/trip/model';
import { roundNumber } from 'app/utils';
import { RouterOutput } from 'app/trpc';
import { type RouterOutput } from 'app/trpc';

type Converter<Input, Result> = (
input: Input,
Expand Down Expand Up @@ -76,6 +76,13 @@ export const feedItemTripCardConverter: Converter<
};
};

export const feedItemCardConverter: Converter<
FeedItem,
RouterOutput['getPackTemplates'][0]
> = (input) => {
return { item: input };
};

export const feedItemPackTemplateCardConverter: Converter<
FeedItem,
RouterOutput['getPackTemplates'][0]
Expand Down
3 changes: 2 additions & 1 deletion packages/app/modules/feed/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export type FeedType =
| 'similarPacks'
| 'similarItems'
| 'packTemplates';
export type FeedResource = 'pack' | 'trip' | 'packTemplate';
export type FeedResource = 'pack' | 'item' | 'trip' | 'packTemplate';

export interface BaseFeedItem {
id: string;
Expand All @@ -25,6 +25,7 @@ export interface BaseFeedItem {
owner_id: string | { id: string };
createdAt: string;
owners: Array<{ any: any }>;
ga;
}

interface PackFeedItem extends BaseFeedItem {
Expand Down
Loading

0 comments on commit 5b01e51

Please sign in to comment.