Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
scottrepreneur committed Jan 26, 2024
1 parent 15a2481 commit bc91ae1
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 26 deletions.
1 change: 0 additions & 1 deletion packages/dapp/pages/create/escrow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
Stack,
Text,
useBreakpointValue,
Stack,
} from '@chakra-ui/react';
import { ESCROW_STEPS } from '@smart-invoice/constants';
import {
Expand Down
1 change: 0 additions & 1 deletion packages/dapp/pages/create/instant.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
Stack,
Text,
useBreakpointValue,
Stack,
} from '@chakra-ui/react';
import { INSTANT_STEPS, INVOICE_TYPES } from '@smart-invoice/constants';
import {
Expand Down
13 changes: 6 additions & 7 deletions packages/dapp/pages/invoice/[chainId]/[invoiceId]/instant.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
Tooltip,
useBreakpointValue,
useClipboard,
Stack,
Wrap,
WrapItem,
} from '@chakra-ui/react';
Expand Down Expand Up @@ -260,14 +259,14 @@ function ViewInstantInvoice() {
<Text color="black">{projectDescription}</Text>
)}

<Link
{/* <Link
href={getAgreementLink(projectAgreement)}
isExternal
textDecor="underline"
color="black"
>
Details of Agreement
</Link>
</Link> */}
</Stack>

