Skip to content

Commit 32ac7a3

Browse files
committed
pr change
1 parent 88e3b0c commit 32ac7a3

7 files changed

Lines changed: 49 additions & 46 deletions

File tree

packages/react-components/review/beta/react-components.api.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2185,18 +2185,6 @@ export interface StreamMediaProps {
21852185
videoStreamElement: HTMLElement | null;
21862186
}
21872187

2188-
// @public
2189-
export interface SurveyCategories {
2190-
// (undocumented)
2191-
audioRating: string;
2192-
// (undocumented)
2193-
overallRating: string;
2194-
// (undocumented)
2195-
screenshareRating: string;
2196-
// (undocumented)
2197-
videoRating: string;
2198-
}
2199-
22002188
// @public
22012189
export interface SurveyIssues {
22022190
// (undocumented)
@@ -2243,6 +2231,18 @@ export interface SurveyIssues {
22432231
};
22442232
}
22452233

2234+
// @public
2235+
export interface SurveyIssuesHeadingStrings {
2236+
// (undocumented)
2237+
audioRating: string;
2238+
// (undocumented)
2239+
overallRating: string;
2240+
// (undocumented)
2241+
screenshareRating: string;
2242+
// (undocumented)
2243+
videoRating: string;
2244+
}
2245+
22462246
// @internal
22472247
export type _SurveyTag = {
22482248
[issueCategory: string]: {
@@ -2268,7 +2268,7 @@ export const _TagsSurvey: (props: _TagsSurveyProps) => JSX.Element;
22682268
// @internal
22692269
export interface _TagsSurveyProps {
22702270
callIssuesToTag: SurveyIssues;
2271-
categoriesToHeader: SurveyCategories;
2271+
categoryHeadings: SurveyIssuesHeadingStrings;
22722272
issues: (_AudioIssue | _OverallIssue | _ScreenshareIssue | _VideoIssue)[];
22732273
onConfirm?: (selectedTags: _CallSurvey) => void;
22742274
strings?: _TagsSurveyStrings;

packages/react-components/src/components/Survey/TagsSurvey/TagsSurvey.tsx

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
import React, { useState } from 'react';
4+
import React, { useMemo, useState } from 'react';
55
import { Text, useTheme, Stack, Checkbox, Pivot, PivotItem } from '@fluentui/react';
66
import { _formatString, _pxToRem } from '@internal/acs-ui-common';
77
import { checkboxClassName, questionTextStyle, helperTextStyle } from './TagsSurvey.styles';
@@ -13,7 +13,7 @@ import {
1313
_ScreenshareIssue,
1414
_VideoIssue
1515
} from '../SurveyTypes';
16-
import { SurveyCategories, SurveyIssues } from '../../../types';
16+
import { SurveyIssuesHeadingStrings, SurveyIssues } from '../../../types';
1717
/**
1818
* Strings of {@link TagsSurvey} that can be overridden.
1919
*
@@ -25,7 +25,7 @@ export interface _TagsSurveyStrings {
2525
*/
2626
tagsSurveyQuestion?: string;
2727
/**
28-
* Confirm Button Label
28+
* Helper text for tag survey explaining what the survey is for
2929
*/
3030
tagsSurveyHelperText?: string;
3131
}
@@ -60,7 +60,7 @@ export interface _TagsSurveyProps {
6060
/** Mappings from call issues to tags displayed on the survey*/
6161
callIssuesToTag: SurveyIssues;
6262
/** Mappings from issue category to categories displayed on survey*/
63-
categoriesToHeader: SurveyCategories;
63+
categoryHeadings: SurveyIssuesHeadingStrings;
6464
/** Function to send TagsSurvey results*/
6565
onConfirm?: (selectedTags: _CallSurvey) => void;
6666
/** Tags survey strings */
@@ -73,32 +73,35 @@ export interface _TagsSurveyProps {
7373
* @internal
7474
*/
7575
export const _TagsSurvey = (props: _TagsSurveyProps): JSX.Element => {
76-
const { issues, callIssuesToTag, categoriesToHeader, onConfirm, strings } = props;
76+
const { issues, callIssuesToTag, categoryHeadings, onConfirm, strings } = props;
7777

7878
const [selectedTags, setSelectedTags] = useState({});
7979

80-
const tags: _SurveyTag[] = [];
81-
issues.map((issue) => {
82-
const issueCamelCase = issue?.charAt(0).toLowerCase() + issue?.slice(1);
83-
const issueCategory = Object.keys(callIssuesToTag).find(
84-
(key) => callIssuesToTag[key][issueCamelCase] !== undefined
85-
);
86-
if (issueCategory) {
87-
if (tags[issueCategory]) {
88-
tags[issueCategory].push({
89-
message: callIssuesToTag[issueCategory][issueCamelCase],
90-
issue: issue
91-
});
92-
} else {
93-
tags[issueCategory] = [
94-
{
80+
const tags: _SurveyTag[] = useMemo(() => {
81+
const tags: _SurveyTag[] = [];
82+
issues.forEach((issue) => {
83+
const issueCamelCase = issue?.charAt(0).toLowerCase() + issue?.slice(1);
84+
const issueCategory = Object.keys(callIssuesToTag).find(
85+
(key) => callIssuesToTag[key][issueCamelCase] !== undefined
86+
);
87+
if (issueCategory) {
88+
if (tags[issueCategory]) {
89+
tags[issueCategory].push({
9590
message: callIssuesToTag[issueCategory][issueCamelCase],
9691
issue: issue
97-
}
98-
];
92+
});
93+
} else {
94+
tags[issueCategory] = [
95+
{
96+
message: callIssuesToTag[issueCategory][issueCamelCase],
97+
issue: issue
98+
}
99+
];
100+
}
99101
}
100-
}
101-
});
102+
});
103+
return tags;
104+
}, [issues, callIssuesToTag]);
102105

103106
const onChange = React.useCallback(
104107
(issue: string, issueCategory: string, checked: boolean): void => {
@@ -146,7 +149,7 @@ export const _TagsSurvey = (props: _TagsSurveyProps): JSX.Element => {
146149
return (
147150
<PivotItem
148151
key={`key-${i}`}
149-
headerText={categoriesToHeader[key]}
152+
headerText={categoryHeadings[key]}
150153
headerButtonProps={{
151154
'data-order': i,
152155
'data-title': key

packages/react-components/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,4 @@ export type { BlockedMessage } from './types';
7474
/* @conditional-compile-remove(end-of-call-survey) */
7575
export type { SurveyIssues } from './types';
7676
/* @conditional-compile-remove(end-of-call-survey) */
77-
export type { SurveyCategories } from './types';
77+
export type { SurveyIssuesHeadingStrings } from './types';

packages/react-components/src/types/SurveyCategories.ts renamed to packages/react-components/src/types/SurveyIssuesHeadingStrings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* @public
66
* Corresponding texts to each call issue category
77
*/
8-
export interface SurveyCategories {
8+
export interface SurveyIssuesHeadingStrings {
99
overallRating: string;
1010
audioRating: string;
1111
videoRating: string;

packages/react-components/src/types/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ export * from './OnRender';
1111
export * from './ReadReceiptsBySenderId';
1212
export * from './CaptionsAvailableLanguageStrings';
1313
export * from './SurveyIssues';
14-
export * from './SurveyCategories';
14+
export * from './SurveyIssuesHeadingStrings';

packages/storybook/stories/INTERNAL/Survey/TagsSurvey.stories.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ const TagsSurveyStory = (): JSX.Element => {
8585
}
8686
};
8787

88-
const categoriesToHeader = {
88+
const categoryHeadings = {
8989
overallRating: 'Overall',
9090
audioRating: 'Audio',
9191
videoRating: 'Video',
@@ -118,7 +118,7 @@ const TagsSurveyStory = (): JSX.Element => {
118118
strings={strings}
119119
issues={issues}
120120
callIssuesToTag={callIssuesToTag}
121-
categoriesToHeader={categoriesToHeader}
121+
categoryHeadings={categoryHeadings}
122122
/>
123123
</div>
124124
);
@@ -133,7 +133,7 @@ export default {
133133
argTypes: {
134134
issues: hiddenControl,
135135
callIssuesToTag: hiddenControl,
136-
categoriesToHeader: hiddenControl,
136+
categoryHeadings: hiddenControl,
137137
onConfirm: hiddenControl,
138138
strings: hiddenControl
139139
},

packages/storybook/stories/INTERNAL/Survey/snippets/TagsSurvey.snippet.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export const TagsSurveyExample: () => JSX.Element = () => {
7171
'Echo',
7272
'Freezes'
7373
];
74-
const categoriesToHeader = {
74+
const categoryHeadings = {
7575
overallRating: 'Overall',
7676
audioRating: 'Audio',
7777
videoRating: 'Video',
@@ -83,7 +83,7 @@ export const TagsSurveyExample: () => JSX.Element = () => {
8383
strings={strings}
8484
issues={issues}
8585
callIssuesToTag={callIssuesToTag}
86-
categoriesToHeader={categoriesToHeader}
86+
categoryHeadings={categoryHeadings}
8787
/>
8888
);
8989
};

0 commit comments

Comments
 (0)