Skip to content

Commit

Permalink
added card icons and username to template
Browse files Browse the repository at this point in the history
  • Loading branch information
okrayum committed Jul 6, 2024
1 parent f2ba9e6 commit 7f0d61f
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 11 deletions.
9 changes: 9 additions & 0 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@
"axios": "^1.7.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-icons": "^5.2.1",
"react-modal": "^3.16.1",
"react-router-dom": "^6.23.1",
"recharts": "^2.12.7",
"react-toastify": "^10.0.5",
"recharts": "^2.12.7",
"uuid": "^10.0.0"
},
"devDependencies": {
Expand Down
9 changes: 6 additions & 3 deletions client/src/components/BoardComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import CardDetails from "./CardDetails";
import ProgressBar from "./ProgressBar";
import { useBoard } from "../context/BoardContext";
import { useTemplates } from "../context/TemplateContext";
import { MdOutlineTimer, MdOutlineCheckBox } from "react-icons/md";

const BoardComponent: React.FC = () => {
const [estimatedTimeTotal, setEstimatedTimeTotal] = useState(0);
Expand Down Expand Up @@ -238,12 +239,13 @@ const BoardComponent: React.FC = () => {
className="bg-white p-2 mb-2 rounded shadow"
onClick={() => setSelectedCard(card)}
>
<h3 className="font-semibold">
<h3 className="font-semibold text-left">
{card.cardName}
</h3>
{card.details.timeEstimate &&
card.details.timeEstimate > 0 ? (
<p>
<p className="flex items-center">
<MdOutlineTimer aria-hidden="true" className="mr-1"/>
{card.details.timeEstimate}{" "}
minutes
</p>
Expand All @@ -253,7 +255,8 @@ const BoardComponent: React.FC = () => {
{card.details.checklist &&
card.details.checklist.length >
0 && (
<p>
<p className="flex items-center">
<MdOutlineCheckBox aria-hidden="true" className="mr-1"/>
{
card.details.checklist.filter(
(item) => item.checked
Expand Down
10 changes: 6 additions & 4 deletions client/src/components/TemplatePreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import React from "react";
import { Template } from "../types";
import { useTemplates } from "../context/TemplateContext";
import { useBoard } from "../context/BoardContext";
import { MdOutlineTimer } from "react-icons/md";
import { PiDownloadSimple, PiCards, PiUploadSimple } from "react-icons/pi";

interface TemplatePreviewProps {
template: Template;
Expand Down Expand Up @@ -36,10 +38,10 @@ const TemplatePreview: React.FC<TemplatePreviewProps> = ({ template }) => {
{template.name}
</h1>

<p>Total cards: {template.cards!.length - 1}</p>
<p># Downloads: {template.downloads}</p>
<p>Length: {getTotalLength()} Minutes</p>
<p>Author: {template.author}</p>
<p className="flex items-center">{<PiCards aria-hidden="true" className="mr-1"/>}Total cards: {template.cards!.length - 1}</p>
<p className="flex items-center">{<PiDownloadSimple aria-hidden="true" className="mr-1"/>}Downloads: {template.downloads}</p>
<p className="flex items-center">{<MdOutlineTimer aria-hidden="true" className="mr-1"/>}Length: {getTotalLength()} Minutes</p>
<p className="flex items-center">{<PiUploadSimple aria-hidden="true" className="mr-1"/>}Author: {template.author}</p>
</div>
);
};
Expand Down
6 changes: 3 additions & 3 deletions client/src/hooks/usePostNewTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const usePostNewTemplate = () => {
const [error, setError] = useState<Error | null>(null);
const { user } = useAuth0();

const email: string = user?.email ?? "anonymous@somethingwentwronghere.com";
// const username: string = email.split("@")[0]; // would like to use this instead of email
const username: string = user?.given_name ?? user?.nickname ?? "anonymous";
// const username: string = email.split("@")[0];

const postNewTemplate = async (template: Board) => {
setIsLoading(true);
Expand All @@ -19,7 +19,7 @@ const usePostNewTemplate = () => {
`${import.meta.env.VITE_BACKEND_URL}/api/templates`,
{
name: template.name,
author: email,
author: username,
uuid: template.uuid,
downloads: 0,
uploaded_at: new Date(),
Expand Down

0 comments on commit 7f0d61f

Please sign in to comment.