Skip to content

Commit

Permalink
Merge pull request #291 from AmbireTech/misc-bug-fixes
Browse files Browse the repository at this point in the history
Misc bug fixes
  • Loading branch information
ivopaunov authored Sep 13, 2024
2 parents 55a84f4 + b7262bb commit 710e164
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 140 deletions.
30 changes: 9 additions & 21 deletions src/components/AdminPanel/AccountDetails.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect, useMemo } from 'react'
import { SimpleGrid, Box, Title, Paper, Loader, Center } from '@mantine/core'
import { SimpleGrid, Box, Loader, Center, Fieldset } from '@mantine/core'
import useAdmin from 'hooks/useAdmin'
import { useParams } from 'react-router-dom'
import Dashboard from 'components/Dashboard'
Expand Down Expand Up @@ -39,34 +39,22 @@ function AccountDetails() {
// { maxWidth: 'md', cols: 1, spacing: 'xl' }
// ]}
>
<Paper p="sm" withBorder>
<Title order={5} c="brand">
Account info form
</Title>
<Fieldset legend="Account info form">
<AccountInfo accountData={accountData} />
</Paper>
<Paper p="sm" withBorder>
<Title order={5} c="brand">
Deposit form
</Title>
</Fieldset>
<Fieldset legend="Deposit form">
<AdminDeposit accountData={accountData} />
</Paper>
</Fieldset>
</SimpleGrid>
<SimpleGrid spacing="xl" mt="xl">
<Paper p="sm" withBorder>
<Title order={5} c="brand">
Activity
</Title>
<Fieldset legend="Activity">
<FundsActivity accountData={accountData} />
</Paper>
</Fieldset>
</SimpleGrid>
<SimpleGrid spacing="xl" mt="xl">
<Paper p="sm" withBorder>
<Title order={5} c="brand">
Campaigns
</Title>
<Fieldset legend="Campaigns">
<Dashboard isAdminPanel accountId={accountId} />
</Paper>
</Fieldset>
</SimpleGrid>
</Box>
)
Expand Down
137 changes: 82 additions & 55 deletions src/components/AdminPanel/AccoutInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
import { useMemo, useCallback, useState } from 'react'
import { hasLength, matches, useForm, isEmail } from '@mantine/form'

import { Button, Group, TextInput, Box, NumberInput, Text, Textarea, Switch } from '@mantine/core'
import {
Button,
Group,
TextInput,
Box,
NumberInput,
Text,
Textarea,
Switch,
Stack
} from '@mantine/core'
import throttle from 'lodash.throttle'

