diff --git a/website/src/components/UserFeedback/index.jsx b/website/src/components/UserFeedback/index.jsx index fd4a1af39d..61affb3e81 100644 --- a/website/src/components/UserFeedback/index.jsx +++ b/website/src/components/UserFeedback/index.jsx @@ -1,55 +1,138 @@ import React from 'react'; import styles from './styles.module.css'; -import CloseIcon from '@site/src/icons/close' +import CloseIcon from '@site/src/icons/close'; -const join = (...cs) => cs.join(" ") +const join = (...cs) => cs.join(' '); -const Component = ({ text }) => ( -
-
- -
-
-

- - On a scale from 1 to 5 where 1 is very unsatisfied and 5 is - very satisfied, - {' '} - How would you rate your overall satisfaction with the Unleash - documentation? -

+const Step1 = () => <>; +const Step2 = () => <>; +const Step3 = () => <>; -
- - {[1, 2, 3, 4, 5].map((n) => ( - - - +const initialData = () => ({ + initialized: Date.now(), + closedOrCompleted: false, + data: { + score: undefined, + comment: undefined, + customerType: undefined, + }, +}); + +const fetchData = (initialData) => { + const localstorageKey = 'user-feedback'; + + return initialData; + // check localstorage + // populate if there is +}; + +const FeedbackWrapper = () => { + const [feedbackIsOpen, setFeedbackIsOpen] = React.useState(false); + const stateReducer = (state, message) => { + switch (message.kind) { + case 'clear': + return initialData(); + case 'set score': + return { + ...state, + data: { ...state.data, score: message.data }, + }; + case 'set comment': + return { + ...state, + data: { ...state.data, comment: message.data }, + }; + case 'set customer type': + return { + ...state, + data: { ...state.data, customerType: message.data }, + }; + } + return state; + }; + + const [state, dispatch] = React.useReducer( + stateReducer, + initialData(), + fetchData, + ); + + const clear = () => dispatch({ kind: 'clear' }); + const setScore = (score) => dispatch({ kind: 'set score', data: score }); + const setComment = (comment) => + dispatch({ kind: 'set comment', data: comment }); + const setCustomerType = (customerType) => + dispatch({ kind: 'set customer type', data: customerType }); + + return feedbackIsOpen ? ( + setFeedbackIsOpen(false)} /> + ) : ( + setFeedbackIsOpen(true)} /> + ); +}; + +const OpenFeedbackButton = ({ openFeedback }) => { + return ; +}; + +const Component = ({ closeFeedback = () => undefined }) => { + return ( +
+
+
-
- - -
- -
-); +
+

+ + On a scale from 1 to 5 where 1 is very unsatisfied and 5 + is very satisfied, + {' '} + How would you rate your overall satisfaction with the + Unleash documentation? +

+ +
+ + {[1, 2, 3, 4, 5].map((n) => ( + + + + + ))} + +
+
+ + +
+
+
+ ); +}; export default Component;