Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update modal warning #101

Merged
merged 2 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ onMounted(() => {
// title: 'Are you sure?',
// question: 'Do you really want to delete this item?',
// onlyConfirm: true,
// error: true,
// warning: true,
// })
// console.log('result', result)
// }
Expand Down
3 changes: 2 additions & 1 deletion src/components/base/ConfirmDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ watch(
<span class="i-material-symbols-light-check-rounded text-3xl"></span>
</div>
<div
v-if="confirmDialog.getQuestion?.error"
v-if="confirmDialog.getQuestion?.warning"
class="w-[48px] h-[48px] bg-[#fde7e7] text-[#e3342f] flex justify-center items-center rounded-full"
>
<span class="i-material-symbols-light-error-rounded text-3xl"></span>
Expand All @@ -52,6 +52,7 @@ watch(
>
<Button
class="w-full rounded-md py-5 font-medium"
:class="{ 'bg-red-500 hover:bg-red-700': confirmDialog.getQuestion?.warning }"
@click="confirmDialog.confirm(true)"
>Confirm</Button
>
Expand Down
1 change: 1 addition & 0 deletions src/components/group/Activity.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
const result = await confirmDialog.open({
title: 'Are you want to delete this group?',
question: 'All data in your group will be lost',
warning: true,
})

if (result.isConfirmed) {
Expand Down Expand Up @@ -162,7 +163,7 @@
<div
class="text-gray-900 font-normal mt-2 content-format"
@click="handleHtmlLinkClick"
v-html="$sanitize(post?.content)"

Check warning on line 166 in src/components/group/Activity.vue

View workflow job for this annotation

GitHub Actions / type-check

'v-html' directive can lead to XSS attack
></div>

<div
Expand Down
1 change: 1 addition & 0 deletions src/components/group/list/GroupList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const handleDeleteGroup = async (id: string) => {
const result = await confirmDialog.open({
title: 'Are you want to delete this group?',
question: 'All data in your group will be lost',
warning: true,
})

if (result.isConfirmed) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/layout/SideBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const openConfirm = async () => {
const { isConfirmed } = await confirmDialog.open({
title: 'Confirm',
question: 'Do you really want to logout?',
error: true,
warning: true,
})

if (isConfirmed) {
Expand Down
1 change: 1 addition & 0 deletions src/components/quizzfly/create/QuestionList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const handleConfirmDelete = async (question: Question) => {
const result = await confirmDialog.open({
title: 'Are you sure?',
question: 'Do you really want to delete this item?',
warning: true,
})

if (result.isConfirmed) {
Expand Down
1 change: 1 addition & 0 deletions src/components/quizzfly/list/QuizzflyList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const handleConfirmDelete = async (quizzflyId: string) => {
const { isConfirmed } = await confirmDialog.open({
title: 'Delete Quizzfly',
question: 'Are you sure you want to delete this quizzfly?',
warning: true,
})

if (isConfirmed) {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/auth/password/reset.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const openConfirmError = async () => {
title: 'Failed',
question: 'Expired password recovery link',
onlyConfirm: true,
error: true,
warning: true,
})

router.push('/login')
Expand Down
11 changes: 9 additions & 2 deletions src/pages/groups/detail/group-detail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { ScrollArea } from '@/components/ui/scroll-area'
import {
Breadcrumb,
BreadcrumbItem,
BreadcrumbLink,
BreadcrumbList,
BreadcrumbPage,
BreadcrumbSeparator,
Expand All @@ -21,6 +20,7 @@ import { usePostStore } from '@/stores/group/post'

const groupStore = useGroupStore()
const postStore = usePostStore()
const route = useRoute()

const groupInfo = computed(() => {
return groupStore.getGroupInfo
Expand All @@ -40,6 +40,11 @@ const openModal = () => {
isShowModal.value = true
}

onBeforeMount(() => {
if (route.params.groupId && typeof route.params.groupId === 'string') {
postStore.fetchPosts(1, route.params.groupId)
}
})
onBeforeUnmount(() => {
postStore.$reset()
})
Expand All @@ -50,7 +55,9 @@ onBeforeUnmount(() => {
<Breadcrumb>
<BreadcrumbList>
<BreadcrumbItem>
<BreadcrumbLink href="/groups"> Groups </BreadcrumbLink>
<BreadcrumbPage>
<RouterLink to="/groups">Groups</RouterLink>
</BreadcrumbPage>
</BreadcrumbItem>
<BreadcrumbSeparator />
<BreadcrumbItem>
Expand Down
3 changes: 0 additions & 3 deletions src/pages/groups/detail/index.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<script lang="ts" setup>
import { useGroupStore } from '@/stores/group/group'
import { usePostStore } from '@/stores/group/post'

const groupStore = useGroupStore()
const postStore = usePostStore()
const route = useRoute()

const groupId = computed(() => route.params.groupId)
Expand All @@ -12,7 +10,6 @@ watchEffect(() => {
if (groupId.value && typeof groupId.value === 'string') {
groupStore.listMemberGroups(groupId.value)
groupStore.getDetailGroup(groupId.value)
postStore.fetchPosts(1, groupId.value)
}
})

Expand Down
2 changes: 1 addition & 1 deletion src/pages/groups/joinGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const openConfirm = async () => {
const { isConfirmed } = await confirmDialog.open({
title: 'Confirm',
question: 'Do you really want to join this group?',
error: true,
warning: true,
})

if (isConfirmed) {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/quizzfly/create.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ onBeforeMount(async () => {
title: 'Error',
question: 'Have an error when fetching data!',
onlyConfirm: true,
error: true,
warning: true,
})
router.push({ name: 'quizzfly' })
} finally {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/test.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const audioFiles = import.meta.glob('/assets/audio/*.mp3')
// title: 'Are you sure?',
// question: 'Do you really want to delete this item?',
// onlyConfirm: true,
// error: true,
// warning: true,
// })
// }

Expand Down
2 changes: 1 addition & 1 deletion src/stores/modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface IQuestion {
data?: any
onlyConfirm?: boolean
success?: boolean
error?: boolean
warning?: boolean
}

export const useConfirmDialog = defineStore({
Expand Down