Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { useRecordContext } from "react-admin";

export const HidePoweredByField = ({
source,
label,
showLabel,
}: {
source: string;
label?: string;
showLabel?: boolean;
}) => {
const record = useRecordContext();
const hideKitField = JSON.parse(record?.config).hide_powered_by;

return (
<>
{label && showLabel && <span> Hide Powered by</span>}
<span style={{ color: hideKitField ? "green" : "red" }}>
{hideKitField ? "true" : "false"}
</span>
</>
);
};
26 changes: 26 additions & 0 deletions apps/dexappadmin/src/modules/admin/components/HolderTextField.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { useHoldDexkitQuery } from "@dexkit/ui/hooks/account";
import { useRecordContext } from "react-admin";

export const HolderTextField = ({
source,
label,
showLabel,
}: {
source: string;
label?: string;
showLabel?: boolean;
}) => {
const record = useRecordContext();
const holdDexKitQuery = useHoldDexkitQuery({
account: record?.owner,
});

return (
<>
{label && showLabel && <span> KIT holder </span>}
<span style={{ color: holdDexKitQuery.data ? "green" : "red" }}>
{holdDexKitQuery.data ? "true" : "false"}
</span>
</>
);
};
64 changes: 62 additions & 2 deletions apps/dexappadmin/src/modules/admin/dashboard/edits/site.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,66 @@
import {
BooleanInput,
Button,
Edit,
NumberInput,
SimpleForm,
TextInput,
} from 'react-admin';
TopToolbar,
useNotify,
useRecordContext,
} from "react-admin";
import { HidePoweredByField } from "../../components/HidePoweredByField";
import { HolderTextField } from "../../components/HolderTextField";
import {
useDisableDexKitSignature,
useRemoveDomainMutation,
} from "../../hooks/payment";

const SiteActions = () => {
const record = useRecordContext();
const removeCustomDomainMutation = useRemoveDomainMutation();
const removeSignatureMutation = useDisableDexKitSignature();
const notify = useNotify();

function handleRemoveCustomDomain() {
try {
removeCustomDomainMutation.mutateAsync({ siteId: Number(record?.id) });
notify("Domain removed", { type: "success" });
} catch {
notify("Failed to remove domain", { type: "warning" });
}
}

function handleRemoveSignature() {
try {
removeSignatureMutation.mutateAsync({ siteId: Number(record?.id) });
notify("hide signature removed", { type: "success" });
} catch {
notify("Failed to remove show signature", { type: "warning" });
}
}

return (
<TopToolbar>
<Button
color="error"
variant="contained"
onClick={handleRemoveCustomDomain}
>
<>Remove Custom Domain</>
</Button>
<Button color="error" variant="contained" onClick={handleRemoveSignature}>
<>Disable Signature</>
</Button>
</TopToolbar>
);
};

export const SiteEdit = () => (
<Edit>
<Edit actions={<SiteActions />}>
<SimpleForm>
<TextInput source="slug" disabled />
<TextInput source="owner" disabled />
{/* <TextInput source="id" />
<DateInput source="createdAt" />
<DateInput source="updatedAt" />
Expand All @@ -29,6 +80,15 @@ export const SiteEdit = () => (
<TextInput source="previewUrl" />*/}
<NumberInput source="featuredScore" />
<BooleanInput source="isTemplate" />
<HidePoweredByField
source="config"
label="HidePoweredBy"
showLabel={true}
/>
<HolderTextField source="owner" label="HoldKit" showLabel={true} />
{/* <TextInput source="signature" />
{/* <TextInput source="config" />*/}
{/* <TextInput source="domainSetupResponse" />
{/* <NumberInput source="nftId" />*/}
</SimpleForm>
</Edit>
Expand Down
8 changes: 6 additions & 2 deletions apps/dexappadmin/src/modules/admin/dashboard/lists/site.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Datagrid, DateField, List, TextField } from 'react-admin';
import { SiteFilterSidebar } from '../filters/siteFilterSidebar';
import { Datagrid, DateField, List, TextField } from "react-admin";
import { HidePoweredByField } from "../../components/HidePoweredByField";
import { HolderTextField } from "../../components/HolderTextField";
import { SiteFilterSidebar } from "../filters/siteFilterSidebar";

export const SiteList = () => (
<List aside={<SiteFilterSidebar />}>
Expand All @@ -13,6 +15,8 @@ export const SiteList = () => (
<TextField source="domain" />
<TextField source="domainStatus" />
<TextField source="email" />
<HolderTextField source="owner" label={"HoldKit"} />
<HidePoweredByField source="config" label={"HidePoweredBy"} />
{/* <TextField source="config" />*/}
<TextField source="domainSetupResponse" />
<TextField source="verifyDomainRawData" />
Expand Down
13 changes: 11 additions & 2 deletions apps/dexappadmin/src/modules/admin/hooks/payment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,21 @@ import { myAppsApi } from "../dashboard/dataProvider"



export function useRemoveDomainMutation(){
export function useRemoveDomainMutation() {


return useMutation(({siteId}: {siteId: number})=> {
return useMutation(({ siteId }: { siteId: number }) => {

return myAppsApi.get(`/premium-appbuilder/admin/remove-domain/${siteId}`)

})
}

export function useDisableDexKitSignature() {


return useMutation(({ siteId }: { siteId: number }) => {
return myAppsApi.get(`/premium-appbuilder/admin/remove-signature/${siteId}`)

})
}
18 changes: 18 additions & 0 deletions packages/dexkit-ui/hooks/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,24 @@ export function useAccountHoldDexkitQuery() {
}


const minHolding = MIN_KIT_HOLDING_AI_GENERATION;
const hasKit = await getKitBalanceOfThreshold(account, minHolding)
return hasKit > 0;
})
}


export function useHoldDexkitQuery({ account }: { account?: string }) {

return useQuery([account], async () => {
if (!account) {
return;
}
if (WHITELISTED_AI_ACCOUNTS.map(a => a.toLowerCase()).includes(account.toLowerCase())) {
return true;
}


const minHolding = MIN_KIT_HOLDING_AI_GENERATION;
const hasKit = await getKitBalanceOfThreshold(account, minHolding)
return hasKit > 0;
Expand Down