diff --git a/backend/db/migrations/init.sql b/backend/db/migrations/init.sql index c8cf74d..013c574 100644 --- a/backend/db/migrations/init.sql +++ b/backend/db/migrations/init.sql @@ -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') diff --git a/backend/docs/docs.go b/backend/docs/docs.go index 25dea12..1c29687 100644 --- a/backend/docs/docs.go +++ b/backend/docs/docs.go @@ -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", diff --git a/backend/docs/swagger.json b/backend/docs/swagger.json index 2342e70..1ac678d 100644 --- a/backend/docs/swagger.json +++ b/backend/docs/swagger.json @@ -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", diff --git a/backend/docs/swagger.yaml b/backend/docs/swagger.yaml index c1eec40..0f4976b 100644 --- a/backend/docs/swagger.yaml +++ b/backend/docs/swagger.yaml @@ -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 diff --git a/client/App.tsx b/client/App.tsx index e266d1b..8176493 100644 --- a/client/App.tsx +++ b/client/App.tsx @@ -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; export type StackNavigation = NavigationProp; @@ -23,6 +24,11 @@ export default function App() { options={{ headerShown: false }} component={Tabs} /> + ); @@ -38,7 +44,7 @@ function Tabs() { tabBarIcon: () => , tabBarLabel: () => Landing }} - component={Medication} + component={MedList} /> ); diff --git a/client/screens/Medication.tsx b/client/screens/Medication.tsx index ecef132..d412928 100644 --- a/client/screens/Medication.tsx +++ b/client/screens/Medication.tsx @@ -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(); React.useEffect(() => { getAllMedications().then((med) => setMedications(med)); diff --git a/client/services/file.ts b/client/services/file.ts index dbb81b8..05cba91 100644 --- a/client/services/file.ts +++ b/client/services/file.ts @@ -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() } } ); @@ -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); }); -}; \ No newline at end of file +}; diff --git a/client/services/medication.ts b/client/services/medication.ts index 4d44521..d70b0ab 100644 --- a/client/services/medication.ts +++ b/client/services/medication.ts @@ -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 => { const response = await axios.get(`${api_url}/medications`); diff --git a/client/types/app.d.ts b/client/types/medication.ts similarity index 100% rename from client/types/app.d.ts rename to client/types/medication.ts