Skip to content

Commit

Permalink
Rewards
Browse files Browse the repository at this point in the history
  • Loading branch information
csansoon committed Sep 26, 2024
1 parent 947f40e commit 224054e
Show file tree
Hide file tree
Showing 13 changed files with 2,701 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use client'

export function RewardsMenu() {
return (
<div className="w-[200px] h[500px] bg-blue-500 rounded-md">
</div>
)
}
22 changes: 22 additions & 0 deletions apps/web/src/components/layouts/AppLayout/Header/Rewards/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Button } from '@latitude-data/web-ui'
import Popover from 'node_modules/@latitude-data/web-ui/src/ds/atoms/Popover'

import { RewardsMenu } from './Menu'

export function RewardsButton() {
return (
<Popover.Root>
<Popover.Trigger asChild>
<Button size='small' >Rewards</Button>
</Popover.Trigger>
<Popover.Content
side='bottom'
sideOffset={8}
align='center'
className='bg-background rounded-md w-80 p-4 shadow-lg border border-border'
>
<RewardsMenu />
</Popover.Content>
</Popover.Root>
)
}
2 changes: 2 additions & 0 deletions apps/web/src/components/layouts/AppLayout/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Fragment } from 'react/jsx-runtime'

import AvatarDropdown from './AvatarDropdown'
import { UsageIndicator } from './UsageIndicator'
import { RewardsButton } from './Rewards'

function BreadcrumbSeparator() {
return (
Expand Down Expand Up @@ -112,6 +113,7 @@ export default function AppHeader({
<Breadcrumb showLogo breadcrumbs={breadcrumbs} />
<div className='flex flex-row items-center gap-x-6'>
<nav className='flex flex-row gap-x-4 items-center'>
<RewardsButton />
<UsageIndicator />
{navigationLinks.map((link, idx) => (
<NavLink key={idx} {...link} />
Expand Down
32 changes: 32 additions & 0 deletions packages/core/drizzle/0060_lumpy_tenebrous.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
DO $$ BEGIN
CREATE TYPE "latitude"."reward_types" AS ENUM('github_star', 'follow', 'post', 'invite', 'referral');
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "latitude"."claimed_rewards" (
"id" bigserial PRIMARY KEY NOT NULL,
"workspace_id" bigint NOT NULL,
"creator_id" text,
"reward_type" "latitude"."reward_types" NOT NULL,
"reference" text NOT NULL,
"value" bigint NOT NULL,
"accepted" boolean,
"created_at" timestamp DEFAULT now() NOT NULL,
"updated_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "latitude"."claimed_rewards" ADD CONSTRAINT "claimed_rewards_workspace_id_workspaces_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "latitude"."workspaces"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "latitude"."claimed_rewards" ADD CONSTRAINT "claimed_rewards_creator_id_users_id_fk" FOREIGN KEY ("creator_id") REFERENCES "latitude"."users"("id") ON DELETE set null ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "claimed_rewards_workspace_id_idx" ON "latitude"."claimed_rewards" USING btree ("workspace_id");--> statement-breakpoint
CREATE UNIQUE INDEX IF NOT EXISTS "workspace_id_reward_type_unique" ON "latitude"."claimed_rewards" USING btree ("workspace_id","reward_type");
Loading

0 comments on commit 224054e

Please sign in to comment.