-
Notifications
You must be signed in to change notification settings - Fork 18
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
Add Grant to profile dashboard #3993
Open
estyxx
wants to merge
13
commits into
main
Choose a base branch
from
add-grant-to-profile-dashboard
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+716
−109
Open
Changes from 6 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
d3b175a
WIP
estyxx dd84f6f
Fix ESLint
estyxx 8bd275e
Implement code review suggestions
estyxx 35017fe
Split component
estyxx 31694bf
Redirect to profile/my-grant when grant exists
estyxx 28432db
Move queryMyGrant on top
estyxx 4d6bd6b
Remove unused vars
estyxx 338adbb
Remove unused vars
estyxx c83d8e6
Chage colors
estyxx 10d3af1
Add GrantInfo component
estyxx 9033b50
Fix grid
estyxx 9c59ad6
Apply suggestions from code review
estyxx 02c0d9d
Apply code review suggestions
estyxx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
96 changes: 96 additions & 0 deletions
96
frontend/src/components/my-grant-profile-page-handler/grant-table-info.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,96 @@ | ||
import { | ||
Button, | ||
Grid, | ||
GridColumn, | ||
Link, | ||
Spacer, | ||
Text, | ||
VerticalStack, | ||
} from "@python-italia/pycon-styleguide"; | ||
import { FormattedMessage } from "react-intl"; | ||
|
||
import { useCurrentLanguage } from "~/locale/context"; | ||
import { DeadlineStatus, Status as GrantStatus } from "~/types"; | ||
import type { MyProfileWithGrantQuery } from "~/types"; | ||
|
||
import { getCountryLabel } from "~/helpers/country-utils"; | ||
import { useCountries } from "~/helpers/use-countries"; | ||
import { createHref } from "../link"; | ||
import { Sidebar } from "./sidebar"; | ||
|
||
type Props = { | ||
grant: MyProfileWithGrantQuery["me"]["grant"]; | ||
}; | ||
const GrantTableInfo = ({ grant }: Props) => { | ||
estyxx marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const countries = useCountries(); | ||
return ( | ||
<Grid cols={3} gap="small" fullWidth> | ||
<div> | ||
estyxx marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<Title> | ||
<FormattedMessage id="grants.form.fields.name" /> | ||
</Title> | ||
<Spacer size="xs" /> | ||
<Text>{grant.name}</Text> | ||
</div> | ||
|
||
<div> | ||
<Title> | ||
<FormattedMessage id="grants.form.fields.fullName" /> | ||
</Title> | ||
<Spacer size="xs" /> | ||
<Text>{grant.fullName}</Text> | ||
</div> | ||
|
||
<div> | ||
<Title> | ||
<FormattedMessage id="grants.form.fields.ageGroup" /> | ||
</Title> | ||
<Spacer size="xs" /> | ||
|
||
<Text> | ||
<FormattedMessage | ||
id={`grants.form.fields.ageGroup.values.${grant.ageGroup}`} | ||
/> | ||
</Text> | ||
</div> | ||
|
||
<div> | ||
<Title> | ||
<FormattedMessage id="grants.form.fields.travellingFrom" /> | ||
</Title> | ||
<Spacer size="xs" /> | ||
<Text>{getCountryLabel(countries, grant.travellingFrom)}</Text> | ||
</div> | ||
|
||
<div> | ||
<Title> | ||
<FormattedMessage id="grants.form.fields.gender" /> | ||
</Title> | ||
<Spacer size="xs" /> | ||
<Text> | ||
<FormattedMessage id={`profile.gender.${grant.gender}`} /> | ||
</Text> | ||
</div> | ||
|
||
<div> | ||
<Title> | ||
<FormattedMessage id="grants.form.fields.occupation" /> | ||
</Title> | ||
<Spacer size="xs" /> | ||
<Text> | ||
<FormattedMessage | ||
id={`grants.form.fields.occupation.values.${grant.occupation}`} | ||
/> | ||
</Text> | ||
</div> | ||
</Grid> | ||
); | ||
}; | ||
|
||
export default GrantTableInfo; | ||
estyxx marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
const Title = ({ children }: { children: React.ReactNode }) => ( | ||
estyxx marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<Text size="label3" uppercase weight="strong"> | ||
{children} | ||
</Text> | ||
); |
43 changes: 43 additions & 0 deletions
43
frontend/src/components/my-grant-profile-page-handler/index.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,43 @@ | ||
import { Heading, Page, Section } from "@python-italia/pycon-styleguide"; | ||
import { FormattedMessage } from "react-intl"; | ||
|
||
import { useMyProfileWithGrantQuery } from "~/types"; | ||
|
||
import { MyGrant } from "~/components/my-grant-profile-page-handler/my-grant"; | ||
import { NoGrant } from "~/components/my-grant-profile-page-handler/no-grant"; | ||
import { MetaTags } from "../meta-tags"; | ||
|
||
export const MyGrantProfilePageHandler = () => { | ||
const { | ||
data: { | ||
me, | ||
estyxx marked this conversation as resolved.
Show resolved
Hide resolved
|
||
conference: { deadline }, | ||
}, | ||
error, | ||
estyxx marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} = useMyProfileWithGrantQuery({ | ||
variables: { | ||
conference: process.env.conferenceCode, | ||
}, | ||
}); | ||
|
||
const grant = me.grant; | ||
|
||
return ( | ||
<Page endSeparator={false}> | ||
<FormattedMessage id="profile.myGrant"> | ||
{(text) => <MetaTags title={text} />} | ||
</FormattedMessage> | ||
|
||
<Section background="green"> | ||
<Heading size="display2"> | ||
<FormattedMessage id="profile.myGrant" /> | ||
</Heading> | ||
</Section> | ||
|
||
<Section> | ||
{grant && <MyGrant grant={grant} deadline={deadline} />} | ||
{!grant && <NoGrant deadline={deadline} />} | ||
</Section> | ||
</Page> | ||
); | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the user lands on
pycon.it/grants
page, if they have a grant, it automatically redirects toprofile/my-grant
. This component is only used when the user doesn't have a grant, so I removed the grant's fetching as it's no longer needed.