-
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.
feat(pcomparator): handle new products on scan
- Loading branch information
1 parent
a2f1fcc
commit f30db13
Showing
7 changed files
with
131 additions
and
23 deletions.
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
pcomparator/src/applications/Prices/Ui/NewQuickPrice/NewQuickPrice.tsx
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,73 @@ | ||
import { Trans } from "@lingui/macro"; | ||
import { | ||
Button, | ||
Card, | ||
CardBody, | ||
Input, | ||
Modal, | ||
ModalBody, | ||
ModalContent, | ||
ModalFooter, | ||
ModalHeader | ||
} from "@nextui-org/react"; | ||
import { Info } from "lucide-react"; | ||
import { useState } from "react"; | ||
import { Location } from "~/applications/Prices/Ui/NewPrice/FormSteps/Step4/Location"; | ||
import { Stepper } from "~/components/Stepper/Stepper"; | ||
|
||
interface NewQuickPriceProps { | ||
isOpen: boolean; | ||
onOpenChange: () => void; | ||
productName: string; | ||
} | ||
|
||
export const NewQuickPrice = ({ isOpen, onOpenChange, productName }: NewQuickPriceProps) => { | ||
const [step, setStep] = useState(1); | ||
|
||
return ( | ||
<Modal isOpen={isOpen} onOpenChange={onOpenChange}> | ||
<ModalContent> | ||
<ModalHeader className="mt-4"> | ||
<Stepper steps={[{ label: "Price" }, { label: "Location" }]} currentStep={step} /> | ||
</ModalHeader> | ||
{step === 1 ? ( | ||
<form onSubmit={() => setStep(2)}> | ||
<ModalBody> | ||
<Card> | ||
<CardBody className="flex !flex-row gap-6 dark:bg-yellow-200/[0.06]"> | ||
<Info color="#f4e28d" size="22px" /> | ||
<div className="flex-1"> | ||
<p className="text-small"> | ||
<Trans>Product "{productName}" was not found but added to your account.</Trans> | ||
</p> | ||
<p className="text-small mt-2">Add a price to validate it.</p> | ||
</div> | ||
</CardBody> | ||
</Card> | ||
<Input | ||
type="text" | ||
name="price" | ||
placeholder="2.99" | ||
label={<Trans>Price</Trans>} | ||
labelPlacement="outside" | ||
size="lg" | ||
/> | ||
</ModalBody> | ||
<ModalFooter> | ||
<Button color="primary" type="submit"> | ||
Next | ||
</Button> | ||
</ModalFooter> | ||
</form> | ||
) : ( | ||
<Location | ||
onPrevious={() => setStep(1)} | ||
onNextStep={async (data) => { | ||
console.log(data); | ||
}} | ||
/> | ||
)} | ||
</ModalContent> | ||
</Modal> | ||
); | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
"use client"; | ||
|
||
import { useDisclosure } from "@nextui-org/react"; | ||
import dynamic from "next/dynamic"; | ||
import { useState } from "react"; | ||
const NewQuickPrice = dynamic(() => | ||
import("~/applications/Prices/Ui/NewQuickPrice/NewQuickPrice").then((mod) => mod.NewQuickPrice) | ||
); | ||
import { SearchBarcode } from "~/applications/Searchbar/Ui/SearchBarcode/SearchBarcode"; | ||
import { Tabbar as TabbarComponent } from "~/components/Tabbar/Tabbar"; | ||
|
||
export const Tabbar = () => { | ||
const [productName, setProductName] = useState<string | null>(null); | ||
const { isOpen, onOpenChange, onOpen } = useDisclosure(); | ||
|
||
return ( | ||
<> | ||
<TabbarComponent | ||
mainButton={ | ||
<SearchBarcode | ||
onNewProduct={(productName) => { | ||
setProductName(productName); | ||
onOpen(); | ||
}} | ||
/> | ||
} | ||
/> | ||
{isOpen && productName ? ( | ||
<NewQuickPrice isOpen={isOpen} onOpenChange={onOpenChange} productName={productName} /> | ||
) : null} | ||
</> | ||
); | ||
}; |
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