diff --git a/backend/api/serializers.py b/backend/api/serializers.py index 443d458..c109132 100644 --- a/backend/api/serializers.py +++ b/backend/api/serializers.py @@ -39,7 +39,7 @@ class StockSerializer(serializers.ModelSerializer): class StockCreateSerializer(serializers.ModelSerializer): class Meta: model = models.Stock - fields = ('user', 'ticker', 'quantity',) + fields = ('ticker', 'quantity',) class CharitySerializer(serializers.ModelSerializer): class Meta: diff --git a/backend/api/views.py b/backend/api/views.py index af1639f..1d9ed93 100644 --- a/backend/api/views.py +++ b/backend/api/views.py @@ -38,7 +38,8 @@ class StockViewSet(ModelViewSet): def create(self, request, *args, **kwargs): - data = QueryDict.copy(request.data) + import copy + data = copy.deepcopy(request.data) data.update({'user': request.user}) serializer = StockCreateSerializer(data=request.data) serializer.is_valid(raise_exception=True) @@ -81,4 +82,4 @@ class BuyRobinhoodStock(APIView): for key, value in stonks.items(): print(key) print(value) - return Response(stonks) \ No newline at end of file + return Response(stonks) diff --git a/frontend/.dockerignore b/frontend/.dockerignore new file mode 100644 index 0000000..93f1361 --- /dev/null +++ b/frontend/.dockerignore @@ -0,0 +1,2 @@ +node_modules +npm-debug.log diff --git a/frontend/Dockerfile b/frontend/Dockerfile new file mode 100644 index 0000000..2ca0b18 --- /dev/null +++ b/frontend/Dockerfile @@ -0,0 +1,22 @@ +## Build React App ## + +FROM node:14.15.4-buster as builder + +WORKDIR /app + +COPY package*.json ./ + +RUN npm install --silent + +RUN npm install react-scripts -g --silent + +COPY . . + +RUN npm run build + +## Run w/ Nginx ## +FROM nginx:alpine + +COPY --from=builder /app/build /usr/share/nginx/html + +EXPOSE 80 diff --git a/frontend/src/components/Browse.js b/frontend/src/components/Browse.js index 1c9d8af..a73b7b5 100644 --- a/frontend/src/components/Browse.js +++ b/frontend/src/components/Browse.js @@ -1,4 +1,5 @@ import React, { useState, useEffect } from "react"; +import { useHistory } from "react-router-dom"; import "./assets/Browse.css"; import Plotly from "plotly.js"; import createPlotlyComponent from "react-plotly.js/factory"; @@ -8,6 +9,8 @@ const Browse = (props) => { const [stockChartYValues, setStockChartYValues] = useState([]); const [days, setDays] = useState(30); const [stock, setStock] = useState("INTC"); + const [quantity, setQuantity] = useState(0); + const history = useHistory(); let stockChartXValuesList = []; let stockChartYValuesList = []; @@ -36,6 +39,23 @@ const Browse = (props) => { fetchStock(); }, [stock]); + const onSubmit = (e) => { + e.preventDefault(); + const requestOptions = { + method: "POST", + headers: { + "Content-Type": "application/json", + Authorization: `Bearer ${localStorage.getItem("token")}`, + }, + body: JSON.stringify({ ticker: stock, quantity: quantity }), + }; + fetch(`${process.env.REACT_APP_API_ENDPOINT}/stock/create`, requestOptions) + .then((response) => response.json()) + .then((data) => { + console.log(data); + }); + }; + return (
- ReInvest is a philanthropic platform where users can invest money - for charities. Instead of a simple donation, you can purchase stocks - for your charity of choice. This offers a great opportunity for you - to learn about stocks while helping your favorite organizations. - Scared of losing too much money? Our platform offers automatic stop - losses so that your organization doesn't lose more than a set - percentage of your initial donation. Additionally, you set the - percentage of profits that you get in return meanwhile your charity - gets the initial donation plus the rest of the profits. -
+ ++ Easily browse through stocks and see their past. Change the + scale of the graph to your pleasing. Then if you wish to hold + a position, specify the amount of money you wish to donate and + submit. +
++ Help out your favorite charities while learning and practicing + trading. The charities will receive the initial buy price. + Then, you can set a percentage of the profits that also goes + to charity. In this era, instead of a simple donation, you can + use our trading platform to trade for your charities. +
++ Easily manage your portfolio with Reinvest. Here you can see + all the positions you currently hold as well as the initial + buy price and quantity. You can sell the stock by clicking + Sell for the desired stock. You can also see the current + earnings for yourself and the charity. +
+