mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-06 00:07:44 +01:00
dbb62631a6
* refactor: add screen-reader-only util class * refactor: move FeedbackNPS component * feat: add FeedbackCES component * refactor: improve hidden checkbox styles * refactor: fix IFeedbackEndpointRequestBody source type * refactor: remove unnecessary event.persist() calls * refactor: remove disableEscapeKeyDown from FeedbackCES modal * refactor: make textarea label customizable * refactor: store feedback state on the backend * refactor: add FeedbackCESForm snapshot test * refactor: use extant IAuthFeedback type * refactor: fix showNPSFeedback logic for multiple feedback types
41 lines
1.0 KiB
TypeScript
41 lines
1.0 KiB
TypeScript
import { IFeedbackCESForm } from 'component/feedback/FeedbackCES/FeedbackCESForm';
|
|
|
|
interface IFeedbackEndpointRequestBody {
|
|
source: 'app' | 'app:segments';
|
|
data: {
|
|
score: number;
|
|
comment?: string;
|
|
customerType?: 'open source' | 'paying';
|
|
openedManually?: boolean;
|
|
currentPage?: string;
|
|
};
|
|
}
|
|
|
|
export const sendFeedbackInput = async (
|
|
form: Partial<IFeedbackCESForm>
|
|
): Promise<void> => {
|
|
if (!form.score) {
|
|
return;
|
|
}
|
|
|
|
const body: IFeedbackEndpointRequestBody = {
|
|
source: 'app:segments',
|
|
data: {
|
|
score: form.score,
|
|
comment: form.comment,
|
|
currentPage: form.path,
|
|
openedManually: false,
|
|
customerType: 'paying',
|
|
},
|
|
};
|
|
|
|
await fetch(
|
|
'https://europe-west3-docs-feedback-v1.cloudfunctions.net/function-1',
|
|
{
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify(body),
|
|
}
|
|
);
|
|
};
|