Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. export interface IFaqProps {
  2. description: string;
  3. items: IExampleItem[];
  4. }
  5. export type IExampleItem = { Question: string; Reponse: string; Categorie: {Title :string}; Langue: string };
  6.  
  7.  
  8. import * as React from 'react';
  9. import * as ReactDom from 'react-dom';
  10. import { Version } from '@microsoft/sp-core-library';
  11. import { BaseClientSideWebPart } from '@microsoft/sp-webpart-base';
  12. import {
  13. IPropertyPaneConfiguration,
  14. PropertyPaneTextField
  15. } from '@microsoft/sp-property-pane';
  16. import { sp } from "@pnp/sp";
  17. import * as strings from 'FaqWebPartStrings';
  18. import Faq from './components/Faq';
  19. import { IFaqProps , IExampleItem} from './components/IFaqProps';
  20.  
  21. export interface IFaqWebPartProps {
  22. description: string;
  23. }
  24.  
  25. export default class FaqWebPart extends BaseClientSideWebPart<IFaqWebPartProps> {
  26.  
  27. public render(): void {
  28. const element: React.ReactElement<IFaqProps > = React.createElement(
  29. Faq,
  30. {
  31. description: this.properties.description,
  32. items : this._getFacItems()
  33.  
  34. }
  35. );
  36.  
  37. ReactDom.render(element, this.domElement);
  38. }
  39.  
  40. //get faq list
  41. public _getFacItems() : Promise <IExampleItem[]> {
  42.  
  43. return sp.web.lists.getByTitle("FAQ_List").items
  44. .select("Question", "Reponse","Categorie", "Langue")
  45. .orderBy("Created", true)
  46. .get()
  47.  
  48.  
  49. }
  50.  
  51.  
  52. private _onRenderCell(item: IExampleItem, index: number | undefined): JSX.Element {
  53. return (
  54. <div className={classNames.itemCell} data-is-focusable={true}>
  55. <Image className={classNames.itemImage} src={item.Reponse} width={50} height={50} imageFit={ImageFit.cover} />
  56. <div className={classNames.itemContent}>
  57. <div className={classNames.itemName}>{item.Langue}</div>
  58. <div className={classNames.itemIndex}>{`Item ${index}`}</div>
  59. <div>{item.Categorie.Title}</div>
  60. </div>
  61. <Icon className={classNames.chevron} iconName={getRTL() ? 'ChevronLeft' : 'ChevronRight'} />
  62. </div>
  63. );
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement