Skip to content

Commit

Permalink
Merge pull request #79 from cmd-AJ/the-way-of-the-prince
Browse files Browse the repository at this point in the history
The way of the prince
  • Loading branch information
Jose-Prince authored Nov 14, 2024
2 parents bbdb4b2 + 20e59fe commit ea8e809
Show file tree
Hide file tree
Showing 8 changed files with 375 additions and 126 deletions.
47 changes: 44 additions & 3 deletions Scrum/Working/src/components/Btn/BtnEditUser.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { IonButton } from "@ionic/react";
import './BtnStyles.css';
import React from "react";
import { updatecuenta, updatecuentaNEO4J } from "../../controller/UserController";
import React, { useEffect, useState } from "react";
import { addJobToWorker, getJobsWithDpi, updatecuenta, updatecuentaNEO4J } from "../../controller/UserController";
import { getJobsList } from "../../controller/HireControler";
import { addjob_toprofile } from "../../controller/Admin_Controller";

type User = {
nombre : string;
Expand All @@ -20,6 +22,11 @@ type User = {
isworking: boolean;
};

type Trabajo = {
descripcion: string
nombre_trabajo: string
}

interface ContainerProps {
user: User;
banner: string;
Expand All @@ -35,6 +42,7 @@ interface ContainerProps {
validatesCell: boolean
setUser: (user: User) => void
setEdit: (edit: boolean) => void
list : Array<Trabajo>
}

const BtnEditUser: React.FC<ContainerProps> = ({
Expand All @@ -50,9 +58,30 @@ const BtnEditUser: React.FC<ContainerProps> = ({
municipio,
validateBirthdate,
validateEmail,
validatesCell
validatesCell,
list
}) => {

const [allJobs, setAllJobs] = useState<Array<Trabajo>>([]);
const [myJobs, setMyJobs] = useState<Array<Trabajo>>([]);

useEffect(() => {
const fetchJobs = async () => {
const jobs = await getJobsWithDpi(user.dpi)
setMyJobs(jobs)
}

fetchJobs()
},[user.dpi])

useEffect(() => {
const fetchAllJobs = async () => {
const jobs = await getJobsList();
setAllJobs(jobs);
};
fetchAllJobs();
}, []);

const handleClick = () => {
const updatedUser = {
...user,
Expand All @@ -65,6 +94,18 @@ const BtnEditUser: React.FC<ContainerProps> = ({
municipio: municipio
};

const jobsNotInMyJobs = list.filter(
(jobInList) => !myJobs.some((jobInMyJobs) => jobInMyJobs.nombre_trabajo === jobInList.nombre_trabajo)
)

jobsNotInMyJobs.forEach((job) => {
if (allJobs.some((jobInAllJobs) => jobInAllJobs.nombre_trabajo === job.nombre_trabajo)) {
addJobToWorker(user.dpi, job.nombre_trabajo)
} else {
addjob_toprofile(job.nombre_trabajo, user.dpi)
}
})

localStorage.setItem('User', JSON.stringify(updatedUser));
setUser(updatedUser);
if (validateBirthdate && validateEmail && validatesCell ) {
Expand Down
92 changes: 79 additions & 13 deletions Scrum/Working/src/components/Calendar/MonthCalendar.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,64 @@
import { useEffect, useState } from 'react'
import TextND from '../Txt/TextND'
import './calendar.css'
import { get_contrat_by_moventh } from '../../controller/UserController'
import Note from '../Dashboard/Note'

interface ContainerProps {
monthMatrix: Date[][]
monthNumber: number
setModal: (modal: boolean) => void;
setSelectedNote: (note: NoteData) => void;

}

interface NoteData {
idtrabajo: string
trabajador: string;
dia: string;
hora: string;
descripcion: string;
precio: string;
foto: string;
timestampcita: string
pago: string
}

const MonthCalendar : React.FC<ContainerProps> = ({monthMatrix}) => {
const MonthCalendar : React.FC<ContainerProps> = ({ monthMatrix, monthNumber, setModal, setSelectedNote }) => {

const [hiringsMonth, setHiringsMonth] = useState<NoteData[]>([])

useEffect(() => {
const data = localStorage.getItem('User')

const fetchData = async () => {
if (data) {
const userData = JSON.parse(data)
const hirings = await get_contrat_by_moventh(userData.dpi, monthNumber.toString())

setHiringsMonth(hirings)
}
}

fetchData()
}, [monthNumber])

useEffect(() => {
console.log("Updated hiringsMonth:", hiringsMonth);
}, [hiringsMonth]);


return (
<div style={{margin: "25px", marginTop: "0" }}>

<div style={{ margin: "25px", marginTop: "0" }}>
<div className="calendar-month">
<b className='day-item' style={{borderRadius: "15px 0 0 0"}}>
<b className='day-item' style={{ borderRadius: "15px 0 0 0" }}>
<TextND text='Lunes' size='small' hex='#000'/>
</b>
<b className='day-item'>
<TextND text='Martes' size='small' hex='#000'/>
</b>
<b className='day-item'>
<TextND text='Miercoles' size='small' hex='#000'/>
<TextND text='Miércoles' size='small' hex='#000'/>
</b>
<b className='day-item'>
<TextND text='Jueves' size='small' hex='#000'/>
Expand All @@ -29,21 +69,47 @@ const MonthCalendar : React.FC<ContainerProps> = ({monthMatrix}) => {
<b className='day-item'>
<TextND text='Sábado' size='small' hex='#000'/>
</b>
<b className='day-item' style={{ borderRadius: "0 15px 0 0"}}>
<b className='day-item' style={{ borderRadius: "0 15px 0 0" }}>
<TextND text='Domingo' size='small' hex='#000'/>
</b>
{
monthMatrix.flat().map((day, index) => (
<div key={index} className='grid-item'>
<div style={{display: "flex", width: "100%", justifyContent: 'flex-end', padding: "10px"}}>
{day.getDate() > 0 ? day.getDate() : null}
monthMatrix.flat().map((day, index) => {
// Filtramos las contrataciones que coinciden con el día actual

return (
<div key={index} className='grid-item'>
<div style={{ display: "flex", width: "100%", justifyContent: 'flex-end', padding: "10px", flexDirection: 'column' }}>
<div>{day.getDate() > 0 ? day.getDate() : null}</div>
{hiringsMonth.map((hiring, i) => (

<>
{
day.getDate() === new Date(hiring.timestampcita).getDate() &&
<div key={i}
onClick={() => {
setModal(true)
setSelectedNote(hiring)
console.log(hiring);

}}>
<Note
trabajador={hiring.trabajador}
hora=''
descripcion={hiring.descripcion}
foto=''
/>
</div>
}
</>
))}
</div>
</div>
</div>
))
);
})
}
</div>
</div>
)
}

export default MonthCalendar
export default MonthCalendar
3 changes: 1 addition & 2 deletions Scrum/Working/src/components/Calendar/calendar.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
}

.daynumbers-display {
display: grid;
grid-template-rows: 300px 300px 300px 300px 300px 300px;
display: flex;
padding: 10px;
overflow: auto;
}
Expand Down
3 changes: 3 additions & 0 deletions Scrum/Working/src/components/Dashboard/GridWeek.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ import './gridWeek.css';
import Note from './Note';

interface NoteData {
idtrabajo: string
trabajador: string;
dia: string;
hora: string;
descripcion: string; // Cambiar de 'descripción' a 'descripcion'
precio: string;
foto: string;
timestampcita: string
pago: string
}


Expand Down
Loading

0 comments on commit ea8e809

Please sign in to comment.