How to implement the proposal creation?
In the Find Job section, users can create a proposal for the job they want to apply for. We will use and detail the use of function createProposal or updateProposal
Good to Know
In this example, we will use reactJS, Ether.js and formik to handle the form on the frontend. You will find a full code example with all imports at the end of tutorial.
① Create a Form for the proposal creation
The user will create a proposal for a job (ProposalForm component)
// The interface for the inupt field of your form
interface IFormValues {
about: string;
rateToken: string;
rateAmount: number;
expirationDate: number;
videoUrl: string;
}
// As we using Formik we use the validationSchema to check all the input value.
const validationSchema = Yup.object({
about: Yup.string().required('Please provide a description of your service'),
rateToken: Yup.string().required('Please select a payment token'),
rateAmount: Yup.string().required('Please provide an amount for your service'),
expirationDate: Yup.number().integer().required('Please provide an expiration date'),
});
Let's create our form
② Handle Submit and Post the proposal
On submit, we create a new transaction and call the createProposal or the updateProposal for that we will need our contract instance and all the parameter including the CID (data stored on IPFS)
③ Get the Proposal by User With Subgraph API
Here is an example of a Graph Query you can use to get the proposal by user
More proposal query here
See the Full Code Implemented on Our Demo DAPP
processRequest utils function:
IPFS : https://github.com/TalentLayer-Labs/indie-frontend/blob/main/src/utils/ipfs.ts
Last updated
Was this helpful?