You've already forked AstralRinth
forked from didirus/AstralRinth
feat: introduce dependency injection framework (#4091)
* feat: migrate frontend notifications to dependency injection based notificaton manager * fix: lint * fix: issues * fix: compile error + notif binding issue * refactor: move org context to new DI setup * feat: migrate app notifications to DI + frontend styling * fix: sidebar issues * fix: dont use delete in computed * fix: import and prop issue * refactor: move handleError to main notification manager class * fix: lint & build * fix: merge issues * fix: lint issues * fix: lint issues --------- Signed-off-by: IMB11 <hendersoncal117@gmail.com> Signed-off-by: Cal H. <hendersoncal117@gmail.com>
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
maxlength="64"
|
||||
:placeholder="`Enter organization name...`"
|
||||
autocomplete="off"
|
||||
@input="updateSlug()"
|
||||
@input="updateSlug"
|
||||
/>
|
||||
</div>
|
||||
<div class="flex flex-col gap-2">
|
||||
@@ -33,7 +33,7 @@
|
||||
type="text"
|
||||
maxlength="64"
|
||||
autocomplete="off"
|
||||
@input="manualSlug = true"
|
||||
@input="setManualSlug"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -61,7 +61,7 @@
|
||||
</button>
|
||||
</ButtonStyled>
|
||||
<ButtonStyled>
|
||||
<button @click="modal.hide()">
|
||||
<button @click="hide">
|
||||
<XIcon aria-hidden="true" />
|
||||
Cancel
|
||||
</button>
|
||||
@@ -70,20 +70,22 @@
|
||||
</div>
|
||||
</NewModal>
|
||||
</template>
|
||||
<script setup>
|
||||
import { XIcon, PlusIcon } from "@modrinth/assets";
|
||||
import { ButtonStyled, NewModal } from "@modrinth/ui";
|
||||
|
||||
<script setup lang="ts">
|
||||
import { PlusIcon, XIcon } from "@modrinth/assets";
|
||||
import { ButtonStyled, NewModal, injectNotificationManager } from "@modrinth/ui";
|
||||
import { ref } from "vue";
|
||||
|
||||
const router = useNativeRouter();
|
||||
const { addNotification } = injectNotificationManager();
|
||||
|
||||
const name = ref("");
|
||||
const slug = ref("");
|
||||
const description = ref("");
|
||||
const manualSlug = ref(false);
|
||||
const name = ref<string>("");
|
||||
const slug = ref<string>("");
|
||||
const description = ref<string>("");
|
||||
const manualSlug = ref<boolean>(false);
|
||||
const modal = ref<InstanceType<typeof NewModal>>();
|
||||
|
||||
const modal = ref();
|
||||
|
||||
async function createOrganization() {
|
||||
async function createOrganization(): Promise<void> {
|
||||
startLoading();
|
||||
try {
|
||||
const value = {
|
||||
@@ -92,19 +94,18 @@ async function createOrganization() {
|
||||
slug: slug.value.trim().replace(/ +/g, ""),
|
||||
};
|
||||
|
||||
const result = await useBaseFetch("organization", {
|
||||
const result: any = await useBaseFetch("organization", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(value),
|
||||
apiVersion: 3,
|
||||
});
|
||||
|
||||
modal.value.hide();
|
||||
modal.value?.hide();
|
||||
|
||||
await router.push(`/organization/${result.slug}`);
|
||||
} catch (err) {
|
||||
} catch (err: any) {
|
||||
console.error(err);
|
||||
addNotification({
|
||||
group: "main",
|
||||
title: "An error occurred",
|
||||
text: err.data ? err.data.description : err,
|
||||
type: "error",
|
||||
@@ -112,13 +113,18 @@ async function createOrganization() {
|
||||
}
|
||||
stopLoading();
|
||||
}
|
||||
function show(event) {
|
||||
|
||||
function show(event?: MouseEvent): void {
|
||||
name.value = "";
|
||||
description.value = "";
|
||||
modal.value.show(event);
|
||||
modal.value?.show(event);
|
||||
}
|
||||
|
||||
function updateSlug() {
|
||||
function hide(): void {
|
||||
modal.value?.hide();
|
||||
}
|
||||
|
||||
function updateSlug(): void {
|
||||
if (!manualSlug.value) {
|
||||
slug.value = name.value
|
||||
.trim()
|
||||
@@ -129,6 +135,10 @@ function updateSlug() {
|
||||
}
|
||||
}
|
||||
|
||||
function setManualSlug(): void {
|
||||
manualSlug.value = true;
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
show,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user