<Stack fontSize="sm" color="grey" align="stretch" justify="center">
Expand All @@ -278,7 +277,7 @@ function ViewInstantInvoice() {
</WrapItem>

<WrapItem>
<Text fontWeight="bold">{getDateString(startDate)}</Text>
{/* <Text fontWeight="bold">{getDateString(startDate)}</Text> */}
</WrapItem>
</Wrap>
) : null}
Expand All @@ -289,7 +288,7 @@ function ViewInstantInvoice() {
</WrapItem>

<WrapItem>
<Text fontWeight="bold">{getDateString(endDate)}</Text>
{/* <Text fontWeight="bold">{getDateString(endDate)}</Text> */}
</WrapItem>
</Wrap>
) : null}
Expand Down Expand Up @@ -345,12 +344,12 @@ function ViewInstantInvoice() {
</Wrap>

<Wrap>
<GenerateInvoicePDF
{/* <GenerateInvoicePDF
invoice={invoice}
symbol={symbol}
buttonText="Preview & Download Invoice PDF"
buttonProps={{ textColor: 'blue.dark' }}
/>
/> */}
</Wrap>
</Stack>
</Stack>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Button, Heading, Link, Text, Stack } from '@chakra-ui/react';
import { Button, Heading, Link, Stack, Text } from '@chakra-ui/react';
import { ChainId } from '@smart-invoice/constants';
import { fetchInvoice, Invoice } from '@smart-invoice/graphql';
import { Container, InvoiceNotFound, Loader } from '@smart-invoice/ui';
Expand Down
2 changes: 1 addition & 1 deletion packages/dapp/pages/invoices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function Invoices() {
>
{chainId ? (
<Heading color="gray" size="lg">
No invoices found on {chainsMap(chainId).name}.
No invoices found on {chainsMap(chainId)?.name}.
</Heading>
) : (
<Heading color="gray" size="lg">
Expand Down
2 changes: 2 additions & 0 deletions packages/forms/src/FormConfirmation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export function FormConfirmation({
endDate,
safetyValveDate,
resolver,
customResolver,
milestones,
token,
} = watch();
Expand All @@ -67,6 +68,7 @@ export function FormConfirmation({
endDate,
safetyValveDate,
resolver,
customResolver,
milestones,
token,
toast,
Expand Down
6 changes: 3 additions & 3 deletions packages/forms/src/InvoicePaymentDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export function InvoicePaymentDetails({ invoice }: { invoice: Invoice }) {
: BigInt(0);
const isReleasable =
!isLocked && amount ? balance >= BigInt(amount) && balance > 0 : false;
const sum = _.sumBy(amounts, _.toNumber);
// const sum = _.sumBy(amounts, _.toNumber);

const tokenInfo = getTokenInfo(chainId, token, tokenData);

Expand Down Expand Up @@ -152,7 +152,7 @@ export function InvoicePaymentDetails({ invoice }: { invoice: Invoice }) {
<HStack align="center" justify="flex-end">
{index < _.toNumber(currentMilestone?.toString()) &&
_.size(releases) > index &&
!!releases?.[index].timestamp && (
!!releases?.[index]?.timestamp && (
<Link
fontSize="xs"
isExternal
Expand All @@ -170,7 +170,7 @@ export function InvoicePaymentDetails({ invoice }: { invoice: Invoice }) {
_.lt(index, currentMilestone) && _.size(releases) > index
) &&
index !== -1 &&
!!deposits?.[index].timestamp && (
!!deposits?.[index]?.timestamp && (
<Link
fontSize="xs"
isExternal
Expand Down
24 changes: 13 additions & 11 deletions packages/forms/src/PaymentsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { ESCROW_STEPS } from '@smart-invoice/constants';
import { useFetchTokens } from '@smart-invoice/hooks';
import { FormInvoice } from '@smart-invoice/types';
import { NumberInput, QuestionIcon, Select } from '@smart-invoice/ui';
import { commify, getTokenInfo, getTokens } from '@smart-invoice/utils';
import { commify } from '@smart-invoice/utils';
import _ from 'lodash';
import { useEffect, useMemo } from 'react';
import { useFieldArray, useForm, UseFormReturn } from 'react-hook-form';
Expand Down Expand Up @@ -70,12 +70,11 @@ export function PaymentsForm({
const { tokenData, allTokens } = _.pick(data, ['tokenData', 'allTokens']);

const TOKENS = useMemo(
() => allTokens && getTokens(allTokens, chainId),
() => tokenData && _.values(tokenData[chainId]),
[chainId, allTokens],
);
const invoiceTokenData = localToken
? getTokenInfo(chainId, localToken, tokenData)
: undefined;
const invoiceTokenData = _.find(TOKENS, { address: localToken });
console.log(localToken, invoiceTokenData);

const buttonSize = useBreakpointValue({ base: 'sm', sm: 'md', md: 'lg' });

Expand All @@ -96,7 +95,7 @@ export function PaymentsForm({
});

useEffect(() => {
localSetValue('token', token || _.first(TOKENS));
localSetValue('token', token || _.first(TOKENS)?.address);

// eslint-disable-next-line react-hooks/exhaustive-deps
}, [TOKENS]);
Expand All @@ -105,6 +104,7 @@ export function PaymentsForm({
localMilestones,
(milestone: { value: string }) => _.toNumber(milestone.value) || 0,
);
console.log(TOKENS);

return (
<Stack as="form" onSubmit={handleSubmit(onSubmit)} spacing={4}>
Expand All @@ -117,11 +117,13 @@ export function PaymentsForm({
tooltip="This is the cryptocurrency you'll receive payment in. The network your wallet is connected to determines which tokens display here. (If you change your wallet network now, you'll be forced to start the invoice over)."
localForm={localForm}
>
{TOKENS?.map((t: string) => (
<option value={t} key={t}>
{getTokenInfo(chainId, t, tokenData).symbol}
</option>
))}
{TOKENS?.map(t => {
return (
<option value={t.address} key={t.address}>
{t.symbol}
</option>
);
})}
</Select>
</FormControl>
</Flex>
Expand Down
2 changes: 2 additions & 0 deletions packages/hooks/src/useInvoiceCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ interface UseInvoiceCreate {
endDate: number;
safetyValveDate: bigint;
resolver: Hex;
customResolver: Hex;
milestones: { value: number }[];
token: Hex;
toast: any;
Expand All @@ -39,6 +40,7 @@ export const useInvoiceCreate = ({
endDate,
safetyValveDate,
resolver,
customResolver,
milestones,
token,
toast,
Expand Down
2 changes: 2 additions & 0 deletions packages/hooks/src/useRegister.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { useChainId, useContractWrite, usePrepareContractWrite } from 'wagmi';
// import INVOICE_FACTORY_ABI from './contracts/InvoiceFactory.json';
// import useDetailsPin from './useDetailsPin';

// ! not used

const REQUIRES_VERIFICATION = true;

export const useRegister = ({
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/forms/DatePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export function DatePicker({
<Icon
as={InfoOutlineIcon}
boxSize={3}
color="red.500"
color="blue.500"
bg="white"
borderRadius="full"
/>
Expand Down

0 comments on commit bc91ae1

Please sign in to comment.