feat(user): Add 'gift_amount' field and update related references in user services and components

This commit is contained in:
web@ppanel 2025-01-08 23:25:13 +07:00
parent a4e9d5da59
commit b13c77e9b7
6 changed files with 16 additions and 10 deletions

View File

@ -192,6 +192,8 @@ declare namespace API {
referer_user: string;
refer_code: string;
balance: number;
commission: number;
gift_amount: number;
is_admin: boolean;
};
@ -989,6 +991,8 @@ declare namespace API {
password: string;
avatar: string;
balance: number;
commission: number;
gift_amount: number;
telegram: number;
refer_code: string;
referer_id: number;

View File

@ -29,14 +29,14 @@ import StripePayment from './stripe';
export default function Page() {
const t = useTranslations('order');
const { getUserInfo } = useGlobalStore();
const [order_no, setOrderNo] = useState<string>();
const [orderNo, setOrderNo] = useState<string>();
const [enabled, setEnabled] = useState<boolean>(false);
const { data } = useQuery({
enabled: enabled,
queryKey: ['queryOrderDetail', order_no],
queryKey: ['queryOrderDetail', orderNo],
queryFn: async () => {
const { data } = await queryOrderDetail({ order_no: order_no! });
const { data } = await queryOrderDetail({ order_no: orderNo! });
if (data?.data?.status !== 1) {
getUserInfo();
setEnabled(false);
@ -47,10 +47,10 @@ export default function Page() {
});
const { data: payment } = useQuery({
enabled: !!order_no && data?.status === 1,
queryKey: ['checkoutOrder', order_no],
enabled: !!orderNo && data?.status === 1,
queryKey: ['checkoutOrder', orderNo],
queryFn: async () => {
const { data } = await checkoutOrder({ orderNo: order_no! });
const { data } = await checkoutOrder({ orderNo: orderNo! });
return data?.data;
},
});

View File

@ -39,7 +39,7 @@ export function SidebarRight({ ...props }: React.ComponentProps<typeof Sidebar>)
<CardTitle className='text-sm font-medium'>{t('giftAmount')}</CardTitle>
</CardHeader>
<CardContent className='p-3 text-2xl font-bold'>
<Display type='currency' value={user?.deduction} />
<Display type='currency' value={user?.gift_amount} />
</CardContent>
</Card>
<Card>

View File

@ -16,7 +16,7 @@ export default function Page() {
const t = useTranslations('wallet');
const { user } = useGlobalStore();
const ref = useRef<ProListActions>(null);
const totalAssets = (user?.balance || 0) + (user?.commission || 0) + (user?.deduction || 0);
const totalAssets = (user?.balance || 0) + (user?.commission || 0) + (user?.gift_amount || 0);
return (
<>
<Card className='mb-4'>
@ -47,7 +47,7 @@ export default function Page() {
{t('giftAmount')}
</p>
<p className='text-secondary-foreground text-2xl font-bold'>
<Display type='currency' value={user?.deduction} />
<Display type='currency' value={user?.gift_amount} />
</p>
</div>
<div className='bg-secondary rounded-lg p-4 shadow-sm transition-all duration-300 hover:shadow-md'>

View File

@ -27,7 +27,7 @@ interface UnsubscribeProps {
export default function Unsubscribe({ id, allowDeduction }: Readonly<UnsubscribeProps>) {
const t = useTranslations('subscribe.unsubscribe');
const router = useRouter();
const { common } = useGlobalStore();
const { common, getUserInfo } = useGlobalStore();
const single_model = common.subscribe.single_model;
const [open, setOpen] = useState(false);
@ -51,6 +51,7 @@ export default function Unsubscribe({ id, allowDeduction }: Readonly<Unsubscribe
);
toast.success(t('success'));
router.refresh();
await getUserInfo();
setOpen(false);
} catch (error) {
toast.error(t('failed'));

View File

@ -611,6 +611,7 @@ declare namespace API {
balance: number;
commission: number;
deduction: number;
gift_amount: number;
telegram: number;
refer_code: string;
referer_id: number;