Skip to content

Commit

Permalink
fix: merge conflicts && adding medication temp data back
Browse files Browse the repository at this point in the history
  • Loading branch information
MattCMcCoy committed Jan 30, 2024
1 parent b5da077 commit ad040ac
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 48 deletions.
13 changes: 11 additions & 2 deletions backend/db/migrations/init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,20 @@ CREATE TABLE IF NOT EXISTS medication (
CREATE TABLE IF NOT EXISTS files (
file_id serial NOT NULL UNIQUE,
file_name varchar NOT NULL,
group_id varchar NOT NULL,
upload_by varchar NOT NULL,
group_id integer NOT NULL,
upload_by integer NOT NULL,
upload_date timestamp,
file_size integer NOT NULL,
task_id varchar,
PRIMARY KEY (file_id)
-- add group id, upload by, task id foreign keys
);

-- Insert sample data into "medication" table
INSERT INTO medication (medication_id, medication_name)
VALUES
(1, 'Medication A'),
(2, 'Medication B'),
(3, 'Medication C'),
(4, 'Medication D'),
(5, 'Medication E')
14 changes: 0 additions & 14 deletions backend/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,6 @@ const docTemplate = `{
}
}
},
"/files/{fname}": {
"delete": {
"description": "Delete a file from database and S3 bucket",
"tags": [
"file"
],
"summary": "Delete a file",
"responses": {
"204": {
"description": "No Content"
}
}
}
},
"/medications": {
"get": {
"description": "get all user medications",
Expand Down
14 changes: 0 additions & 14 deletions backend/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,6 @@
}
}
},
"/files/{fname}": {
"delete": {
"description": "Delete a file from database and S3 bucket",
"tags": [
"file"
],
"summary": "Delete a file",
"responses": {
"204": {
"description": "No Content"
}
}
}
},
"/medications": {
"get": {
"description": "get all user medications",
Expand Down
9 changes: 0 additions & 9 deletions backend/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,6 @@ info:
title: Care-Wallet API
version: "1.0"
paths:
/files/{fname}:
delete:
description: Delete a file from database and S3 bucket
responses:
"204":
description: No Content
summary: Delete a file
tags:
- file
/files/upload:
post:
description: Upload a file to database and S3 bucket
Expand Down
12 changes: 9 additions & 3 deletions client/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import { Text } from 'react-native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { NavigationContainer, NavigationProp } from '@react-navigation/native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import Medication from './screens/Medication';
import MedList from './screens/Medication';
import Home from './assets/home.svg';
import DocPickerButton from './components/DocPickerButton';

export type ScreenNames = ['BottomNav', 'Landing'];
export type ScreenNames = ['BottomNav', 'Landing', 'TEMP-FileUpload'];
export type RootStackParamList = Record<ScreenNames[number], any>;
export type StackNavigation = NavigationProp<RootStackParamList>;

Expand All @@ -23,6 +24,11 @@ export default function App() {
options={{ headerShown: false }}
component={Tabs}
/>
<Stack.Screen
name="TEMP-FileUpload"
options={{ headerShown: true }}
component={DocPickerButton}
/>
</Stack.Navigator>
</NavigationContainer>
);
Expand All @@ -38,7 +44,7 @@ function Tabs() {
tabBarIcon: () => <Home color={'gray'} />,
tabBarLabel: () => <Text>Landing</Text>
}}
component={Medication}
component={MedList}
/>
</Tab.Navigator>
);
Expand Down
3 changes: 2 additions & 1 deletion client/screens/Medication.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import * as React from 'react';
import { View, Text } from 'react-native';
import { getAllMedications } from '../services/medication';
import { Medication } from '../types/medication';

export default function Medication() {
export default function MedList() {
const [medications, setMedications] = React.useState<Medication[]>();
React.useEffect(() => {
getAllMedications().then((med) => setMedications(med));
Expand Down
8 changes: 4 additions & 4 deletions client/services/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export const uploadFile = async (
uploadType: FileSystem.FileSystemUploadType.MULTIPART,
fieldName: 'file_data',
headers: {
'user_id': userId.toString(),
'group_id': groupId.toString()
user_id: userId.toString(),
group_id: groupId.toString()
}
}
);
Expand All @@ -28,6 +28,6 @@ export const uploadFile = async (
return res.status;
}
console.log('Upload failed!');
throw new Error('Upload failed!');
throw new Error(res?.body);
});
};
};
2 changes: 1 addition & 1 deletion client/services/medication.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios from 'axios';
import { api_url } from './api-links';
import { Medication } from '../types/app';
import { Medication } from '../types/medication';

export const getAllMedications = async (): Promise<Medication[]> => {
const response = await axios.get(`${api_url}/medications`);
Expand Down
File renamed without changes.

0 comments on commit ad040ac

Please sign in to comment.