-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
163 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,49 @@ | ||
import { useDispatch, useSelector, } from "react-redux"; | ||
import { getCollaboratorsData } from "../store/reducers/CollaboratorsCall/getCollaboratorsData"; | ||
import { useEffect,useState } from "react"; | ||
import CollaboratorsCardIndividual from "./CollaboratorsCardIndividual"; | ||
import { RootState } from "../store/store"; | ||
const CollaboratorsCard = ({title}: {title: string}) => { | ||
//variables del componente | ||
|
||
const [windowWidth, setWindowWidth] = useState(window.innerWidth); | ||
|
||
//Variables Redux// | ||
const dispatch = useDispatch(); | ||
|
||
const {collaborators, maxWidth} = useSelector((state:RootState)=> state.getCollaboratorsFunctionality); | ||
|
||
//Inicialization of the api// | ||
useEffect(()=>{ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
dispatch(getCollaboratorsData() as any); | ||
const handleResize = () => { | ||
setWindowWidth(window.innerWidth); | ||
}; | ||
|
||
window.addEventListener('resize', handleResize); | ||
|
||
},[dispatch]); | ||
|
||
//collaborators function | ||
|
||
const collaboratorsDataSlice =()=>{ | ||
|
||
//Colocar el 750 centralizado en redux en una variable// | ||
if(windowWidth>maxWidth && title !='modal'){ | ||
return collaborators.slice(0,15) | ||
}else if(windowWidth<maxWidth && title !='modal'){ | ||
return collaborators.slice(0,4) | ||
} | ||
return collaborators; | ||
} | ||
return ( | ||
<div className="card"> | ||
<p>{title}</p> | ||
</div> | ||
<div className="grid grid-cols-1 gap-y-5 md:w-11/12 m-auto md:grid-cols-3 lg:grid-cols-3"> | ||
|
||
<CollaboratorsCardIndividual collaboratorsDataSlice={collaboratorsDataSlice}/> | ||
</div> | ||
) | ||
} | ||
|
||
|
||
export default CollaboratorsCard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { collaborator } from "../interfaces/interfaces"; | ||
|
||
interface CollaboratorsCardIndividualProps { | ||
collaboratorsDataSlice: () => collaborator[]; | ||
} | ||
export const CollaboratorsCardIndividual: React.FC<CollaboratorsCardIndividualProps> = ({ collaboratorsDataSlice }) => { return ( | ||
<> | ||
|
||
{ | ||
collaboratorsDataSlice().map((a:collaborator, index:number)=>{ | ||
|
||
{/**Colocar en un componente card */} | ||
return <div className="w-2/3 m-auto" key={index} > <a className="flex items-center justify-center "href={a.url} target="_blank" > <img className="w-32 md:w-20 rounded-full" src={a.photo} alt={a.name+ ' photo'} /> <p className="ms-5 w-full text-start">{a.name}</p> </a> </div> | ||
}) | ||
} | ||
</> | ||
) | ||
} | ||
|
||
export default CollaboratorsCardIndividual; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/store/reducers/CollaboratorsCall/getCollaboratorsData.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { createAsyncThunk } from "@reduxjs/toolkit"; | ||
import axios from "axios"; | ||
|
||
export const getCollaboratorsData = createAsyncThunk( | ||
'getinitialdataCollaborators', | ||
async () => { | ||
try { | ||
const { data } = await axios.get('http://87.106.229.119/api/collaborators/landing'); | ||
|
||
const dataTotal = data.sort(() => Math.random() - 0.5); | ||
return dataTotal; | ||
|
||
|
||
|
||
} catch (error) { | ||
console.log(error); | ||
} | ||
} | ||
); |
31 changes: 31 additions & 0 deletions
31
src/store/reducers/CollaboratorsCall/getCollaboratorsFunctionality.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { createSlice } from '@reduxjs/toolkit' | ||
import { getCollaboratorsData } from './getCollaboratorsData' | ||
|
||
const initialState = { | ||
|
||
collaborators:[], | ||
maxWidth:750 | ||
|
||
} | ||
export const apiSlice = createSlice({ | ||
name: 'CollaboratorsCard', | ||
initialState, | ||
reducers: { | ||
|
||
},extraReducers:(builder)=>{ | ||
|
||
builder.addCase(getCollaboratorsData.fulfilled,(state,action)=>{ | ||
state.collaborators = action.payload; | ||
|
||
}) | ||
} | ||
}) | ||
|
||
//export const {} = apiSlice.actions; | ||
|
||
|
||
|
||
|
||
|
||
|
||
export default apiSlice.reducer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters