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

Master #2

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
1,260 changes: 1,222 additions & 38 deletions package-lock.json

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,16 @@
"lint": "next lint"
},
"dependencies": {
"@tanstack/react-query": "^4.20.4",
"@tanstack/react-query-devtools": "^4.20.4",
"@types/react-scroll": "^1.8.5",
"axios": "^1.2.1",
"next": "13.0.7",
"react": "18.2.0",
"react-dom": "18.2.0"
"react-dom": "18.2.0",
"react-drag-drop-files": "^2.3.8",
"react-icons": "^4.7.1",
"react-scroll": "^1.8.9"
},
"devDependencies": {
"@types/node": "18.11.15",
Expand Down
8 changes: 0 additions & 8 deletions pages/_app.tsx

This file was deleted.

10 changes: 0 additions & 10 deletions pages/index.tsx

This file was deleted.

File renamed without changes.
42 changes: 42 additions & 0 deletions src/components/Acordion.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import React, { FC } from "react";
import { accordion } from "../types/types";
import Arrow from "./Arrow";
import NoteCard from "./NoteCard";
import ProgressBar from "./ProgressBar";

const Acordion: FC<accordion> = ({ subjects, progressPercentage }) => {
return (
<div className="relative w-full overflow-hidden p-4">
<input
type="checkbox"
className="peer absolute top-0 inset-x-0 w-full h-12 opacity-0 z-10 cursor-pointer"
/>
<div className="bg-blue-500 h-12 w-full pl-5 flex items-center rounded-t-lg">
<h1 className="text-lg font-semibold text-white">Primer Año</h1>
</div>
{/* progress bar */}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need of comments like this

<ProgressBar progressPercentage={progressPercentage} />
{/* Arrow */}
<Arrow />
{/* Content */}
<div className="max-h-0 peer-checked:max-h-96 bg-transparent overflow-hidden transition-all duration-500">
<div className="grid grid-cols-6 gap-5 place-items-center p-4">
{subjects.map((course) => (
<NoteCard
key={course.id}
id={course.id}
name={course.name}
semester={course.semester}
ordinal_year={course.ordinal_year}
grade={course.grade}
credit={course.credit}
status={course.status}
/>
))}
</div>
</div>
</div>
);
};

export default Acordion;
12 changes: 12 additions & 0 deletions src/components/Arrow.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from "react";
import { AiOutlineRight } from "react-icons/ai";

const Arrow = () => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add type :React.FC

return (
<div className="absolute top-6 right-6 text-white transition-transform duration-500 rotate-0 peer-checked:rotate-90">
<AiOutlineRight size={30} />
</div>
);
};

export default Arrow;
9 changes: 9 additions & 0 deletions src/components/BlueDegrade.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from "react";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is a way to avoid importing React on all files 🤔


const BlueDegrade = () => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FC missing

return (
<div className="text-center -z-5 grid place-items-center top-28 h-52 w-full absolute bg-gradient-to-b from-cmf_blue to-transparent"></div>
);
};

export default BlueDegrade;
47 changes: 47 additions & 0 deletions src/components/DragArea.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import React, { FC, useEffect } from "react";
import { FileUploader } from "react-drag-drop-files";
import { dragdropArea, notes } from "../types/types";
import { useNotas } from "./../hooks/useNotas";

const DragArea: FC<dragdropArea> = ({
file,
dropFile,
setNoteData,
noteData,
}) => {
const fileTypes = ["PDF"];
const { data, mutate } = useNotas();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spanish detected ⚰️

useEffect(() => {
setNoteData(data?.data);
}, [data]);

return (
<div
className={`text-3xl top-0 left-0 w-full ${
noteData ? "hidden" : "block"
}`}
>
<div className="text-center -z-5 grid place-items-center top-28 h-52 w-full absolute bg-gradient-to-b from-cmf_blue to-transparent">
<p className="text-white"> Bienvenido a CMF para egresar</p>
</div>
<div className=" h-[58rem] px-8 pb-8 ">
<FileUploader
hoverTitle={"dropealo aca"}
types={fileTypes}
//handleChange={(file: File) => dropFile(file)}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comments always if not necessary

handleChange={(file: File) => {
return mutate({ file });
}}
>
<div className="h-full w-full text-4xl text-white flex flex-col items-center justify-center gap-52 border-4 border-dotted border-cmf_blue">
<p className="text-cmf_blue">Sube tu libreta</p>
</div>
</FileUploader>
{/* <button onClick={() => mutate({ file })}>Apretameeeee</button> */}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀

</div>
</div>
);
};

