-
Notifications
You must be signed in to change notification settings - Fork 234
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
Update Read Mes #12450
Open
shayneahchoon
wants to merge
10
commits into
latest
Choose a base branch
from
WORLDSERVICE-README
base: latest
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.
+282
−24
Open
Update Read Mes #12450
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6e4f5e4
WORLDSERVICE-UPDATE: Update readme
shayneahchoon e7284ad
WORLDSERVICE-UPDATE: Update readme
shayneahchoon 550a66b
Merge branch 'latest' into WORLDSERVICE-README
shayneahchoon 279422b
WORLDSERVICE-README: Edit MediaLoader
shayneahchoon 0ce34ad
WORLDSERVICE-README: Edit MediaLoader
shayneahchoon e04e7bd
WORLDSERVICE-README: Edit MediaLoader
shayneahchoon b5229a6
WORLDSERVICE-README: Edit MediaLoader
shayneahchoon e897b92
WORLDSERVICE-README: Edit MediaLoader
shayneahchoon 9e0fad7
WORLDSERVICE-README: Edit MediaLoader
shayneahchoon 60c5b0a
WORLDSERVICE-README: Edit readme
shayneahchoon 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
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,104 @@ | ||
# UGC Uploader Form | ||
|
||
## Description | ||
|
||
User Generated Content (UGC) refers to any content that is generated by the user. Our uploader form supports the following types of UGC: long text, short text, checkbox, e-mail, telephone, files and images. | ||
|
||
## BFF Response | ||
|
||
BFF details for UGC/Send pages can be found here: | ||
[BFF Send Response](https://github.com/bbc/fabl-modules/tree/main/modules/application/simorgh-bff#send) | ||
|
||
## How routes are handled | ||
|
||
Our UGC Uploader Page is served through the following route: | ||
`/pages/[service]/send/[id]/[[variant]]`, where the double brackets in `[[variant]]` means that the variant is optional. | ||
|
||
This route matches the file structure of this repo: | ||
|
||
├── ws-nextjs-app | ||
├── pages | ||
├── [service] | ||
├── send | ||
├── [id] | ||
├── [[...variant]].page.tsx | ||
├── [[...]].page.tsx | ||
├── _app.page.tsx | ||
├── _document.page.tsx | ||
|
||
Sample routes that match this construct are: | ||
|
||
| Service | URL | | ||
| ------------------ | ----------------------------- | | ||
| Mundo (no variant) | `/mundo/send/u50853489` | | ||
| Serbian (variant) | `/serbian/send/u00000009/lat` | | ||
|
||
#### Server Side functions | ||
|
||
Within `[[variant]].page.tsx`, the `getServerSideProps` function is called on the server side when a request to a send page is made. It's important that this function returns an object that directly correlates to the props expected by the default exported component within `[[variant]].page.tsx`. | ||
|
||
``` | ||
export const getServerSideProps: GetServerSideProps = async context => { | ||
|
||
context.res.statusCode = data.status; | ||
|
||
return { | ||
props: { | ||
...props expected by UGCPageLayout | ||
}, | ||
}; | ||
}; | ||
|
||
export default UGCPageLayout; | ||
``` | ||
|
||
In the code snippet above, NextJS will serve the component returned by `UGCPageLayout`. Before doing so, it calls `getServerSideProps` (on the server) to retrieve the requisite props, which are then used to call `UGCPageLayout`, which in turn returns a valid HTML element. | ||
|
||
**It's important that request/response data is stored within `context.res`, so that requests can be handled appropriately by our ELBs.** | ||
|
||
## Component Structure | ||
|
||
A typical UGC form can be found here: https://www.bbc.com/mundo/send/u50853489 | ||
|
||
Component file structure | ||
|
||
├── ws-nextjs-app | ||
├── pages | ||
├── [service] | ||
├── send | ||
├── [id] | ||
├── FormContext | ||
├── FormScreen | ||
├── FormField | ||
├── File | ||
├── Checkbox | ||
├── EmailInput | ||
├── FieldLabel | ||
├── Telephone | ||
├── TextArea | ||
├── TextInput | ||
|
||
The FormScreen component takes in a list of fields from the BFF and populates itself with a respective body of form fields, based on the components we have available. This is a sample BFF Response: | ||
|
||
For example, if the BFF returned the following under `data.sections.fields`, then it would render a phone field followed by a text area: | ||
|
||
{ "id": "txt49018963", | ||
"type": "text", | ||
"validation": { "mandatory": false }, | ||
"htmlType": "phone", | ||
"label": "Número de teléfono", | ||
"description": "", | ||
"textArea": false | ||
}, | ||
{ "id": "txt49019016", | ||
"type": "text", | ||
"validation": { "mandatory": true }, | ||
"htmlType": "textarea", | ||
"label": "Comentario (obligatorio)", | ||
"description": "", | ||
"textArea": true | ||
}, | ||
|
||
### Form Context | ||
|
||
The FormContext acts as controller to collate and send all UGC inputted into the form. The `handleSubmit` function within the FormContext effectively validates the form field values and sends it off to the UGC team. |
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.
Should we try and find descriptions for these configs?
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.
Yesss, I was hoping to pair with Aaron at some point to get greater clarity on these ones.
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.
Or use co-pilot to help?