Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix quotes #161

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

14 changes: 9 additions & 5 deletions dashboard/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,12 @@ function App() {
setActivities(json)
}
)
fetch('https://api.quotable.io/random?tags=wisdom|future|humor').then(response => response.json()).then(
data => setQuote(data)
fetch('/api/quotes/').then(response => response.json()).then(
data => {
if (data.length > 0) {
setQuote(data[0])
}
}
);

if (isTodayInDates(unavailableDates)) {
Expand Down Expand Up @@ -844,9 +848,9 @@ function App() {
}
{ quote ?
<div className='quote-container'>
<Typography className='quote'>{quote['content']}</Typography>
{quote['author'] ?
<Typography className='quote-author'> — {quote['author']}</Typography>
<Typography className='quote'>{quote['q']}</Typography>
{quote['a'] ?
<Typography className='quote-author'> — {quote['a']}</Typography>
: ''
}
</div> : ''}
Expand Down
42 changes: 21 additions & 21 deletions dashboard/webpack-stats.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
{
"status": "done",
"assets": {
"App.ee2c3298e95d078be818.js": {
"name": "App.ee2c3298e95d078be818.js",
"path": "/Users/user/Documents/Kartoza/timesheet-project/dashboard/assets/webpack_bundles/App.ee2c3298e95d078be818.js"
"App.702fa133ea35517198b9.js": {
"name": "App.702fa133ea35517198b9.js",
"path": "/Users/user/Documents/Kartoza/timesheet-project/dashboard/assets/webpack_bundles/App.702fa133ea35517198b9.js"
},
"Space.a2f2c15f28deadbeaca6.js": {
"name": "Space.a2f2c15f28deadbeaca6.js",
"path": "/Users/user/Documents/Kartoza/timesheet-project/dashboard/assets/webpack_bundles/Space.a2f2c15f28deadbeaca6.js"
},
"Summary.8f289a45b4cd750eefc8.js": {
"name": "Summary.8f289a45b4cd750eefc8.js",
"path": "/Users/user/Documents/Kartoza/timesheet-project/dashboard/assets/webpack_bundles/Summary.8f289a45b4cd750eefc8.js"
"Summary.97f908bf5e34dbe1ebb1.js": {
"name": "Summary.97f908bf5e34dbe1ebb1.js",
"path": "/Users/user/Documents/Kartoza/timesheet-project/dashboard/assets/webpack_bundles/Summary.97f908bf5e34dbe1ebb1.js"
},
"PublicSummary.ac635ec3fa79ea68500c.js": {
"name": "PublicSummary.ac635ec3fa79ea68500c.js",
"path": "/Users/user/Documents/Kartoza/timesheet-project/dashboard/assets/webpack_bundles/PublicSummary.ac635ec3fa79ea68500c.js"
"PublicSummary.2cc0833084b1360496ae.js": {
"name": "PublicSummary.2cc0833084b1360496ae.js",
"path": "/Users/user/Documents/Kartoza/timesheet-project/dashboard/assets/webpack_bundles/PublicSummary.2cc0833084b1360496ae.js"
},
"Planner.da2209d173b9badd1e53.js": {
"name": "Planner.da2209d173b9badd1e53.js",
Expand Down Expand Up @@ -169,39 +169,39 @@
"name": "762.3c9e2283db5a7d9b5d83.js.LICENSE.txt",
"path": "/Users/user/Documents/Kartoza/timesheet-project/dashboard/assets/webpack_bundles/762.3c9e2283db5a7d9b5d83.js.LICENSE.txt"
},
"App.ee2c3298e95d078be818.js.LICENSE.txt": {
"name": "App.ee2c3298e95d078be818.js.LICENSE.txt",
"path": "/Users/user/Documents/Kartoza/timesheet-project/dashboard/assets/webpack_bundles/App.ee2c3298e95d078be818.js.LICENSE.txt"
"App.702fa133ea35517198b9.js.LICENSE.txt": {
"name": "App.702fa133ea35517198b9.js.LICENSE.txt",
"path": "/Users/user/Documents/Kartoza/timesheet-project/dashboard/assets/webpack_bundles/App.702fa133ea35517198b9.js.LICENSE.txt"
},
"Planner.da2209d173b9badd1e53.js.LICENSE.txt": {
"name": "Planner.da2209d173b9badd1e53.js.LICENSE.txt",
"path": "/Users/user/Documents/Kartoza/timesheet-project/dashboard/assets/webpack_bundles/Planner.da2209d173b9badd1e53.js.LICENSE.txt"
},
"PublicSummary.ac635ec3fa79ea68500c.js.LICENSE.txt": {
"name": "PublicSummary.ac635ec3fa79ea68500c.js.LICENSE.txt",
"path": "/Users/user/Documents/Kartoza/timesheet-project/dashboard/assets/webpack_bundles/PublicSummary.ac635ec3fa79ea68500c.js.LICENSE.txt"
"PublicSummary.2cc0833084b1360496ae.js.LICENSE.txt": {
"name": "PublicSummary.2cc0833084b1360496ae.js.LICENSE.txt",
"path": "/Users/user/Documents/Kartoza/timesheet-project/dashboard/assets/webpack_bundles/PublicSummary.2cc0833084b1360496ae.js.LICENSE.txt"
},
"Space.a2f2c15f28deadbeaca6.js.LICENSE.txt": {
"name": "Space.a2f2c15f28deadbeaca6.js.LICENSE.txt",
"path": "/Users/user/Documents/Kartoza/timesheet-project/dashboard/assets/webpack_bundles/Space.a2f2c15f28deadbeaca6.js.LICENSE.txt"
},
"Summary.8f289a45b4cd750eefc8.js.LICENSE.txt": {
"name": "Summary.8f289a45b4cd750eefc8.js.LICENSE.txt",
"path": "/Users/user/Documents/Kartoza/timesheet-project/dashboard/assets/webpack_bundles/Summary.8f289a45b4cd750eefc8.js.LICENSE.txt"
"Summary.97f908bf5e34dbe1ebb1.js.LICENSE.txt": {
"name": "Summary.97f908bf5e34dbe1ebb1.js.LICENSE.txt",
"path": "/Users/user/Documents/Kartoza/timesheet-project/dashboard/assets/webpack_bundles/Summary.97f908bf5e34dbe1ebb1.js.LICENSE.txt"
}
},
"chunks": {
"App": [
"App.ee2c3298e95d078be818.js"
"App.702fa133ea35517198b9.js"
],
"Space": [
"Space.a2f2c15f28deadbeaca6.js"
],
"Summary": [
"Summary.8f289a45b4cd750eefc8.js"
"Summary.97f908bf5e34dbe1ebb1.js"
],
"PublicSummary": [
"PublicSummary.ac635ec3fa79ea68500c.js"
"PublicSummary.2cc0833084b1360496ae.js"
],
"Planner": [
"Planner.da2209d173b9badd1e53.js"
Expand Down
13 changes: 13 additions & 0 deletions timesheet/api_views/quotes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import requests
from rest_framework.response import Response
from rest_framework.views import APIView


class RandomQuotes(APIView):

def get(self, request):
quote_api_url = 'https://zenquotes.io/api/random'
quote_response = requests.get(quote_api_url)
if quote_response.status_code == 200:
return Response(quote_response.json())
return Response([])
7 changes: 6 additions & 1 deletion timesheet/urls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from django.urls import path, include
from rest_framework import routers

from timesheet.api_views.quotes import RandomQuotes
from timesheet.api_views.timesheet import (
TimesheetModelViewSet,
TimesheetViewSet,
Expand Down Expand Up @@ -59,5 +61,8 @@
name='user-activities'),
path('api/user-leaderboard/',
UserLeaderBoard.as_view(),
name='user-leaderboard')
name='user-leaderboard'),
path('api/quotes/',
RandomQuotes.as_view(),
name='random-quotes'),
]
Loading