Skip to content

Commit e8fd249

Browse files
committed
aider: Add created date to PromptResult, create computed property sortedPromptResults, and add space between rows.
# Context: USER: add a created date to the PromptResult as a timestamp, create a computed property: sortedPromptResults, add some space between the rows ASSISTANT: To add a created date to the `PromptResult` as a timestamp, create a computed property `sortedPromptResults`, and add some space between the rows, you will need to modify the `App.vue` file. Here are the steps: 1. Update the `PromptResult` interface to include a `created` property. 2. Modify the `sendPrompt` method to add the current timestamp when a new prompt result is created. 3. Create a computed property `sortedPromptResults` that sorts the results by the created date. 4. Update the CSS to add space between the rows. Here are the changes you need to make: ```vue fe-clients/vue-ts/src/App.vue <<<<<<< ORIGINAL interface PromptResult { prompt: string; results: Record<string, any>[]; sql: string; } ======= import { computed } from "vue"; interface PromptResult { prompt: string; results: Record<string, any>[]; sql: string; created: number; // Timestamp for the created date } // Computed property to sort prompt results by created date const sortedPromptResults = computed(() => { return [...promptResults.value].sort((a, b) => b.created - a.created); }); >>>>>>> UPDATED ``` ```vue fe-clients/vue-ts/src/App.vue <<<<<<< ORIGINAL const data = await response.json(); data.results = JSON.parse(data.results); // Assuming 'results' is a JSON string that needs to be parsed promptResults.value.push(data); ======= const data: PromptResult = await response.json(); data.results = JSON.parse(data.results); // Assuming 'results' is a JSON string that needs to be parsed data.created = Date.now(); // Add the current timestamp promptResults.value.push(data); >>>>>>> UPDATED ``` ```vue fe-clients/vue-ts/src/App.vue <<<<<<< ORIGINAL <section v-for="(result, index) in promptResults" :key="index"> ======= <section v-for="(result, index) in sortedPromptResults" :key="index"> >>>>>>> UPDATED ``` And for the CSS to add space between the rows: ```vue fe-clients/vue-ts/src/App.vue <<<<<<< ORIGINAL section { display: flex; flex-direction: column; gap: 1em; padding: 1em; } ======= section { display: flex; flex-direction: column; gap: 1.5em; /* Increased gap for more space between rows */ padding: 1em; } >>>>>>> UPDATED ``` These changes will add a timestamp to each `PromptResult`, sort the results by the created date in descending order, and increase the space between the rows. If you have any further requests or need additional changes, please let me know!
1 parent d07fdec commit e8fd249

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

fe-clients/vue-ts/src/App.vue

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
@keyup.enter="sendPrompt"
2020
/>
2121

22-
<section v-for="(result, index) in promptResults" :key="index">
22+
<section v-for="(result, index) in sortedPromptResults" :key="index">
2323
<h3>{{ result.prompt }}</h3>
2424
<pre>{{ JSON.stringify(result.results, null, 2) }}</pre>
2525
<code>{{ result.sql }}</code>
@@ -30,12 +30,20 @@
3030
<script setup lang="ts">
3131
import { ref } from "vue";
3232
33+
import { computed } from "vue";
34+
3335
interface PromptResult {
3436
prompt: string;
3537
results: Record<string, any>[];
3638
sql: string;
39+
created: number; // Timestamp for the created date
3740
}
3841
42+
// Computed property to sort prompt results by created date
43+
const sortedPromptResults = computed(() => {
44+
return [...promptResults.value].sort((a, b) => b.created - a.created);
45+
});
46+
3947
const prompt = ref("");
4048
4149
// code: load this from local storage or default to empty list
@@ -54,8 +62,9 @@ const sendPrompt = async () => {
5462
body: JSON.stringify({ prompt: prompt.value }),
5563
});
5664
if (!response.ok) throw new Error("Network response was not ok");
57-
const data = await response.json();
65+
const data: PromptResult = await response.json();
5866
data.results = JSON.parse(data.results); // Assuming 'results' is a JSON string that needs to be parsed
67+
data.created = Date.now(); // Add the current timestamp
5968
promptResults.value.push(data);
6069
localStorage.setItem("promptResults", JSON.stringify(promptResults.value));
6170
// code: save this to local storage
@@ -94,7 +103,7 @@ pre {
94103
section {
95104
display: flex;
96105
flex-direction: column;
97-
gap: 1em;
106+
gap: 1.5em; /* Increased gap for more space between rows */
98107
padding: 1em;
99108
}
100109

0 commit comments

Comments
 (0)