-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from logion-network/feature/cost-calculator
Cost calculator
- Loading branch information
Showing
50 changed files
with
2,527 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,9 @@ | |
--header-height: 252px; | ||
} | ||
} | ||
|
||
@media print { | ||
.App .content { | ||
padding-top: 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.Center { | ||
text-align: center; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { ReactNode } from "react" | ||
import "./Center.css"; | ||
|
||
export interface Props { | ||
children: ReactNode; | ||
} | ||
|
||
export default function Center(props: Props) { | ||
return ( | ||
<div className="Center">{ props.children }</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,3 +38,9 @@ | |
.Footer .legal p:last-child { | ||
margin-bottom: 0; | ||
} | ||
|
||
@media print { | ||
.Footer { | ||
display: none; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,3 +20,9 @@ | |
align-items: center; | ||
} | ||
} | ||
|
||
@media print { | ||
.Header { | ||
display: none; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.AddLocButtons { | ||
margin-top: 30px; | ||
} | ||
|
||
.AddLocButtons .btn-toolbar { | ||
justify-content: center; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { Button, ButtonGroup, ButtonToolbar } from "react-bootstrap"; | ||
import { useCalculatorContext } from "./CalculatorContext"; | ||
import { useCallback, useState } from "react"; | ||
import { LocType } from "@logion/node-api"; | ||
import { LegalOfficerCaseCost } from "./LegalOfficerCaseCost"; | ||
import "./AddLocButtons.css"; | ||
|
||
export default function AddLocButtons() { | ||
const { addLocCost } = useCalculatorContext(); | ||
const [ adding, setAdding ] = useState(false); | ||
|
||
const addLoc = useCallback(async (locType: LocType) => { | ||
setAdding(true); | ||
try { | ||
if(locType === "Identity") { | ||
await addLocCost(LegalOfficerCaseCost.defaultIdentityLocCost()); | ||
} else if(locType === "Transaction") { | ||
await addLocCost(LegalOfficerCaseCost.defaultTransactionLocCost()); | ||
} else if(locType === "Collection") { | ||
await addLocCost(LegalOfficerCaseCost.defaultCollectionLocCost()); | ||
} else { | ||
throw new Error(""); | ||
} | ||
} finally { | ||
setAdding(false); | ||
} | ||
}, [ addLocCost ]); | ||
|
||
return ( | ||
<div className="AddLocButtons"> | ||
<ButtonToolbar> | ||
<ButtonGroup className="me-2"> | ||
<Button onClick={ () => addLoc("Identity") } disabled={ adding }>Add an ID LOC</Button> | ||
</ButtonGroup> | ||
<ButtonGroup className="me-2"> | ||
<Button onClick={ () => addLoc("Transaction") } disabled={ adding }>Add a Transaction LOC</Button> | ||
</ButtonGroup> | ||
<ButtonGroup className="me-2"> | ||
<Button onClick={ () => addLoc("Collection") } disabled={ adding }>Add a Collection LOC</Button> | ||
</ButtonGroup> | ||
</ButtonToolbar> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Lgnt } from "@logion/node-api"; | ||
import { useCallback, useMemo } from "react"; | ||
import { InputGroup } from "react-bootstrap"; | ||
import DebounceFormControl from "./DebounceFormControl"; | ||
|
||
export interface Props { | ||
amount?: Lgnt; | ||
readOnly?: boolean; | ||
onChange?: (value: Lgnt) => void; | ||
disabled?: boolean; | ||
} | ||
|
||
export default function AmountInputGroup(props: Props) { | ||
const value = useMemo(() => props.amount?.toPrefixedNumber().coefficient.unnormalize() || "0", [ props.amount ]); | ||
|
||
const onChange = useCallback((value: string) => { | ||
if(props.onChange) { | ||
const nLgnt = Number(value); | ||
props.onChange(Lgnt.from(nLgnt)); | ||
} | ||
}, [ props ]); | ||
|
||
return ( | ||
<InputGroup> | ||
<DebounceFormControl | ||
value={ value } | ||
readOnly={ props.readOnly } | ||
disabled={ props.disabled } | ||
onChange={ props.onChange ? onChange : undefined } | ||
type="number" | ||
format | ||
/> | ||
<InputGroup.Text>{ Lgnt.CODE }</InputGroup.Text> | ||
</InputGroup> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
.Calculator .top-bar { | ||
margin-top: 20px; | ||
} | ||
|
||
.Calculator .accordion-header .loc-description { | ||
display: inline-block; | ||
width: calc(100% - 150px); | ||
} | ||
|
||
@media print { | ||
.Calculator .btn { | ||
display: none; | ||
} | ||
|
||
.Calculator .accordion-button { | ||
font-size: 1.7rem; | ||
color: var(--color1-color); | ||
} | ||
} |
Oops, something went wrong.