export default DragArea;
//${file ? "hidden" : "block"}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀

19 changes: 19 additions & 0 deletions src/components/Myheader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from "react";
import Navbar from "./Navbar";
import { FaBars } from "react-icons/fa";
import useModal from "../hooks/useModal";
import Navbarmobile from "./Navbarmobile";

const Myheader = () => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MyHeader camel case on components

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also .FC missing

const { modal, settingModal } = useModal();
return (
<div className="sticky top-0 z-50 flex items-center text-white justify-between bg-cmf_blue h-28 p-10">
<h1 className="text-7xl tex">CMF</h1>
<Navbar></Navbar>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<Navbar/>

<FaBars className="md:hidden" size={40} onClick={settingModal} />
<Navbarmobile modal={modal} settingModal={settingModal} />
</div>
);
};

export default Myheader;
18 changes: 18 additions & 0 deletions src/components/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import Link from "next/link";
import React from "react";

const Navbar = () => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NavBar could be a directory and have NavBarMobile and NavBarDesktop inside of it

return (
<div className="hidden md:block">
<nav>
<ul>
<li className="text-4xl">
<Link href={"#"}>Más</Link>
</li>
</ul>
</nav>
</div>
);
};

export default Navbar;
33 changes: 33 additions & 0 deletions src/components/Navbarmobile.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import Link from "next/link";
import React from "react";
import { AiOutlineClose } from "react-icons/ai";
import { FC } from "react";
import { navbarmodal } from "../types/types";

const Navbarmobile: FC<navbarmodal> = ({ modal, settingModal }) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NavBarMobile maybe?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

types should be always capitalized
navbarmodal -> NavBarProps

return (
<div
className={` ${

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space not needed

modal ? "absolute" : "hidden"
} top-0 left-0 w-full h-screen bg-gradient-to-b from-cmf_blue grid place-items-center`}
// className={`${
// modal ? "absolute" : "hidden"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment 👀

// } w-screen h-full text-black text-center bg-gradient-to-b from-cmf_blue`}
>
<div className="absolute top-1 right-1">
<AiOutlineClose size={40} onClick={settingModal} />
</div>
<nav>
<ul>
<li className="text-4xl">
<Link onClick={settingModal} href={"#"}>
CMF Notas
</Link>
</li>
</ul>
</nav>
</div>
);
};

export default Navbarmobile;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀 you should also change the file name

28 changes: 28 additions & 0 deletions src/components/NoteCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React, { FC } from "react";
import { NoteCard } from "../types/types";

const NoteCard: FC<NoteCard> = ({

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use NoteCardProps to avoid component name repetition.
Also to import just types you could use:

import type { NoteCardProps } from ...

id,
name,
semester,
ordinal_year,
grade,
credit,
status,
}) => {
return (
<div
className={`rounded-md text-center text-white w-48 ${
status === "Aprobado" ? "bg-green-600" : "bg-red-500"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yoy could use an enum for status

enum NoteStatus {
 Approved
 Disapproved
}

}`}
>
<p>Nombre:{name}</p>
<p>Semestre:{semester}</p>
<p>Año:{ordinal_year}</p>
<p>Grado:{grade}</p>
<p>Credito:{credit}</p>
</div>
);
};

