Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
B
burger-project
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-project
Commits
5299eb97
Commit
5299eb97
authored
Nov 27, 2025
by
anton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
first_lesson-4
parent
8ea89b32
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
3 deletions
+19
-3
BuildControls.tsx
src/components/BuildControls/BuildControls.tsx
+3
-1
BurgerBuilder.tsx
src/containers/BurgerBuilder/BurgerBuilder.tsx
+8
-2
burger-interface.ts
src/interfaces/burger-interface.ts
+8
-0
No files found.
src/components/BuildControls/BuildControls.tsx
View file @
5299eb97
...
...
@@ -4,15 +4,17 @@ import { BuildControl } from "@/components/BuildControls/BuildControl/BuildContr
interface
Props
{
ingredients
:
Ingredients
;
totalPrice
:
number
;
hadlerLess
:
(
key
:
IngredientNames
)
=>
void
;
hadlerMore
:
(
key
:
IngredientNames
)
=>
void
;
}
export
function
BuildControls
({
ingredients
,
hadlerLess
,
hadlerMore
}:
Props
)
{
export
function
BuildControls
({
ingredients
,
totalPrice
,
hadlerLess
,
hadlerMore
}:
Props
)
{
const
ingrKeys
=
Object
.
keys
(
ingredients
)
as
(
keyof
Ingredients
)[];
return
(
<
div
className=
"BuildControls"
>
<
p
>
Price:
{
totalPrice
}
</
p
>
{
ingrKeys
.
map
((
key
,
i
)
=>
(
<
BuildControl
key=
{
key
+
i
}
...
...
src/containers/BurgerBuilder/BurgerBuilder.tsx
View file @
5299eb97
import
{
BuildControls
}
from
"@/components/BuildControls/BuildControls"
;
import
{
Burger
}
from
"@/components/Burger/Burger"
;
import
{
IngredientNames
,
Ingredients
}
from
"@/interfaces/burger-interface"
;
import
{
IngredientNames
,
Ingredient
Prices
,
Ingredient
s
}
from
"@/interfaces/burger-interface"
;
import
{
useState
}
from
"react"
;
export
function
BurgerBuilder
()
{
const
[
totalPrice
,
setTotalPrice
]
=
useState
<
number
>
(
IngredientPrices
.
cheese
);
const
[
ingredients
,
setIngredients
]
=
useState
<
Ingredients
>
({
salad
:
0
,
cheese
:
0
,
...
...
@@ -27,7 +28,12 @@ export function BurgerBuilder() {
return
(
<>
<
Burger
ingredients=
{
ingredients
}
/>
<
BuildControls
ingredients=
{
ingredients
}
hadlerLess=
{
hadlerLess
}
hadlerMore=
{
hadlerMore
}
/>
<
BuildControls
ingredients=
{
ingredients
}
hadlerLess=
{
hadlerLess
}
hadlerMore=
{
hadlerMore
}
totalPrice=
{
totalPrice
}
/>
</>
);
}
src/interfaces/burger-interface.ts
View file @
5299eb97
...
...
@@ -3,3 +3,11 @@ export type IngredientNames = "salad" | "cheese" | "meat" | "bacon";
export
type
Ingredients
=
{
[
key
in
IngredientNames
]:
number
;
};
export
enum
IngredientPrices
{
salad
=
200
,
cheese
=
400
,
bacon
=
700
,
meat
=
900
,
bread
=
150
,
}
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