Skip to content

Commit

Permalink
Update farm reload after farm creation (#3544)
Browse files Browse the repository at this point in the history
* re-add event emit

* add event watcher and prop updater
  • Loading branch information
amiraabouhadid authored Oct 22, 2024
1 parent 1b54bd9 commit a516b1b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
3 changes: 2 additions & 1 deletion packages/playground/src/dashboard/components/create_farm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ import { createCustomToast, ToastType } from "../../utils/custom_toast";
export default {
name: "CreateFarm",
setup() {
setup(_, context) {
const showDialogue = ref(false);
const isCreating = ref(false);
const gridStore = useGrid();
Expand All @@ -73,6 +73,7 @@ export default {
createCustomToast("Farm created successfully.", ToastType.success);
showDialogue.value = false;
farmName.value = "";
context.emit("farm-created");
notifyDelaying();
} catch (error) {
console.log(error);
Expand Down
19 changes: 15 additions & 4 deletions packages/playground/src/dashboard/farms_view.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
<v-card-title class="pa-0">Farms</v-card-title>
</v-card>

<CreateFarm class="mt-4" @farm-created="farmsReload = true" />
<UserFarms ref="userFarms" :reloadFarms="farmsReload" />
<CreateFarm class="mt-4" @farm-created="handleFarmCreated" />
<UserFarms :ref="el => (userFarms = el)" :reloadFarms="farmsReload" />
<UserNodes />
</div>
</template>

<script lang="ts">
import { ref } from "vue";
import { ref, watch } from "vue";
import CreateFarm from "./components/create_farm.vue";
import UserFarms from "./components/user_farms.vue";
Expand All @@ -26,9 +26,20 @@ export default {
},
setup() {
const farmsReload = ref<boolean>(false);
const userFarms = ref();
function handleFarmCreated() {
farmsReload.value = !farmsReload.value;
}
watch(
() => farmsReload.value,
() => {
userFarms.value.reloadFarms = farmsReload.value;
},
);
return {
farmsReload,
handleFarmCreated,
userFarms,
};
},
};
Expand Down

0 comments on commit a516b1b

Please sign in to comment.