Skip to content

Commit

Permalink
Format fix
Browse files Browse the repository at this point in the history
  • Loading branch information
stoneliuCS committed Dec 1, 2024
1 parent 4713c01 commit c990665
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 24 deletions.
2 changes: 1 addition & 1 deletion backend/src/controllers/user/putUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const userService: UserService = new UserServiceImpl();

//Will get the user by the given ID
export const putUser = async (req: express.Request, res: express.Response) => {
console.log("Putting user!");
console.log('Putting user!');
try {
const userId = req.session.userId;
if (!userId) {
Expand Down
9 changes: 8 additions & 1 deletion backend/src/models/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ const UserSchema = new mongoose.Schema({
lastName: { type: String },
badges: {
type: [String],
enum: ['Deep Diver', 'First Catch', 'Ocean Explorer', '100 Dives Logged', 'Reef Guardian', 'Rare Fish Find'],
enum: [
'Deep Diver',
'First Catch',
'Ocean Explorer',
'100 Dives Logged',
'Reef Guardian',
'Rare Fish Find',
],
}, // badge is an array of enum
diveLogs: [{ type: mongoose.Schema.Types.ObjectId, ref: 'DiveLog' }],
speciesCollected: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Species' }],
Expand Down
37 changes: 18 additions & 19 deletions frontend/app/(app)/user/components/badges.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import DefaultBage from '../../../../assets/BadgeIcons/badge.svg';
import FishCaught100 from '../../../../assets/BadgeIcons/100-fishes-badge.svg';
import OceanExplorer from '../../../../assets/BadgeIcons/ocean-explorer-badge.svg';
import RareFishCaught from '../../../../assets/BadgeIcons/rare-fishes-badge.svg';
import FirstCatch from '../../../../assets/BadgeIcons/first-catch-badge.svg'
import ReefGuardian from '../../../../assets/BadgeIcons/reef-gaurdian-badge.svg'
import FirstCatch from '../../../../assets/BadgeIcons/first-catch-badge.svg';
import ReefGuardian from '../../../../assets/BadgeIcons/reef-gaurdian-badge.svg';

const Badges = ({ id }: { id: string }) => {
const { data, isError, isLoading } = useUserById(id);
Expand Down Expand Up @@ -40,29 +40,28 @@ const Badges = ({ id }: { id: string }) => {
);

type RenderBadge = {
name: string,
width: number,
height: number
}
name: string;
width: number;
height: number;
};

const RenderBagdeImage = ({ name, width, height }: RenderBadge) => {
switch (name) {
case "100 Dives Logged":
return (<FishCaught100 width={width} height={height} />)
case "Rare Fish Find":
return (<RareFishCaught width={width} height={height} />)
case "Ocean Explorer":
return (<OceanExplorer width={width} height={height} />)
case "Reef Guardian":
return (<ReefGuardian width={width} height={height} />)
case "First Catch":
return (<FirstCatch width={width} height={height} />)
case '100 Dives Logged':
return <FishCaught100 width={width} height={height} />;
case 'Rare Fish Find':
return <RareFishCaught width={width} height={height} />;
case 'Ocean Explorer':
return <OceanExplorer width={width} height={height} />;
case 'Reef Guardian':
return <ReefGuardian width={width} height={height} />;
case 'First Catch':
return <FirstCatch width={width} height={height} />;
default:
return (<DefaultBage width={width} height={height} />)
return <DefaultBage width={width} height={height} />;
}
};

}

return (
<View>
<Text className="font-bold text-base sm:text-lg md:text-xl pb-[2%] text-darkblue">
Expand Down
9 changes: 6 additions & 3 deletions frontend/app/(app)/user/components/user-profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ const User = ({ id }: { id: string }) => {
return (
<LinearGradient
colors={['#549ac7', '#ffffff', '#ffffff', '#ffffff']}
style={{ flex: 1 }}>
style={{ flex: 1 }}
>
<Stack.Screen
options={{
headerTitle: '',
Expand All @@ -37,10 +38,12 @@ const User = ({ id }: { id: string }) => {
!isViewingOwnProfile ? (
<Arrow direction="left" onPress={() => router.back()} />
) : null,
}}/>
}}
/>
<SafeAreaView
edges={['top', 'left', 'right']}
className="flex flex-1 mt-[10%]">
className="flex flex-1 mt-[10%]"
>
<FlatList
data={data}
renderItem={renderItem}
Expand Down

0 comments on commit c990665

Please sign in to comment.