problem: can't include text in merit request solution

This commit is contained in:
gsovereignty
2024-08-14 11:57:55 +08:00
parent af8084f402
commit d0b78cf7a6
4 changed files with 57 additions and 32 deletions

View File

@@ -12,11 +12,12 @@
import type NDKSvelte from '@nostr-dev-kit/ndk-svelte'; import type NDKSvelte from '@nostr-dev-kit/ndk-svelte';
import { Terminal } from 'lucide-svelte'; import { Terminal } from 'lucide-svelte';
import Todo from './Todo.svelte'; import Todo from './Todo.svelte';
import { isValidUrl } from '@/event_helpers/rockets'; import { isValidUrl, Rocket } from '@/event_helpers/rockets';
import CalculateSats from './CalculateSats.svelte'; import CalculateSats from './CalculateSats.svelte';
import { isGitHubUrl, parseProblem } from '@/helpers'; import { isGitHubUrl, parseProblem } from '@/helpers';
import Login from './Login.svelte';
export let rocketEvent: NDKEvent; export let rocket: Rocket;
let problem: string = ''; let problem: string = '';
let solution: string = ''; let solution: string = '';
@@ -78,17 +79,29 @@
e.created_at = Math.floor(new Date().getTime() / 1000); e.created_at = Math.floor(new Date().getTime() / 1000);
e.tags.push(['problem', 'text', problem]); e.tags.push(['problem', 'text', problem]);
if (solution.length > 0) { if (solution.length > 0) {
e.tags.push(['solution', 'url', solution]); try {
let url = new URL(solution);
e.tags.push(['solution', 'url', url.toString()]);
} catch {
e.tags.push(['solution', 'text', solution]);
}
} }
e.tags.push(['a', `31108:${rocketEvent.pubkey}:${rocketEvent.dTag}`]); e.tags.push(['a', `31108:${rocket.Event.pubkey}:${rocket.Event.dTag}`]);
e.tags.push(['merits', merits.toString(10)]); e.tags.push(['merits', merits.toString(10)]);
e.tags.push(['sats', sats]); e.tags.push(['sats', sats]);
console.log(e.rawEvent()); console.log(e.rawEvent());
e.publish().then((x) => { e.publish()
console.log(x); .then((x) => {
open = false; console.log(x);
//goto(`${base}/rockets/${getRocketURL(e)}`); console.log('todo: publish a kind 1 and tag the rocket and author');
}); open = false;
//goto(`${base}/rockets/${getRocketURL(e)}`);
})
.catch(() => {
alert(
"something went wrong, copy/paste your data and refresh then try again if you don't see your merit request in the rocket dashboard (we r so early, there will be blugs)"
);
});
} }
</script> </script>
@@ -140,7 +153,7 @@
<CalculateSats on:result={(event) => (sats = event.detail)} /> <CalculateSats on:result={(event) => (sats = event.detail)} />
</div> </div>
<div class="flex items-center space-x-2"> <!-- <div class="flex items-center space-x-2">
<Checkbox id="sell" bind:checked={wts} aria-labelledby="terms-label" /> <Checkbox id="sell" bind:checked={wts} aria-labelledby="terms-label" />
<Label <Label
id="terms-label" id="terms-label"
@@ -149,9 +162,9 @@
> >
I want Sats not Merits I want Sats not Merits
</Label> </Label>
</div> </div> -->
{#if wts} <!-- {#if wts}
Your Merits will be auctioned to potential sponsors as soon as it is approved, enabling you Your Merits will be auctioned to potential sponsors as soon as it is approved, enabling you
to be paid in Sats for your work. Tip: you don't have to decide right now, you can do this to be paid in Sats for your work. Tip: you don't have to decide right now, you can do this
at any time. at any time.
@@ -160,15 +173,19 @@
<Label for="sats" class="col-span-2 text-right">Auction Reserve Price (Sats)</Label> <Label for="sats" class="col-span-2 text-right">Auction Reserve Price (Sats)</Label>
<Input bind:value={minimum} id="price" placeholder="Reserve Price" class="col-span-1" /> <Input bind:value={minimum} id="price" placeholder="Reserve Price" class="col-span-1" />
</div> </div>
{/if} {/if} -->
</div> </div>
<Dialog.Footer> <Dialog.Footer>
<Button {#if $currentUser}
on:click={() => { <Button
publish($ndk); on:click={() => {
}} publish($ndk);
type="submit">Publish</Button }}
> type="submit">Publish</Button
>
{:else}
<Login />
{/if}
</Dialog.Footer> </Dialog.Footer>
<Todo <Todo
text={['remove white border on focus so that the validation indication color can be seen']} text={['remove white border on focus so that the validation indication color can be seen']}

View File

@@ -12,6 +12,7 @@
import { Avatar, Name } from '@nostr-dev-kit/ndk-svelte-components'; import { Avatar, Name } from '@nostr-dev-kit/ndk-svelte-components';
import { onDestroy } from 'svelte'; import { onDestroy } from 'svelte';
import { derived, writable } from 'svelte/store'; import { derived, writable } from 'svelte/store';
import CreateMeritRequest from './CreateMeritRequest.svelte';
//export let rocket: NDKEvent; //export let rocket: NDKEvent;
export let rocket: Rocket; // = new Rocket(rocket); export let rocket: Rocket; // = new Rocket(rocket);
@@ -33,7 +34,7 @@
_votes?.unsubscribe(); _votes?.unsubscribe();
}); });
let truncate = writable(true) let truncate = writable(true);
let merits = derived(_merits, ($merits) => { let merits = derived(_merits, ($merits) => {
let map = new Map<string, MeritRequest>(); let map = new Map<string, MeritRequest>();
@@ -96,6 +97,7 @@
<Card.Description>Merit Requests</Card.Description> <Card.Description>Merit Requests</Card.Description>
</Card.Header> </Card.Header>
<Card.Content> <Card.Content>
<CreateMeritRequest {rocket} />
<Table.Root> <Table.Root>
<Table.Header> <Table.Header>
<Table.Row> <Table.Row>
@@ -138,13 +140,12 @@
<Table.Cell class="hidden text-right md:table-cell" <Table.Cell class="hidden text-right md:table-cell"
>{unixToRelativeTime(merit.TimeStamp * 1000)}</Table.Cell >{unixToRelativeTime(merit.TimeStamp * 1000)}</Table.Cell
> >
</Table.Row> </Table.Row>
{/each} {/each}
{#if $merits.size > $meritsTruncated.length} {#if $merits.size > $meritsTruncated.length}
<span <span
on:click={() => { on:click={() => {
truncate.set(false) truncate.set(false);
}} }}
class="m-2 flex w-48 flex-nowrap text-lg" class="m-2 flex w-48 flex-nowrap text-lg"
><Badge href="#">View {$merits.size - $meritsTruncated.length} more</Badge></span ><Badge href="#">View {$merits.size - $meritsTruncated.length} more</Badge></span

View File

@@ -26,7 +26,7 @@
let result: VoteDirection | undefined; let result: VoteDirection | undefined;
export let parsedRocket:Rocket; export let parsedRocket: Rocket;
let _votes = $ndk.storeSubscribe( let _votes = $ndk.storeSubscribe(
{ '#a': [RocketATagFilter(parsedRocket.Event)], '#e': [merit.ID], kinds: [1410 as NDKKind] }, { '#a': [RocketATagFilter(parsedRocket.Event)], '#e': [merit.ID], kinds: [1410 as NDKKind] },
@@ -52,7 +52,7 @@
} }
$: referenceTime = cuckPrice $: referenceTime = cuckPrice
? formatReferenceTime(((merit.Sats / 100000000) * cuckPrice) / 70) ? formatReferenceTime(((merit.Sats / 100000000) * cuckPrice) / 50)
: '...'; : '...';
let votes = derived(_votes, ($_votes) => { let votes = derived(_votes, ($_votes) => {
@@ -158,8 +158,14 @@
<div class="grid gap-3"> <div class="grid gap-3">
<div class="font-semibold">Analysis</div> <div class="font-semibold">Analysis</div>
<span class="grid gap-0.5 not-italic text-muted-foreground"> <span class="grid gap-0.5 not-italic text-muted-foreground">
A competent freelance developer earns $70 CuckLoserBucks an hour (on average). Using <p class="m-1 text-justify">
this rate, the contributor is claiming to have spent about {referenceTime} working on this. To make it easier to compare the value of each contribution we normalize the hourly
rate to $50 CuckLoserBucks an hour.
</p>
<p class="m-1 text-justify">
At this rate, the contributor is claiming to have worked for {referenceTime} solving
this problem.
</p>
</span> </span>
</div> </div>
<div class="grid auto-rows-max gap-3"> <div class="grid auto-rows-max gap-3">
@@ -170,8 +176,8 @@
<Separator class="my-4" /> <Separator class="my-4" />
<div class="font-semibold">Votes</div> <div class="font-semibold">Votes</div>
{#if $votes.size == 0}<Alert {#if $votes.size == 0}<Alert
><Info />Waiting for existing <span class="italic">{parsedRocket.Name()}</span> Merit ><Info />Waiting for existing <span class="italic">{parsedRocket.Name()}</span> Merit holders
holders to vote</Alert to vote</Alert
> >
{/if} {/if}
<Table.Root> <Table.Root>
@@ -221,6 +227,9 @@
{:else if !result} {:else if !result}
<VoteOnMeritRequest {merit} rocket={parsedRocket} /> <VoteOnMeritRequest {merit} rocket={parsedRocket} />
{/if} {/if}
<a href="#" class="text-xs" on:click={() => console.log(merit.Event.rawEvent())}
>print to console</a
>
</Card.Footer> </Card.Footer>
</Card.Root> </Card.Root>

View File

@@ -2,8 +2,9 @@
import * as Breadcrumb from '$lib/components/ui/breadcrumb/index.js'; import * as Breadcrumb from '$lib/components/ui/breadcrumb/index.js';
import Button from '@/components/ui/button/button.svelte'; import Button from '@/components/ui/button/button.svelte';
import * as Card from '@/components/ui/card'; import * as Card from '@/components/ui/card';
import { Rocket } from '@/event_helpers/rockets';
import type { NDKEvent } from '@nostr-dev-kit/ndk'; import type { NDKEvent } from '@nostr-dev-kit/ndk';
import CreateMeritRequest from './CreateMeritRequest.svelte'; import BitcoinAssociations from './AssociatedBitcoinAddresses.svelte';
import CreateNewProduct from './CreateNewProduct.svelte'; import CreateNewProduct from './CreateNewProduct.svelte';
import MeritRequests from './MeritRequests.svelte'; import MeritRequests from './MeritRequests.svelte';
import MeritsAndSatflow from './MeritsAndSatflow.svelte'; import MeritsAndSatflow from './MeritsAndSatflow.svelte';
@@ -11,8 +12,6 @@
import ProposedProducts from './ProposedProducts.svelte'; import ProposedProducts from './ProposedProducts.svelte';
import Todo from './Todo.svelte'; import Todo from './Todo.svelte';
import UpdateMission from './UpdateMission.svelte'; import UpdateMission from './UpdateMission.svelte';
import { Rocket } from '@/event_helpers/rockets';
import BitcoinAssociations from './AssociatedBitcoinAddresses.svelte';
export let rocket: NDKEvent; export let rocket: NDKEvent;
@@ -50,7 +49,6 @@
<Card.Description class="flex space-x-4"> <Card.Description class="flex space-x-4">
<UpdateMission rocketEvent={rocket} /> <UpdateMission rocketEvent={rocket} />
<CreateNewProduct rocketEvent={rocket} /> <CreateNewProduct rocketEvent={rocket} />
<CreateMeritRequest rocketEvent={rocket} />
<Button <Button
on:click={() => { on:click={() => {
console.log(rocket.rawEvent()); console.log(rocket.rawEvent());