import { Account } from 'types'
Expand Down Expand Up @@ -74,76 +84,93 @@ function AccountInfo({ accountData }: { accountData: Account }) {
disabled
{...form.getInputProps('availableBalance')}
/>
<Text size="sm" fw={500} mt="xl">
Billing details
</Text>
<Text size="xs">* Just for info, users can edit, admins can verify only</Text>
<Group mt="md" justify="left" align="baseline">
<TextInput
label="First name"
disabled
{...form.getInputProps('billingDetails.firstName')}
/>
<TextInput label="Last name" disabled {...form.getInputProps('billingDetails.lastName')} />
<TextInput
label="Company number"
disabled
{...form.getInputProps('billingDetails.companyNumber')}
/>
<TextInput
label="VAT number"
disabled
{...form.getInputProps('billingDetails.companyNumberPrim')}
/>
<TextInput
label="Company address"
disabled
{...form.getInputProps('billingDetails.companyAddress')}
/>
<TextInput
label="Company country"
disabled
{...form.getInputProps('billingDetails.companyCountry')}
/>

<Stack gap="xs">
<Text size="sm" fw={500} mt="xl">
Billing details
</Text>
<Text size="xs">* Just for info, users can edit, admins can verify only</Text>
<TextInput
label="Company city"
label="Company name"
disabled
{...form.getInputProps('billingDetails.companyCity')}
/>
<TextInput
label="Company ZIP code"
disabled
{...form.getInputProps('billingDetails.companyZipCode')}
{...form.getInputProps('billingDetails.companyName')}
/>
<Group justify="left" align="baseline" grow>
<TextInput
label="First name"
disabled
{...form.getInputProps('billingDetails.firstName')}
/>
<TextInput
label="Last name"
disabled
{...form.getInputProps('billingDetails.lastName')}
/>
</Group>
<Group justify="left" align="baseline" grow>
<TextInput
label="Company number"
disabled
{...form.getInputProps('billingDetails.companyNumber')}
/>
<TextInput
label="VAT number"
disabled
{...form.getInputProps('billingDetails.companyNumberPrim')}
/>
</Group>
<Group justify="left" align="baseline" grow>
<TextInput
label="Company address"
disabled
{...form.getInputProps('billingDetails.companyAddress')}
/>
<TextInput
label="Company country"
disabled
{...form.getInputProps('billingDetails.companyCountry')}
/>
</Group>
<Group justify="left" align="baseline" grow>
<TextInput
label="Company city"
disabled
{...form.getInputProps('billingDetails.companyCity')}
/>
<TextInput
label="Company ZIP code"
disabled
{...form.getInputProps('billingDetails.companyZipCode')}
/>
</Group>
<Switch
label="Verified by admin"
{...form.getInputProps('billingDetails.verified', { type: 'checkbox' })}
/>
</Group>

<Text size="sm" fw={500} mt="xl">
Additional info
</Text>
<Text size="xs">* can be seen and edited only by admins</Text>

<Group mt="md" justify="left" align="baseline">
<TextInput label="Contact email" {...form.getInputProps('info.email')} />
<TextInput label="Contact phone" {...form.getInputProps('info.phone')} />
</Stack>
<Stack gap="xs">
<Text size="sm" fw={500} mt="xl">
Additional info
</Text>
<Text size="xs">* can be seen and edited only by admins</Text>
<TextInput label="Contact person" {...form.getInputProps('info.contactPerson')} />
<Group justify="left" grow>
<TextInput label="Contact email" {...form.getInputProps('info.email')} />
<TextInput label="Contact phone" {...form.getInputProps('info.phone')} />
</Group>
<Textarea
label="Additional notes"
w="100%"
rows={7}
{...form.getInputProps('info.notes')}
/>
</Group>

<Group justify="left" mt="md">
<Button type="submit" loading={loading} disabled={loading || !form.isDirty()}>
Update account data
</Button>
</Group>
<Group justify="left" mt="md">
<Button type="submit" loading={loading} disabled={loading || !form.isDirty()}>
Update account data
</Button>
</Group>
</Stack>
</Box>
)
}
Expand Down
123 changes: 64 additions & 59 deletions src/components/AdminPanel/AdminDeposit.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { isInRange, hasLength, matches, useForm } from '@mantine/form'
import { useCallback, useMemo, useState, FormEvent } from 'react'
import { Button, Group, TextInput, Box, NumberInput } from '@mantine/core'
import { Button, Group, TextInput, Box, NumberInput, Stack } from '@mantine/core'
import { defaultConfirmModalProps } from 'components/common/Modals/CustomConfirmModal'
import { modals } from '@mantine/modals'
import useAdmin from 'hooks/useAdmin'
Expand Down Expand Up @@ -94,69 +94,74 @@ function AdminDeposit({ accountData }: { accountData: Account }) {

return (
<Box component="form">
<TextInput
label="Account address"
placeholder="0x000"
withAsterisk
{...form.getInputProps('accountId')}
disabled
/>
<Group mt="sm" justify="left" align="baseline">
<NumberInput
mt="sm"
label="Amount"
// type="number"
placeholder="Amount"
hideControls
min={0}
{...form.getInputProps('amount')}
/>
<TextInput
label="Token name"
placeholder="Token name"
withAsterisk
disabled
{...form.getInputProps('token.name')}
/>
<Stack gap="xs">
<TextInput
label="Token addr"
placeholder="Token addr"
label="Account address"
placeholder="0x000"
withAsterisk
{...form.getInputProps('accountId')}
disabled
{...form.getInputProps('token.address')}
/>
<TextInput
label="Token chain id"
placeholder="Token chain id"
withAsterisk
disabled
{...form.getInputProps('token.chainId')}
/>
<NumberInput
label="Token decimals"
placeholder="token decimals"
withAsterisk
disabled
{...form.getInputProps('token.decimals')}
/>
<TextInput
label="Tx hash"
placeholder="0x0000000000000000000000000000000000000000000000000000000000000000"
withAsterisk
{...form.getInputProps('txHash')}
/>
</Group>
<Group grow align="baseline">
<NumberInput
label="Amount"
// type="number"
placeholder="Amount"
hideControls
min={0}
{...form.getInputProps('amount')}
/>
<TextInput
label="Token name"
placeholder="Token name"
withAsterisk
disabled
{...form.getInputProps('token.name')}
/>
</Group>
<Group grow align="baseline">
<TextInput
label="Token addr"
placeholder="Token addr"
withAsterisk
disabled
{...form.getInputProps('token.address')}
/>
<TextInput
label="Token chain id"
placeholder="Token chain id"
withAsterisk
disabled
{...form.getInputProps('token.chainId')}
/>
</Group>
<Group grow align="baseline">
<NumberInput
label="Token decimals"
placeholder="token decimals"
withAsterisk
disabled
{...form.getInputProps('token.decimals')}
/>
<TextInput
label="Tx hash"
placeholder="0x0000000000000000000000000000000000000000000000000000000000000000"
withAsterisk
{...form.getInputProps('txHash')}
/>
</Group>

<Group justify="left" mt="md">
<Button
type="submit"
loading={loading}
disabled={loading || !form.isDirty()}
onClick={onSubmit}
>
Make deposit
</Button>
</Group>
<Group justify="left" mt="md">
<Button
type="submit"
loading={loading}
disabled={loading || !form.isDirty()}
onClick={onSubmit}
>
Make deposit
</Button>
</Group>
</Stack>
</Box>
)
}
Expand Down
13 changes: 8 additions & 5 deletions src/components/common/CustomTable/CustomTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ export const CustomTable = ({
}, [list, actions, isMobile, columns, selectedElements, selectedElements.size, headings])

return (
<Stack align="stretch" w="100%" pos="relative">
<Stack align="stretch" w="100%" pos="relative" gap="sm">
<LoadingOverlay visible={loading} />
{error && (
<Alert
Expand All @@ -312,10 +312,13 @@ export const CustomTable = ({
{!error && !loading && !rows.length && (
<Alert variant="outline" color="info" title="No data found" />
)}
<Group align="center" justify={selectedElements.size ? 'space-between' : 'right'}>
{selectedElements.size && masterActionMenu}
{tableActions}
</Group>

{((!!selectedElements.size && !!masterActionMenu) || tableActions) && (
<Group align="center" justify={selectedElements.size ? 'space-between' : 'right'}>
{selectedElements.size && masterActionMenu}
{tableActions}
</Group>
)}

{isMobile ? (
<Stack gap="xl">
Expand Down

0 comments on commit 710e164

Please sign in to comment.