-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from Refugee-Aid-Capstone/feature/edit-org
Feature/edit org
- Loading branch information
Showing
7 changed files
with
86 additions
and
100 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
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,10 @@ | ||
.action-button { | ||
padding: 0.4rem 0.8rem; | ||
font-size: 0.9rem; | ||
border-radius: 9px; | ||
margin-left: 1rem; | ||
border: none; | ||
cursor: pointer; | ||
transition: background-color 0.3s ease; | ||
margin-top: 1rem; | ||
} |
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,28 +1,35 @@ | ||
export default function OrgRequestCard({ request, handleApprove, handleDecline }) { | ||
import '../RequestCard/RequestCard.scss'; | ||
import '../OrganizationDashboard/OrganizationDashboard.scss'; | ||
import './OrgRequest.scss'; | ||
import { useMutation } from '@apollo/client'; | ||
import { UPDATE_AID_REQUEST } from '../../apollo-client/mutations'; | ||
|
||
export default function OrgRequestCard({ request }) { | ||
const { id, description, aidType, language, status } = request; | ||
const [updateStatus] = useMutation(UPDATE_AID_REQUEST); | ||
|
||
const buttons = ['pending', 'fulfilled', 'active'] | ||
.filter(buttonType => buttonType !== status) | ||
.map(buttonType => ( | ||
<button | ||
key={buttonType} | ||
className='action-button' | ||
onClick={() => | ||
updateStatus({ variables: { id: id, status: buttonType } }) | ||
} | ||
aria-label={`Mark request for ${aidType} aid as ${buttonType}`} | ||
> | ||
{buttonType} | ||
</button> | ||
)); | ||
|
||
return ( | ||
<article className='request-card org' id={id}> | ||
<h3 className='card-text type'>{aidType} Aid</h3> | ||
{language && <p className='card-text'>Language: {language}</p>} | ||
{language !== 'None' && <p className='card-text'>Language: {language}</p>} | ||
<p className='card-text description'>{description}</p> | ||
<p className='card-text'>Status: {status}</p> | ||
<div> | ||
<button | ||
className="action-button" | ||
onClick={() => handleApprove(request.id)} | ||
aria-label={`Approve request for ${aidType} aid`} | ||
> | ||
Approve | ||
</button> | ||
<button | ||
className="action-button" | ||
onClick={() => handleDecline(request.id)} | ||
aria-label={`Mark request for ${aidType} aid as fulfilled`} | ||
> | ||
Fulfilled | ||
</button> | ||
</div> | ||
<div>{buttons}</div> | ||
</article> | ||
); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { gql } from "@apollo/client"; | ||
|
||
export const UPDATE_AID_REQUEST = gql` | ||
mutation updateAidRequest($id: ID!, $status: String) { | ||
updateAidRequest(id: $id, status: $status) { | ||
id | ||
status | ||
organization { | ||
name | ||
id | ||
} | ||
} | ||
} | ||
`; |