Fixed typos and lint

This commit is contained in:
Hugo Bernier 2024-03-11 10:23:56 -04:00
parent 3d55ccc561
commit caf8c85b35
3 changed files with 36 additions and 49 deletions

View File

@ -1,14 +1,10 @@
# React Poll
## Summary
This web part allow User to add New Poll Questions and their options. End users can submit his/her response to the poll. After Submission, user can see all responses count with Bar chart.
![React-Poll](./assets/react-poll.gif)
**Following are some of the features of this component.**
@ -23,33 +19,35 @@ This web part allow User to add New Poll Questions and their options. End users
- Poll response can be viewed via Bar chart.
- Easy to configure.
## Compatibility
## Used SharePoint Framework Version
| :warning: Important |
|:---------------------------|
| Every SPFx version is optimally compatible with specific versions of Node.js. In order to be able to build this sample, you need to ensure that the version of Node on your workstation matches one of the versions listed in this section. This sample will not work on a different version of Node.|
|Refer to <https://aka.ms/spfx-matrix> for more information on SPFx compatibility. |
This sample is optimally compatible with the following environment configuration:
![version](https://img.shields.io/badge/version-1.17.1-green.svg)
![SPFx 1.17.1](https://img.shields.io/badge/SPFx-1.17.1-green.svg)
![Node.js v16.13+](https://img.shields.io/badge/Node.js-v16.13+-green.svg)
![Compatible with SharePoint Online](https://img.shields.io/badge/SharePoint%20Online-Compatible-green.svg)
![Does not work with SharePoint 2019](https://img.shields.io/badge/SharePoint%20Server%202019-Incompatible-red.svg "SharePoint Server 2019 requires SPFx 1.4.1 or lower")
![Does not work with SharePoint 2016 (Feature Pack 2)](https://img.shields.io/badge/SharePoint%20Server%202016%20(Feature%20Pack%202)-Incompatible-red.svg "SharePoint Server 2016 Feature Pack 2 requires SPFx 1.1")
![Local Workbench Unsupported](https://img.shields.io/badge/Local%20Workbench-Unsupported-red.svg "Local workbench is no longer available as of SPFx 1.13 and above")
![Hosted Workbench Compatible](https://img.shields.io/badge/Hosted%20Workbench-Compatible-green.svg)
![Compatible with Remote Containers](https://img.shields.io/badge/Remote%20Containers-Compatible-green.svg)
## Applies to
- [SharePoint Framework](https://learn.microsoft.com/sharepoint/dev/spfx/sharepoint-framework-overview)
- [Microsoft 365 tenant](https://learn.microsoft.com/sharepoint/dev/spfx/set-up-your-development-environment)
- [SharePoint Framework](https://aka.ms/spfx)
- [Microsoft 365 tenant](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-developer-tenant)
> Get your own free development tenant by subscribing to [Microsoft 365 developer program](http://aka.ms/o365devprogram)
> Get your own free development tenant by subscribing to [Microsoft 365 developer program](https://aka.ms/m365/devprogram)
## Prerequisites
- Office 365 subscription with SharePoint Online
- SharePoint Framework [development environment](https://learn.microsoft.com/sharepoint/dev/spfx/set-up-your-development-environment) set up
@ -57,28 +55,16 @@ This web part allow User to add New Poll Questions and their options. End users
- [Harsh Bhavsar](https://github.com/Harsh24491)
## Version history
| Version | Date | Comments |
| ------- | ---------------- | --------------- |
| 1.0 | March 02, 2024 | Initial release |
## Minimal Path to Awesome
- Clone this repository (or [download this solution as a .ZIP file](https://pnp.github.io/download-partial/?url=https://github.com/pnp/sp-dev-fx-webparts/tree/main/samples/react-poll) then unzip it)
- From your command line, change your current directory to the directory containing this sample (`react-poll`, located under `samples`)* in the command line run:
- `npm install`
@ -86,7 +72,6 @@ This web part allow User to add New Poll Questions and their options. End users
> This sample can also be opened with [VS Code Remote Development](https://code.visualstudio.com/docs/remote/remote-overview). Visit [https://aka.ms/spfx-devcontainer](https://aka.ms/spfx-devcontainer) for further instructions.
## Help
We do not support samples, but we this community is always willing to help, and we want to improve these samples. We use GitHub to track issues, which makes it easy for community members to volunteer their time and help resolve issues.

View File

@ -8,13 +8,14 @@ import { WebPartContext } from "@microsoft/sp-webpart-base";
import { IQuestion, IAnswer } from "../models/models";
import { Fields, ListsUrl } from "../Constants/Constants";
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
export function useGetData(
context: WebPartContext,
userEmail: string,
webServerRelativeUrl: string
) {
//Delare States
//Declare States
const [isLoading, setIsLoading] = useState<boolean>(true);
const [isSubmitting, setIsSubmitting] = useState<boolean>(false);
const [questions, setQuestions] = useState<IQuestion[]>([]);
@ -46,6 +47,7 @@ export function useGetData(
};
//Map Question with Options and Answer
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const mapQuestion = async (item: any): Promise<IQuestion> => {
const question: IQuestion = {
id: item.ID,

View File

@ -145,7 +145,7 @@ const ReactPoll: React.FunctionComponent<IReactPollProps> = (props) => {
<PrimaryButton
text="Submit"
disabled={
question.selectedOption == null || isSubmitting
question.selectedOption === null || isSubmitting
}
onClick={() => handleSubmitClick(question)}
/>