Subscription finally working!

This commit is contained in:
2025-06-13 13:36:13 -05:00
parent b80bf9cd3f
commit 9b69027a85
6 changed files with 107 additions and 8 deletions

View File

@ -0,0 +1,41 @@
'use client';
import * as React from 'react';
import { Progress } from '@/components/ui/progress';
import type * as ProgressPrimitive from '@radix-ui/react-progress';
type Loading_Props = React.ComponentProps<typeof ProgressPrimitive.Root> & {
/** how many ms between updates */
intervalMs?: number;
/** fraction of the remaining distance to add each tick */
alpha?: number;
};
export const Loading: React.FC<Loading_Props> = ({
intervalMs = 50,
alpha = 0.1,
className,
...props
}: Loading_Props) => {
const [progress, setProgress] = React.useState(0);
React.useEffect(() => {
const id = window.setInterval(() => {
setProgress((prev) => {
// compute the next progress
const next = prev + (100 - prev) * alpha;
// optional: round if you want neat numbers
return Math.min(100, Math.round(next * 10) / 10);
});
}, intervalMs);
return () => window.clearInterval(id);
}, [intervalMs, alpha]);
return (
<div className="items-center justify-center w-1/3 m-auto pt-20">
<Progress value={progress} className={className} {...props} />
</div>
);
};
export default Loading;