11import React , { useState } from 'react'
2- import { Button , Container } from 'react-bootstrap'
2+ import { Button , Container , Form } from 'react-bootstrap'
33import { useAppHooks } from '../hooks'
4- import { ItemsPricingTopBar , QuoteCreation , ROUTES } from '../shared'
5- import { PcAccordion } from '../ui'
4+ import { ItemsPricingTopBar , ItemTotalPrice , QuoteCreation , ROUTES } from '../shared'
5+ import { PcAccordion , PcItemAccordion , PcItemFormGroup , PcItemTextareaControl } from '../ui'
66import { getCurrentStepId } from '../utils'
77
88export const ItemsPricing = ( ) => {
99 const { navigate, queryParams, location } = useAppHooks ( )
10- const quoteId = queryParams . get ( 'quote_id' )
11- const currentStepId = getCurrentStepId ( location . pathname )
12- const totalPrice = 123 // TODO: get total price from BE
1310
1411 const [ selectedCategories , setSelectedCategories ] = useState ( [ ] )
1512 const [ expandedAccordions , setExpandedAccordions ] = useState ( [ ] ) // array of IDs
13+ const [ isNotesShow , setIsNotesShow ] = useState ( false )
14+ const [ notesValue , setNotesValue ] = useState ( '' )
15+ const [ includeNotes , setIncludeNotes ] = useState ( false )
16+
17+ const quoteId = queryParams . get ( 'quote_id' )
18+ const currentStepId = getCurrentStepId ( location . pathname )
19+ const totalPrice = 123 // TODO: get total price from BE
20+ const notesIcon = notesValue . trim ( ) ? 'noted' : 'note'
1621
1722 const handleToggle = ( id ) => {
1823 setExpandedAccordions ( ( prev ) =>
1924 prev . includes ( id ) ? prev . filter ( item => item !== id ) : [ ...prev , id ] ,
2025 )
2126 }
22-
23- const expandAll = ( ) => {
24- setExpandedAccordions ( selectedCategories . map ( category => category . id ) )
25- }
26-
27- const collapseAll = ( ) => {
28- setExpandedAccordions ( [ ] )
29- }
30-
27+ const expandAll = ( ) => setExpandedAccordions ( selectedCategories . map ( category => category . id ) )
28+ const collapseAll = ( ) => setExpandedAccordions ( [ ] )
3129 const handleDownload = ( ) => {
3230 // await fetchQuotes.update(quoteId, {
3331 // quote: { step: STEPS.COMPLETED },
3432 // })
3533 }
36-
37- const handleBack = ( ) => {
38- navigate ( ROUTES . CUSTOMER_INFO )
39- }
34+ const handleBack = ( ) => navigate ( ROUTES . CUSTOMER_INFO )
35+ const handleIncludeNotes = ( e ) => setIncludeNotes ( e . target . checked )
36+ const handleNotesValue = ( e ) => setNotesValue ( e . target . value )
4037
4138 return (
4239 < Container className = { 'wrapper' } >
@@ -60,18 +57,47 @@ export const ItemsPricing = () => {
6057 }
6158 </ section >
6259
63- < section className = { 'mb-8' } >
60+ < section className = { 'd-flex flex-column gap-4 mb-8' } >
61+ { selectedCategories . length > 0 && selectedCategories . map ( ( category ) => (
62+ < PcAccordion
63+ key = { category . id }
64+ categoryName = { category . name }
65+ isOpen = { expandedAccordions . includes ( category . id ) }
66+ onToggle = { ( ) => handleToggle ( category . id ) }
67+ >
68+ { /*List of items */ }
69+ < div className = { 'd-flex flex-column gap-5' } >
70+ { /*TODO: Example of Fixed Price. Will be changed after adding logic*/ }
71+ < PcItemAccordion
72+ key = { 'fixed-price' }
73+ itemName = { 'Decision Success' }
74+ isNotesShow = { isNotesShow }
75+ setIsNotesShow = { setIsNotesShow }
76+ notesIcon = { notesIcon }
77+ >
78+ < ItemTotalPrice name = { '' } className = { 'mb-4' } />
6479
65- < div className = { 'd-flex flex-column gap-4' } >
66- { selectedCategories . length > 0 && selectedCategories . map ( ( category ) => (
67- < PcAccordion
68- key = { category . id }
69- category = { category . name }
70- isOpen = { expandedAccordions . includes ( category . id ) }
71- onToggle = { ( ) => handleToggle ( category . id ) }
72- />
73- ) ) }
74- </ div >
80+ { isNotesShow &&
81+ < PcItemFormGroup label = { 'Notes' } itemType = { 'notes' } >
82+ < PcItemTextareaControl
83+ placeholder = { '' }
84+ className = { 'mb-3' }
85+ value = { notesValue }
86+ onChange = { handleNotesValue }
87+ />
88+ < Form . Check
89+ type = { 'checkbox' }
90+ label = { `Include notes with quote` }
91+ className = { 'fs-10' }
92+ checked = { includeNotes }
93+ onChange = { handleIncludeNotes }
94+ />
95+ </ PcItemFormGroup >
96+ }
97+ </ PcItemAccordion >
98+ </ div >
99+ </ PcAccordion >
100+ ) ) }
75101 </ section >
76102
77103 { /* Buttons section */ }
0 commit comments