-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added sorting grants by clicking on header
- Loading branch information
1 parent
fe1c6f8
commit 2ffecab
Showing
8 changed files
with
268 additions
and
183 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
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,58 +1,65 @@ | ||
import React, {useState} from 'react'; | ||
import './styles/GrantItem.css'; | ||
import { GrantAttributes } from './GrantAttributes'; | ||
import GrantDetails from './GrantDetails'; | ||
import React, { useState } from "react"; | ||
import "./styles/GrantItem.css"; | ||
import { GrantAttributes } from "./GrantAttributes"; | ||
import GrantDetails from "./GrantDetails"; | ||
|
||
interface GrantItemProps { | ||
grantName: string; | ||
applicationDate: string; | ||
generalStatus: string; | ||
amount: number; | ||
restrictionStatus: string; | ||
export interface GrantItemProps { | ||
grantName: string; | ||
applicationDate: Date; | ||
generalStatus: string; | ||
amount: number; | ||
restrictionStatus: string; | ||
} | ||
const GrantItem: React.FC<GrantItemProps> = (props) => { | ||
const { grantName, applicationDate, generalStatus, amount, restrictionStatus } = props; | ||
const { | ||
grantName, | ||
applicationDate, | ||
generalStatus, | ||
amount, | ||
restrictionStatus, | ||
} = props; | ||
|
||
const [isExpanded, setIsExpanded] = useState(false); | ||
const [isEditing, setIsEditing] = useState(false); | ||
const [isExpanded, setIsExpanded] = useState(false); | ||
const [isEditing, setIsEditing] = useState(false); | ||
|
||
const toggleExpand = () => { | ||
setIsExpanded(!isExpanded); | ||
}; | ||
const toggleEdit = () => setIsEditing((prev) => !prev); | ||
const toggleExpand = () => { | ||
setIsExpanded(!isExpanded); | ||
}; | ||
const toggleEdit = () => setIsEditing((prev) => !prev); | ||
|
||
return ( | ||
|
||
// class name with either be grant-item or grant-item-expanded | ||
<div className='grant-item-wrapper'> | ||
<ul className={`grant-summary ${isExpanded ? 'expanded' : ''}`} onClick={toggleExpand}> | ||
<li className="grant-name">{grantName}</li> | ||
<li className="application-date">{applicationDate}</li> | ||
<li className="status">{generalStatus}</li> | ||
<li className="amount">${amount}</li> | ||
<li className="restriction-status">{restrictionStatus}</li> | ||
</ul> | ||
<div className={`grant-body ${isExpanded ? 'expanded' : ''}`}> | ||
{isExpanded && ( | ||
<div className="grant-description"> | ||
<h2>Community Development Initiative Grant</h2> | ||
<div className = 'grant-content'> | ||
<GrantAttributes isEditing={isEditing} /> | ||
<GrantDetails/> | ||
</div> | ||
<div className="bottom-buttons"> | ||
<button className="done-button" onClick={toggleEdit}> | ||
{isEditing ? 'SAVE' : 'EDIT'} | ||
</button> | ||
</div> | ||
</div> | ||
|
||
)} | ||
return ( | ||
// class name with either be grant-item or grant-item-expanded | ||
<div className="grant-item-wrapper"> | ||
<ul | ||
className={`grant-summary ${isExpanded ? "expanded" : ""}`} | ||
onClick={toggleExpand} | ||
> | ||
<li className="grant-name">{grantName}</li> | ||
<li className="application-date"> | ||
{applicationDate.toISOString().split("T")[0]} | ||
</li> | ||
<li className="status">{generalStatus}</li> | ||
<li className="amount">${amount}</li> | ||
<li className="restriction-status">{restrictionStatus}</li> | ||
</ul> | ||
<div className={`grant-body ${isExpanded ? "expanded" : ""}`}> | ||
{isExpanded && ( | ||
<div className="grant-description"> | ||
<h2>Community Development Initiative Grant</h2> | ||
<div className="grant-content"> | ||
<GrantAttributes isEditing={isEditing} /> | ||
<GrantDetails /> | ||
</div> | ||
<div className="bottom-buttons"> | ||
<button className="done-button" onClick={toggleEdit}> | ||
{isEditing ? "SAVE" : "EDIT"} | ||
</button> | ||
</div> | ||
</div> | ||
)} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
</div> | ||
|
||
) | ||
} | ||
|
||
export default GrantItem; | ||
export default GrantItem; |
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,17 +1,63 @@ | ||
import React from 'react'; | ||
import './styles/GrantLabels.css' | ||
import React from "react"; | ||
import "./styles/GrantLabels.css"; | ||
import { GrantItemProps } from "./GrantItem"; | ||
import { useState } from "react"; | ||
|
||
const GrantLabels: React.FC = () => { | ||
return ( | ||
<ul className="grant-labels"> | ||
<li></li> | ||
<li className="grant-name">Grant Name</li> | ||
<li className="application-date">Application Date</li> | ||
<li className="status">Status</li> | ||
<li className="amount">Amount</li> | ||
<li className="restriction-status">Restricted vs. Unrestricted</li> | ||
</ul> | ||
) | ||
} | ||
const GrantLabels: React.FC<{ | ||
onSort: (header: keyof GrantItemProps, asc: boolean) => void; | ||
}> = ({ onSort }) => { | ||
const [labels, setLabels] = useState({ | ||
header: "applicationDate", | ||
asc: true, | ||
}); | ||
|
||
export default GrantLabels; | ||
function buttonHandler(header: keyof GrantItemProps) { | ||
const isAsc = labels.header == header ? !labels.asc : true; | ||
onSort(header, isAsc); | ||
setLabels({ header: header, asc: isAsc }); | ||
} | ||
|
||
return ( | ||
<ul className="grant-labels"> | ||
<li> | ||
<button | ||
className="grant-name" | ||
onClick={() => buttonHandler("grantName")} | ||
> | ||
Grant Name | ||
</button> | ||
</li> | ||
<li> | ||
<button | ||
className="application-date" | ||
onClick={() => buttonHandler("applicationDate")} | ||
> | ||
Application Date | ||
</button> | ||
</li> | ||
<li> | ||
<button | ||
className="status" | ||
onClick={() => buttonHandler("generalStatus")} | ||
> | ||
Status | ||
</button> | ||
</li> | ||
<li> | ||
<button className="amount" onClick={() => buttonHandler("amount")}> | ||
Amount | ||
</button> | ||
</li> | ||
<li> | ||
<button | ||
className="restriction-status" | ||
onClick={() => buttonHandler("restrictionStatus")} | ||
> | ||
Restricted vs. Unrestricted | ||
</button> | ||
</li> | ||
</ul> | ||
); | ||
}; | ||
|
||
export default GrantLabels; |
Oops, something went wrong.