Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
B
burger-builder-template
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Нұрасыл Қайратұлы
burger-builder-template
Commits
7ad636c0
Commit
7ad636c0
authored
Dec 16, 2024
by
Нұрасыл Қайратұлы
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add order now
parent
6fbfdb79
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
118 additions
and
2 deletions
+118
-2
BuildControls.tsx
src/components/BuildControls/BuildControls.tsx
+9
-2
OrderSummary.tsx
src/components/Burger/OrderSummary/OrderSummary.tsx
+33
-0
Backdrop.css
src/components/UI/Backdrop/Backdrop.css
+9
-0
Backdrop.tsx
src/components/UI/Backdrop/Backdrop.tsx
+13
-0
Modal.css
src/components/UI/Modal/Modal.css
+21
-0
Modal.tsx
src/components/UI/Modal/Modal.tsx
+22
-0
BurgerBuilder.tsx
src/containers/BurgerBuilder/BurgerBuilder.tsx
+11
-0
No files found.
src/components/BuildControls/BuildControls.tsx
View file @
7ad636c0
...
...
@@ -8,9 +8,10 @@ interface Props {
ingredients
:
Ingredients
lessHandler
:
(
ingKey
:
IngredientNames
)
=>
void
moreHandler
:
(
ingKey
:
IngredientNames
)
=>
void
setOpen
:
React
.
Dispatch
<
React
.
SetStateAction
<
boolean
>>
}
const
BuildControls
=
({
ingredients
,
purchasable
,
price
,
lessHandler
,
moreHandler
}:
Props
)
=>
{
const
BuildControls
=
({
ingredients
,
purchasable
,
price
,
setOpen
,
lessHandler
,
moreHandler
}:
Props
)
=>
{
const
ingKeys
=
Object
.
keys
(
ingredients
)
return
(
...
...
@@ -29,7 +30,13 @@ const BuildControls = ({ingredients, purchasable, price, lessHandler, moreHandle
))
}
<
button
className=
"OrderButton"
disabled=
{
!
purchasable
}
>
ORDER NOW
</
button
>
<
button
className=
"OrderButton"
disabled=
{
!
purchasable
}
onClick=
{
()
=>
setOpen
(
true
)
}
>
ORDER NOW
</
button
>
</
div
>
);
}
...
...
src/components/Burger/OrderSummary/OrderSummary.tsx
0 → 100644
View file @
7ad636c0
import
{
IngredientNames
,
Ingredients
}
from
'@/interfaces/Ingredients'
;
interface
Props
{
ingredients
:
Ingredients
;
price
:
number
;
}
const
OrderSummary
=
({
price
,
ingredients
}:
Props
)
=>
{
const
ingredientSummary
=
Object
.
keys
(
ingredients
)
.
map
((
ingKey
)
=>
{
return
(
<
li
key=
{
ingKey
}
>
<
span
style=
{
{
textTransform
:
'capitalize'
}
}
>
{
ingKey
}
</
span
>
:
{
ingredients
[
ingKey
as
IngredientNames
]
}
</
li
>
)
})
return
(
<>
<
h3
>
Your order
</
h3
>
<
p
>
A delicious burger with the following ingredients:
</
p
>
<
ul
>
{
ingredientSummary
}
</
ul
>
<
p
><
strong
>
Total Price:
{
price
}
₸
</
strong
></
p
>
<
p
>
Continue to checkout?
</
p
>
</>
)
}
export
default
OrderSummary
\ No newline at end of file
src/components/UI/Backdrop/Backdrop.css
0 → 100644
View file @
7ad636c0
.Backdrop
{
width
:
100%
;
height
:
100%
;
position
:
fixed
;
z-index
:
100
;
left
:
0
;
top
:
0
;
background-color
:
rgba
(
0
,
0
,
0
,
0.5
);
}
\ No newline at end of file
src/components/UI/Backdrop/Backdrop.tsx
0 → 100644
View file @
7ad636c0
import
'./Backdrop.css'
interface
Props
{
setOpen
:
React
.
Dispatch
<
React
.
SetStateAction
<
boolean
>>
}
const
Backdrop
=
({
setOpen
}:
Props
)
=>
{
return
(
<
div
className=
'Backdrop'
onClick=
{
()
=>
setOpen
(
false
)
}
></
div
>
)
}
export
default
Backdrop
\ No newline at end of file
src/components/UI/Modal/Modal.css
0 → 100644
View file @
7ad636c0
.Modal
{
position
:
fixed
;
z-index
:
500
;
background-color
:
white
;
width
:
70%
;
border
:
1px
solid
#ccc
;
box-shadow
:
1px
1px
1px
black
;
padding
:
16px
;
left
:
15%
;
top
:
30%
;
box-sizing
:
border-box
;
transition
:
all
0.3s
ease-out
;
color
:
black
;
}
@media
(
min-width
:
600px
)
{
.Modal
{
width
:
500px
;
left
:
calc
(
50%
-
250px
);
}
}
\ No newline at end of file
src/components/UI/Modal/Modal.tsx
0 → 100644
View file @
7ad636c0
import
{
ReactNode
}
from
"react"
import
'./Modal.css'
import
Backdrop
from
"../Backdrop/Backdrop"
type
TProps
=
{
children
:
ReactNode
open
:
boolean
setOpen
:
React
.
Dispatch
<
React
.
SetStateAction
<
boolean
>>
}
const
Modal
=
({
open
,
setOpen
,
children
}:
TProps
)
=>
{
return
open
?
(
<>
<
Backdrop
setOpen=
{
setOpen
}
/>
<
div
className=
"Modal"
>
{
children
}
</
div
>
</>
)
:
null
}
export
default
Modal
\ No newline at end of file
src/containers/BurgerBuilder/BurgerBuilder.tsx
View file @
7ad636c0
import
BuildControls
from
'@/components/BuildControls/BuildControls'
;
import
Burger
from
'@/components/Burger/Burger'
;
import
OrderSummary
from
'@/components/Burger/OrderSummary/OrderSummary'
;
import
Modal
from
'@/components/UI/Modal/Modal'
;
import
{
IngredientNames
,
IngredientPrices
,
Ingredients
}
from
'@/interfaces/Ingredients'
;
import
{
useState
}
from
'react'
;
const
BurgerBuilder
=
()
=>
{
const
[
totalPrice
,
setTotalPrice
]
=
useState
<
number
>
(
IngredientPrices
.
bread
);
const
[
purchasable
,
setPurchasable
]
=
useState
<
boolean
>
(
false
);
const
[
open
,
setOpen
]
=
useState
<
boolean
>
(
false
);
const
[
ingredients
,
setIngredients
]
=
useState
<
Ingredients
>
({
salad
:
0
,
cheese
:
0
,
...
...
@@ -55,11 +58,19 @@ const BurgerBuilder = () => {
return
(
<>
<
Modal
open=
{
open
}
setOpen=
{
setOpen
}
>
<
OrderSummary
price=
{
totalPrice
}
ingredients=
{
ingredients
}
/>
</
Modal
>
<
Burger
ingredients=
{
ingredients
}
/>
<
BuildControls
ingredients=
{
ingredients
}
lessHandler=
{
lessHandler
}
moreHandler=
{
moreHandler
}
setOpen=
{
setOpen
}
price=
{
totalPrice
}
purchasable=
{
purchasable
}
/>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment