-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Urban Vidovič <[email protected]>
- Loading branch information
Showing
31 changed files
with
313 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@blockchain-lab-um/dapp": patch | ||
--- | ||
|
||
Adds reclaim option for campaigns. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { type NextRequest, NextResponse } from 'next/server'; | ||
import jwt from 'jsonwebtoken'; | ||
import { supabaseServiceRoleClient } from '@/utils/supabase/supabaseServiceRoleClient'; | ||
import { supabaseClient } from '@/utils/supabase/supabaseClient'; | ||
|
||
const CORS_HEADERS = { | ||
'Access-Control-Allow-Origin': '*', | ||
'Access-Control-Allow-Methods': 'GET, OPTIONS', | ||
'Access-Control-Allow-Headers': 'Content-Type', | ||
}; | ||
|
||
export const dynamic = 'force-dynamic'; | ||
|
||
export async function GET(request: NextRequest) { | ||
const token = request.headers.get('Authorization')?.replace('Bearer ', ''); | ||
if (!token) { | ||
return new NextResponse('Unauthorized', { | ||
status: 401, | ||
headers: { | ||
...CORS_HEADERS, | ||
}, | ||
}); | ||
} | ||
const user = jwt.verify(token, process.env.SUPABASE_JWT_SECRET!) as { | ||
sub: string; | ||
address: string; | ||
aud: string; | ||
role: string; | ||
iat: number; | ||
exp: number; | ||
}; | ||
|
||
const supabase = supabaseServiceRoleClient(); | ||
const { data: userId } = await supabase | ||
.from('users') | ||
.select('id') | ||
.eq('address', user.address.toLowerCase()) | ||
.single(); | ||
if (!userId) { | ||
return NextResponse.json({ claims: [] }, { headers: { ...CORS_HEADERS } }); | ||
} | ||
const { data: claims, error } = await supabase | ||
.from('claims') | ||
.select('*') | ||
.eq('user_id', userId.id); | ||
|
||
if (error) { | ||
console.error('Error getting claims', error); | ||
return new NextResponse('Error getting claims', { | ||
status: 500, | ||
headers: { | ||
...CORS_HEADERS, | ||
}, | ||
}); | ||
} | ||
|
||
return NextResponse.json({ claims }, { headers: { ...CORS_HEADERS } }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
packages/dapp/src/components/CampaignsDisplay/RewardDisplay.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Chip } from '@nextui-org/react'; | ||
|
||
type RequirementProps = { | ||
reward: string; | ||
}; | ||
|
||
export const RewardDisplay = ({ reward }: RequirementProps) => { | ||
return ( | ||
<div className="mt-8 flex w-full justify-between"> | ||
<Chip> | ||
<h2 className="font-ubuntu dark:text-navy-blue-50 flex items-center gap-x-2 text-lg font-medium leading-6 text-gray-800"> | ||
{reward} | ||
</h2> | ||
</Chip> | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.