+ {this.state.loading &&
+
+ }
+ {this.state.loading === false &&
+ this.state.voteOptions.length > 0 &&
+
+
+
+
+
+ }
+ {this.state.voting &&
+
+ }
+ {this.state.error !== undefined &&
+
+ An error has occurred while loading vote options: {this.state.error}
+
+ }
+
+ );
+ }
+
+ private selectVoteOption(option: IChoiceGroupOption, evt?: React.SyntheticEvent): void {
+ this.setState((prevState: IVoteState, props: IVoteProps): IVoteState => {
+ prevState.voteOptionId = parseInt(option.key);
+ return prevState;
+ });
+ }
+
+ private vote(): void {
+ this.setState((prevState: IVoteState, props: IVoteProps): IVoteState => {
+ prevState.error = undefined;
+ prevState.voting = true;
+ return prevState;
+ });
+ this.props.pollService.vote(this.state.voteOptionId, this.props.listName)
+ .then((): void => {
+ this.setState((prevState: IVoteState, props: IVoteProps): IVoteState => {
+ prevState.voting = false;
+ return prevState;
+ });
+ this.props.onVoted();
+ }, (error: any): void => {
+ this.setState((prevState: IVoteState, props: IVoteProps): IVoteState => {
+ prevState.voting = false;
+ prevState.error = error.data ? error.data['odata.error'].message.value : error;
+ return prevState;
+ });
+ });
+ }
+}
\ No newline at end of file
diff --git a/samples/react-multipage/src/webparts/poll/components/Vote/index.ts b/samples/react-multipage/src/webparts/poll/components/Vote/index.ts
new file mode 100644
index 000000000..c864744ee
--- /dev/null
+++ b/samples/react-multipage/src/webparts/poll/components/Vote/index.ts
@@ -0,0 +1 @@
+export * from './Vote';
\ No newline at end of file
diff --git a/samples/react-multipage/src/webparts/poll/loc/en-us.js b/samples/react-multipage/src/webparts/poll/loc/en-us.js
new file mode 100644
index 000000000..13d5ad583
--- /dev/null
+++ b/samples/react-multipage/src/webparts/poll/loc/en-us.js
@@ -0,0 +1,10 @@
+define([], function() {
+ return {
+ "PropertyPaneDescription": "Configure properties of this poll",
+ "DataGroupName": "Data",
+ "ViewGroupName": "View",
+ "ListNameFieldLabel": "List name",
+ "PollTitleFieldLabel": "Poll title",
+ "PollDescriptionFieldLabel": "Poll description (optional)"
+ }
+});
\ No newline at end of file
diff --git a/samples/react-multipage/src/webparts/poll/loc/mystrings.d.ts b/samples/react-multipage/src/webparts/poll/loc/mystrings.d.ts
new file mode 100644
index 000000000..222310e69
--- /dev/null
+++ b/samples/react-multipage/src/webparts/poll/loc/mystrings.d.ts
@@ -0,0 +1,13 @@
+declare interface IPollStrings {
+ PropertyPaneDescription: string;
+ DataGroupName: string;
+ ViewGroupName: string;
+ ListNameFieldLabel: string;
+ PollTitleFieldLabel: string;
+ PollDescriptionFieldLabel: string;
+}
+
+declare module 'pollStrings' {
+ const strings: IPollStrings;
+ export = strings;
+}
diff --git a/samples/react-multipage/src/webparts/poll/services/IPollService.ts b/samples/react-multipage/src/webparts/poll/services/IPollService.ts
new file mode 100644
index 000000000..73d90fb92
--- /dev/null
+++ b/samples/react-multipage/src/webparts/poll/services/IPollService.ts
@@ -0,0 +1,8 @@
+import { IVoteOption } from './IVoteOption';
+import { IVoteResult } from './IVoteResult';
+
+export interface IPollService {
+ getVoteOptions: (listName: string) => Promise