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

(WIP) Refactor, revamp, and cleanup #268

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ node_modules
/playwright-report/
/blob-report/
/playwright/.cache/
.generated
5 changes: 5 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 61 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/team-generator.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions .npmrc

This file was deleted.

2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"semi": false,
"arrowParens": "always",
"singleQuote": true,
"printWidth": 120,
"printWidth": 140,
"htmlWhitespaceSensitivity": "ignore"
}
1 change: 0 additions & 1 deletion .tool-versions

This file was deleted.

5 changes: 3 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"files.exclude": {
// "**/.nuxt": true,
"**/.nuxt": true,
"**/.output": true,
"**/node_modules": true,
"**/dist": true
"**/dist": true,
"**/.generated": true
},
"editor.quickSuggestions": {
"strings": true
Expand Down
18 changes: 0 additions & 18 deletions app.vue

This file was deleted.

36 changes: 36 additions & 0 deletions app/app.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<script lang="ts" setup>
import type { FetchFn } from '@zenstackhq/tanstack-query/runtime'
import { ModalsContainer } from 'vue-final-modal'

const {
public: { site },
} = useRuntimeConfig()

provideHooksContext({
endpoint: `${site.url}/api/model`,
logging: true,
})

useHead({
titleTemplate: (title) => title || 'Team Generator',
})
</script>

<template>
<div>
<!-- <UNotifications /> -->
<NuxtLayout>
<NuxtPage />
</NuxtLayout>
<ModalsContainer />
</div>
</template>

<style>
@import 'tailwindcss';
@import '@nuxt/ui';

@theme {
--font-family-sans: 'Inter var', sans-serif;
}
</style>
File renamed without changes.
File renamed without changes.
109 changes: 109 additions & 0 deletions app/components/dialog/confirm.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<script lang="ts" setup>
import { VueFinalModal } from 'vue-final-modal'

const {
size = 'sm',
clickToClose = false,
description = undefined,
confirmLabel = 'Yes',
dismissLabel = 'No',
onConfirm = () => {},
onDismiss = () => {},
onClose = () => {},
transition = 'fade',
} = defineProps<{
transition?: 'fade' | 'down'
size?: 'sm' | 'md'
title: string
description?: string
confirmLabel?: string
dismissLabel?: string
onConfirm?: (() => void) | (() => Promise<void>)
onDismiss?: () => void
onClose: () => void
clickToClose?: boolean
}>()

const sizeClass = computed(() => {
switch (size) {
case 'sm':
return 'sm:max-w-xl'
case 'md':
return 'sm:max-w-3xl'

default:
return 'max-w-3xl'
}
})

const contentTransition = computed(() => {
switch (transition) {
case 'fade':
return 'vfm-fade'
case 'down':
return 'vfm-slide-down'
default:
return 'vfm-fade'
}
})
const isConfirming = ref(false)

const dismiss = () => {
onDismiss()
onClose()
}

const confirm = async () => {
const isAsync = onConfirm.constructor.name === 'AsyncFunction'

if (isAsync) {
isConfirming.value = true
await onConfirm()
isConfirming.value = false
} else {
onConfirm()
}

onClose()
}
</script>

<template>
<VueFinalModal
class="flex items-center justify-center absolute bottom-0"
:click-to-close="clickToClose"
overlay-transition="vfm-fade"
content-transition="vfm-slide-down"
overlay-class="!bg-black/20 backdrop-blur-sm"
:content-class="['w-full absolute bottom-0', sizeClass]"
>
<UCard>
<div class="flex flex-col gap-y-2">
<span class="text-lg font-semibold">{{ title }}</span>
<!-- eslint-disable-next-line vue/no-v-html -->
<p class="text-sm text-gray-500" v-html="description"></p>
</div>
<template #footer>
<div class="flex justify-end gap-3">
<UButton
v-if="dismissLabel"
size="xl"
:ui="{ base: 'justify-around' }"
variant="soft"
color="neutral"
:label="dismissLabel"
@click="dismiss"
/>
<UButton
size="xl"
color="error"
:loading="isConfirming"
:label="confirmLabel"
:ui="{ base: 'justify-around' }"
@click="confirm"
/>
</div>
</template>
</UCard>
</VueFinalModal>
</template>
40 changes: 40 additions & 0 deletions app/components/dialog/create-league.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<script lang="ts" setup>
import { LeagueDTOSchema } from '~~/schemas/forms/create-league.form'

const { accountId } = defineProps<{ accountId: number }>()
const emits = defineEmits<{ close: [] }>()

const { mutateAsync: asyncCreateLeague, isPending: isCreatingLeague } = useCreateLeague()

const { defineField, handleSubmit } = useForm({
validationSchema: toTypedSchema(LeagueDTOSchema),
initialValues: {
accountId,
configuration: {
rules: {},
teamCount: 2,
},
},
})

const [name] = defineField('name')

const onCreateLeague = handleSubmit(async (league) => {
await asyncCreateLeague({
data: league,
})

emits('close')
})
</script>

<template>
<OverlayModal title="Create a League" size="xs">
<UFormField required size="xl">
<UInput v-model="name" placeholder="League name" :ui="{ root: 'w-full' }" />
</UFormField>
<template #footer-right>
<UButton color="primary" @click="onCreateLeague()" :loading="isCreatingLeague">Create</UButton>
</template>
</OverlayModal>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ const emit = defineEmits<{
>
<UIcon :name="icon" class="text-6xl text-gray-400" v-if="!loading" />
<UIcon name="i-ph-spinner-bold" class="text-6xl text-gray-400 animate-spin" v-else />
<span class="block mt-4 text-sm font-medium text-gray-900">{{ label }}</span>
<span class="block mt-4 text-sm font-medium text-gray-900 dark:text-gray-400">{{ label }}</span>
</button>
</template>
Loading
Loading