export default NoteCard;
120 changes: 120 additions & 0 deletions src/components/Notesinfo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
import React, { FC, useEffect } from "react";
import { NoteCard, notesInfo } from "../types/types";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import type { ...

import Acordion from "./Acordion";
import BlueDegrade from "./BlueDegrade";
import { RiArrowUpSLine } from "react-icons/ri";
import { animateScroll as scroll } from "react-scroll";
import { scroller } from "react-scroll";

const Notesinfo: FC<notesInfo> = ({ notes }) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Camel plz 🙏
Notesinfo -> NotesInfo
also file name 👀

const years = ["1er", "2do", "3ero", "4to", "5to", "6to", "7mo"];
useEffect(() => {
// scroll.scrollTo("datos");
// window.scrollTo(0, 700);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀

//550
if (window.innerWidth > 550) {
scroller.scrollTo("linkdatos", { duration: 50, offset: -80 });
} else {
scroller.scrollTo("linkdatos", { duration: 50, offset: -120 });
}
}, []);
const scrollToTop = () => {
scroll.scrollToTop();
};
const progressPercentage = 80;
const cardstest = {
subjects: [
{
id: 1,
name: "test1",
semester: 1,
ordinal_year: 1,
grade: 19,
credit: 4.0,
status: "aprobado",
},
{
id: 2,
name: "test2",
semester: 2,
ordinal_year: 1,
grade: 19,
credit: 4.0,
status: "aprobado",
},
{
id: 3,
name: "test3",
semester: 3,
ordinal_year: 2,
grade: 19,
credit: 4.0,
status: "desaprobado",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we may use Storybook to have a components sketch of every component for testing
https://storybook.js.org/

},
],
total_passed_credits: 210.0,
total_non_passed_credits: 0,
mean_grades: 13.327586206896552,
student: {
name: "APAZA/TORRES, ALEXANDER RUSVELL",
grade: "PRE-GRADO",
school: "CIENCIA DE LA COMPUTACION",
},
card_date: "21.08.26 12:09:39",
};
const notesObject = notes.subjects.reduce(
(cache, item) => {
console.log(cache.length);
if (cache.length === item.ordinal_year) {
cache[cache.length - 1].push(item);
} else {
cache.push([item]);
}
return cache;
},
[[]] as NoteCard[][]
);

console.log(notesObject);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

console.log should never be commited

return (
<div>
{/* <div className="text-center -z-5 grid place-items-center top-28 h-52 w-full absolute bg-gradient-to-b from-cmf_blue to-transparent"></div> */}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀

<BlueDegrade />

<div
className="h-screen grid place-content-center text-center"
id="datos"
>
<h1 className="text-3xl"> Bienvenido {notes.student.name}</h1>
<p>El grado de estudio es: {notes.student.grade}</p>
<p>La escuela en la que se encuentra es: {notes.student.school}</p>
<p>Los Creditos actuales son: {notes.total_passed_credits} </p>
<p>Los Creditos faltantes son: {notes.total_non_passed_credits}</p>
<p>El promedio de todas las notas actuales es: {notes.mean_grades} </p>
<p>
La fecha y hora en la que se saco la libreta de notas es:
{notes.card_date}
</p>
</div>
<div className="flex justify-center" id="linkdatos">

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id first 🙏 . Also, spanish detected 👀

<div
className="flex flex-col items-center w-36 cursor-pointer"
onClick={scrollToTop}
>
<RiArrowUpSLine size={20} />
<p className="text-center">Desliza arriba para ver tus datos</p>
</div>
</div>
<div className="mb-5">
{notesObject.map((grade, index) => (
<Acordion key={index} subjects={grade} progressPercentage={80} />
))}
<Acordion
progressPercentage={progressPercentage}
subjects={notes.subjects}
/>
</div>
</div>
);
};
export default Notesinfo;
21 changes: 21 additions & 0 deletions src/components/ProgressBar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React, { FC } from "react";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

React not need, I think this was the library to avoid importing React all the time: https://www.npmjs.com/package/eslint-plugin-react

import { progressBar } from "../types/types";

const ProgressBar: FC<progressBar> = ({ progressPercentage }) => {
return (
<div className="h-1 w-full bg-gray-300">
<div
style={{ width: `${progressPercentage}%` }}
className={`h-full ${
progressPercentage < 45
? "bg-red-500"
: progressPercentage < 80
? "bg-orange-400"
: "bg-green-300"
}`}
></div>
</div>
);
};

export default ProgressBar;
Loading