Skip to content

Commit 5373e4e

Browse files
author
Hugo Bernier
committed
chore(spfx-extensions): udptade readme.md, sample.json, lint issues
1 parent 1881d00 commit 5373e4e

6 files changed

Lines changed: 30 additions & 23 deletions

File tree

samples/react-application-customizer-feedback-widget/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ Create a SharePoint custom list Feedbacks in the SPO site where this application
7777
?debugManifestsFile=https%3A%2F%2Flocalhost%3A4321%2Ftemp%2Fmanifests.js&loadSPFX=true&customActions=%7B"33ce42af-1748-4989-ab97-a8d9f782b886"%3A%7B"location"%3A"ClientSideExtension.ApplicationCustomizer"%2C"properties"%3A%7B"title"%3A"Submit+your+feedbacks+%26+ideas"%2C"position"%3A"rightBottom"%7D%7D%7D
7878
```
7979
80-
## Deploy Package Solution 🚀
81-
80+
## Deploy Package Solution
8281
- Ensure that you are at the solution folder
8382
- in the command-line run:
8483
- `gulp build --ship`

samples/react-application-customizer-feedback-widget/assets/sample.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"An SPFx Application Customizer Extension placed in the bottom placeholder which allows users to input their feedbacks without scrolling down to the end of the page."
1010
],
1111
"creationDateTime": "2023-07-02",
12-
"updateDateTime": "2023-07-02",
12+
"updateDateTime": "2025-05-25",
1313
"products": [
1414
"SharePoint"
1515
],
@@ -20,7 +20,7 @@
2020
},
2121
{
2222
"key": "SPFX-VERSION",
23-
"value": "1.16.1"
23+
"value": "1.20.2"
2424
}
2525
],
2626
"tags": [],

samples/react-application-customizer-feedback-widget/src/Configuration/PnPConfig.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ import "@pnp/sp/site-users/web"
1010
import "@pnp/sp/items"
1111
import "@pnp/sp/comments"
1212

13+
// eslint-disable-next-line no-var, @rushstack/no-new-null
1314
var _sp: SPFI | null = null
1415

1516
export const getSP = (context?: BaseComponentContext): SPFI => {
16-
if (context != null) {
17+
if (context !== null) {
1718
//You must add the @pnp/logging package to include the PnPLogging behavior it is no longer a peer dependency
1819
// The LogLevel set's at what level a message will be written to the console
1920
_sp = spfi().using(SPFx(context)).using(PnPLogging(LogLevel.Warning))

samples/react-application-customizer-feedback-widget/src/extensions/feedback/FeedbackApplicationCustomizer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export default class FeedbackApplicationCustomizer extends BaseApplicationCustom
5353
this._rootElement = this.HeaderPlaceholder.domElement
5454
}
5555

56+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
5657
const elem: React.ReactElement<any> = React.createElement(
5758
FeedbackCustomizer,
5859
{

samples/react-application-customizer-feedback-widget/src/extensions/feedback/components/FeedbackCustomizer.tsx

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,38 +21,42 @@ type CurrentUser = {
2121
}
2222

2323
interface IFeedbackCustomizerProps {
24+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2425
context: any
26+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2527
properties: any
2628
}
2729

2830
export default function FeedbackCustomizer({
2931
context,
3032
properties,
31-
}: IFeedbackCustomizerProps) {
33+
// eslint-disable-next-line @rushstack/no-new-null
34+
}: IFeedbackCustomizerProps): React.ReactElement | null {
3235
const [open, setOpen] = useState(false)
3336
const [currentUser, setCurrentUser] = useState<CurrentUser>({
3437
name: "",
3538
mailId: "",
3639
})
3740
const [feedbackComment, setfeedbackComment] = useState("")
41+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
3842
const [currentRating, setCurrentRating] = useState<any>(0)
3943
const [errorMessage, setErrorMessage] = useState("")
4044
const [successFlag, setSuccessFlag] = useState(false)
4145
const [currentsiteUrl, setSiteUrl] = useState("")
4246
const [isExiting, setIsExiting] = useState(false)
4347

44-
const handleOpen = () => {
48+
const handleOpen = (): void => {
4549
setOpen(true)
4650
}
4751

48-
const handleBtnClose = () => {
52+
const handleBtnClose = (): void => {
4953
setOpen(false)
5054
setfeedbackComment("")
5155
setSuccessFlag(false)
5256
handleOpen() // Call handleOpen to show the popup again
5357
}
5458

55-
const handleClose = () => {
59+
const handleClose = (): void => {
5660
setIsExiting(true)
5761
setTimeout(() => {
5862
setOpen(false)
@@ -69,23 +73,23 @@ export default function FeedbackCustomizer({
6973
})
7074
}
7175
// set current page siteurl
72-
let getpageUrl = window.location.href
76+
const getpageUrl = window.location.href
7377
setSiteUrl(getpageUrl)
7478
}, [])
7579

76-
const handleTextArea = (event) => {
80+
const handleTextArea = (event: React.ChangeEvent<HTMLTextAreaElement>): void => {
7781
setfeedbackComment(event.target.value)
7882
}
7983

80-
const handleFeedbackSubmit = async () => {
81-
let sp: SPFI = getSP()
84+
const handleFeedbackSubmit = async (): Promise<void> => {
85+
const sp: SPFI = getSP()
8286

8387
if (feedbackComment.trim() === "") {
8488
setErrorMessage("Comment can't be empty")
8589
} else if (feedbackComment.length < 30) {
8690
setErrorMessage("Comment should be at least 50 characters long")
8791
} else {
88-
let data = await sp.web.lists.getByTitle("Feedbacks").items.add({
92+
const data = await sp.web.lists.getByTitle("Feedbacks").items.add({
8993
Employee_Name: currentUser.name,
9094
Employee_MailId: currentUser.mailId,
9195
Comment: feedbackComment,
@@ -123,7 +127,7 @@ export default function FeedbackCustomizer({
123127
}`}
124128
>
125129
<div
126-
className={styles["buttonWrapper"]}
130+
className={styles.buttonWrapper}
127131
onClick={open ? handleClose : handleOpen}
128132
>
129133
<BiMessageSquareDetail
@@ -162,15 +166,15 @@ export default function FeedbackCustomizer({
162166
/>
163167
</div>
164168
{successFlag === false ? (
165-
<div className={styles["feedbackWrapper"]}>
169+
<div className={styles.feedbackWrapper}>
166170
<Textarea
167-
className={styles["textArea__style"]}
171+
className={styles.textArea__style}
168172
value={feedbackComment}
169173
onChange={(event) => handleTextArea(event)}
170174
placeholder='Type here...'
171175
></Textarea>
172176
{errorMessage && (
173-
<p className={styles["errorTxt"]}>{errorMessage}</p>
177+
<p className={styles.errorTxt}>{errorMessage}</p>
174178
)}
175179
<Rating
176180
value={currentRating}
@@ -180,7 +184,7 @@ export default function FeedbackCustomizer({
180184
onChange={(_, data) => setCurrentRating(data.value)}
181185
/>
182186
<button
183-
className={styles["submitbtn"]}
187+
className={styles.submitbtn}
184188
onClick={handleFeedbackSubmit}
185189
>
186190
Submit
@@ -190,7 +194,7 @@ export default function FeedbackCustomizer({
190194
<SuccessPage goBack={handleBtnClose} />
191195
)}
192196
<div
193-
className={`${styles["downarrow"]} ${
197+
className={`${styles.downarrow} ${
194198
properties.position === "leftBottom"
195199
? styles["downarrow-left"]
196200
: ""

samples/react-application-customizer-feedback-widget/src/extensions/feedback/components/SuccessPage.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ export interface ISuccessProps {
99

1010
export const SuccessPage: React.FC<ISuccessProps> = (props:ISuccessProps): JSX.Element => {
1111

12-
const handleGoBack = () => {
13-
props.goBack && props.goBack();
12+
const handleGoBack = (): void => {
13+
if (props.goBack) {
14+
props.goBack();
15+
}
1416
};
1517

1618
return (
17-
<div className={styles["successWrapper"]}>
19+
<div className={styles.successWrapper}>
1820
<p style={{ marginBottom: "0", fontSize: "15px", fontWeight: "500" }}>
1921
Thanks for submitting your feedback!
2022
</p>

0 commit comments

Comments
 (0)