diff --git a/website/src/components/UserFeedback/UserFeedback.stories.jsx b/website/src/components/UserFeedback/UserFeedback.stories.jsx index 3414ff0457..c1aab5462f 100644 --- a/website/src/components/UserFeedback/UserFeedback.stories.jsx +++ b/website/src/components/UserFeedback/UserFeedback.stories.jsx @@ -13,13 +13,13 @@ FullComponent.args = { // initialData, }; -export const Step2 = Template.bind({}); -Step2.args = { - seedData: { - ...initialData, - currentStep: 2, - }, -}; +// export const Step2 = Template.bind({}); +// Step2.args = { +// seedData: { +// ...initialData, +// currentStep: 2, +// }, +// }; export const Step3 = Template.bind({}); export const Closed = Template.bind({}); diff --git a/website/src/components/UserFeedback/index.jsx b/website/src/components/UserFeedback/index.jsx index 1ccb50e8b8..f90c04539e 100644 --- a/website/src/components/UserFeedback/index.jsx +++ b/website/src/components/UserFeedback/index.jsx @@ -17,10 +17,14 @@ const fetchData = (initialData) => { const localstorageKey = 'user-feedback'; return { + currentStep: 1, + ...initialData, data: { score: undefined, + comment: undefined, + customerType: undefined, + ...initialData?.data, }, - ...initialData, initialized: Date.now(), closedOrCompleted: false, }; @@ -35,7 +39,7 @@ const stateReducer = (state, message) => { case 'set score': return { ...state, - // data: { ...state.data, score: message.data }, + data: { ...state.data, score: message.data }, }; case 'set comment': return { @@ -50,19 +54,19 @@ const stateReducer = (state, message) => { case 'step forward': return { ...state, - currentStep: min(state.currentStep + 1, 3), + currentStep: Math.min(state.currentStep + 1, 3), }; case 'step back': return { ...state, - currentStep: max(state.currentStep - 1, 1), + currentStep: Math.max(state.currentStep - 1, 1), }; } return state; }; export const FeedbackWrapper = ({ seedData }) => { - const [feedbackIsOpen, setFeedbackIsOpen] = React.useState(false); + // const [feedbackIsOpen, setFeedbackIsOpen] = React.useState(false); const [state, dispatch] = React.useReducer( stateReducer, @@ -70,9 +74,10 @@ export const FeedbackWrapper = ({ seedData }) => { fetchData, ); + console.log(state, state.data); + const clear = () => dispatch({ kind: 'clear' }); - const stepForward = (e) => { - e.preventDefault(); + const stepForward = () => { console.log('stepping forward!'); dispatch({ kind: 'step forward' }); }; @@ -84,6 +89,7 @@ export const FeedbackWrapper = ({ seedData }) => { dispatch({ kind: 'set customer type', data: customerType }); const Step1 = () => { + const [newValue, setNewValue] = React.useState(undefined); return (

@@ -113,7 +119,7 @@ export const FeedbackWrapper = ({ seedData }) => { onChange={(e) => { const value = parseInt(e.target.value); console.log('the value is', value); - /* setScore(value); */ + setNewValue(value); }} />

- - +
@@ -138,8 +157,6 @@ export const FeedbackWrapper = ({ seedData }) => { ); }; - console.log('bluh'); - return (
@@ -150,7 +167,13 @@ export const FeedbackWrapper = ({ seedData }) => {
- + {state.currentStep === 1 ? ( + + ) : state.currentStep === 2 ? ( + + ) : ( + + )}
); };