Skip to content

Commit

Permalink
adding toast and replacing alerts;
Browse files Browse the repository at this point in the history
translate new board name;
  • Loading branch information
jnettome committed Apr 16, 2023
1 parent 8b88e26 commit 733e639
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 25 deletions.
1 change: 1 addition & 0 deletions app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const { locale, locales, setLocale } = useI18n()
const switchLocale = (code: string) => {
// locale.value = code
// alert(code)
// useNuxtApp().$toast(code)
setLocale(code)
}
const availableLocales = computed(() => {
Expand Down
7 changes: 6 additions & 1 deletion assets/css/main.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
@tailwind utilities;

:root {
--toastify-color-light: rgba(226, 232, 240, .8);
--toastify-color-dark: rgba(30, 41, 59, .8);
}
16 changes: 8 additions & 8 deletions components/BoardColumnComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ async function addTask () {
}).select('*').single()
if (error) {
return alert(`Oups ! Something went wrong ! Error: ${JSON.stringify(error)}`)
return useNuxtApp().$toast.error(`Oups ! Something went wrong ! Error: ${JSON.stringify(error)}`)
}
newTask.value = ''
Expand All @@ -212,7 +212,7 @@ async function updateTask (task: Todo) {
const { error } = await client.from<Todo>('todos').update({ is_complete: task.is_complete }).match({ id: task.id })
if (error) {
return alert(`Oups ! Something went wrong ! Error: ${JSON.stringify(error)}`)
return useNuxtApp().$toast.error(`Oups ! Something went wrong ! Error: ${JSON.stringify(error)}`)
}
emit('refreshBoard')
Expand All @@ -225,7 +225,7 @@ async function updateColumn (column: any) {
if (error) {
isEditingLoading.value = false
return alert(`Oups ! Something went wrong ! Error: ${JSON.stringify(error)}`)
return useNuxtApp().$toast.error(`Oups ! Something went wrong ! Error: ${JSON.stringify(error)}`)
}
isEditing.value = false
Expand All @@ -240,7 +240,7 @@ async function updateTaskPosition (taskId: number, position: number) {
if (error) {
loading.value = false
return alert(`Oups ! Something went wrong ! Error: ${JSON.stringify(error)}`)
return useNuxtApp().$toast.error(`Oups ! Something went wrong ! Error: ${JSON.stringify(error)}`)
}
emit('refreshBoard')
Expand All @@ -253,7 +253,7 @@ async function updateTaskBoardColumn (taskId: number, boardColumnId: number) {
if (error) {
loading.value = false
return alert(`Oups ! Something went wrong ! Error: ${JSON.stringify(error)}`)
return useNuxtApp().$toast.error(`Oups ! Something went wrong ! Error: ${JSON.stringify(error)}`)
}
emit('refreshBoard')
Expand All @@ -269,7 +269,7 @@ async function updateTaskPositionInSupabase (value: Array) {
if (error) {
loading.value = false
return alert(`Oups ! Something went wrong ! Error: ${JSON.stringify(error)}`)
return useNuxtApp().$toast.error(`Oups ! Something went wrong ! Error: ${JSON.stringify(error)}`)
}
loading.value = false
Expand All @@ -292,7 +292,7 @@ async function removeTask (task: Todo) {
const { error } = await client.from<Todo>('todos').delete().match({ id: task.id })
if (error) {
return alert(`Oups ! Something went wrong ! Error: ${JSON.stringify(error)}`)
return useNuxtApp().$toast.error(`Oups ! Something went wrong ! Error: ${JSON.stringify(error)}`)
}
// tasks.splice(tasks.indexOf(task), 1)
Expand All @@ -305,7 +305,7 @@ async function removeColumn (boardColumnId: number) {
const { error } = await client.from<Board>('board_columns').delete().match({ id: boardColumnId })
if (error) {
return alert(`Oups ! Something went wrong ! Error: ${JSON.stringify(error)}`)
return useNuxtApp().$toast.error(`Oups ! Something went wrong ! Error: ${JSON.stringify(error)}`)
}
emit('refreshBoard')
Expand Down
2 changes: 1 addition & 1 deletion components/TagsField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ async function addTag () {
if (error) {
isEditingLoading.value = false
return alert(`Oups ! Something went wrong ! Error: ${JSON.stringify(error)}`)
return useNuxtApp().$toast.error(`Oups ! Something went wrong ! Error: ${JSON.stringify(error)}`)
}
newTag.value = ''
Expand Down
6 changes: 4 additions & 2 deletions i18n.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export default defineI18nConfig(nuxt => ({
please_wait: 'Please wait...',
email_sent: "We've sent you an email with a link to sign in.",
your_email_address: 'Your email address'
}
},
new_board_name: 'My new board 🎉',
},
'pt': {
logout: 'sair',
Expand All @@ -48,7 +49,8 @@ export default defineI18nConfig(nuxt => ({
please_wait: 'aguarde...',
email_sent: "Enviamos um email com um link para você acessar.",
your_email_address: 'Seu endereço de email'
}
},
new_board_name: 'Meu novo projeto 🎉',
}
}
}))
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"dependencies": {
"@vueuse/components": "^9.13.0",
"dayjs": "^1.11.7",
"vue3-toastify": "^0.1.6",
"vuedraggable": "^4.1.0"
}
}
16 changes: 8 additions & 8 deletions pages/boards/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ async function updateBoard (params: any) {
if (error) {
isEditingLoading.value = false
return alert(`Oups ! Something went wrong ! Error: ${JSON.stringify(error)}`)
return useNuxtApp().$toast.error(`Oups ! Something went wrong ! Error: ${JSON.stringify(error)}`)
}
isEditing.value = false
Expand Down Expand Up @@ -284,7 +284,7 @@ async function addColumn () {
}).select('id, name').single()
if (error) {
return alert(`Oups ! Something went wrong ! Error: ${JSON.stringify(error)}`)
return useNuxtApp().$toast.error(`Oups ! Something went wrong ! Error: ${JSON.stringify(error)}`)
}
// boards.push(data)
Expand All @@ -303,7 +303,7 @@ async function addNewColumn () {
}).select('id, name').single()
if (error) {
return alert(`Oups ! Something went wrong ! Error: ${JSON.stringify(error)}`)
return useNuxtApp().$toast.error(`Oups ! Something went wrong ! Error: ${JSON.stringify(error)}`)
}
// boards.push(data)
Expand All @@ -317,7 +317,7 @@ async function addNewColumn () {
// const { error } = await client.from<BoardColumn>('board_columns').delete().match({ id: task.id })
// if (error) {
// return alert(`Oups ! Something went wrong ! Error: ${JSON.stringify(error)}`)
// return useNuxtApp().$toast.error(`Oups ! Something went wrong ! Error: ${JSON.stringify(error)}`)
// }
// boards.splice(boards.indexOf(task), 1)
Expand All @@ -331,7 +331,7 @@ async function updateTask (task: Todo) {
}).match({ id: task.id })
if (error) {
return alert(`Oups ! Something went wrong ! Error: ${JSON.stringify(error)}`)
return useNuxtApp().$toast.error(`Oups ! Something went wrong ! Error: ${JSON.stringify(error)}`)
}
isLoading.value = false
Expand All @@ -349,7 +349,7 @@ async function updateTaskTaggings(task: Todo, tagIds: number[], todoId: number)
if (error) {
isLoading.value = false
return alert(`Oups ! Something went wrong ! Error: ${JSON.stringify(error)}`)
return useNuxtApp().$toast.error(`Oups ! Something went wrong ! Error: ${JSON.stringify(error)}`)
}
const { data: taggings, error: errorTaggings } = await client.from('taggings').select('id, tag_id, todo_id, tags(*)').match({ todo_id: todoId, user_id: user.value?.id })
Expand All @@ -368,7 +368,7 @@ async function deleteTask (params: any) {
const { error } = await client.from<Todo>('todos').delete().match({ id: params.id })
if (error) {
return alert(`Oups ! Something went wrong ! Error: ${JSON.stringify(error)}`)
return useNuxtApp().$toast.error(`Oups ! Something went wrong ! Error: ${JSON.stringify(error)}`)
}
isLoading.value = false
Expand All @@ -385,7 +385,7 @@ async function removeBoard (board: Board) {
const { error } = await client.from<Board>('boards').delete().match({ id: board.id })
if (error) {
return alert(`Oups ! Something went wrong ! Error: ${JSON.stringify(error)}`)
return useNuxtApp().$toast.error(`Oups ! Something went wrong ! Error: ${JSON.stringify(error)}`)
}
router.push('/boards')
Expand Down
8 changes: 5 additions & 3 deletions pages/boards/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ async function addBoard () {
}).select('id, name').single()
if (error) {
return alert(`Oups ! Something went wrong ! Error: ${JSON.stringify(error)}`)
return useNuxtApp().$toast(`Oups ! Something went wrong ! Error: ${JSON.stringify(error)}`)
}
boards.push(data)
Expand All @@ -74,15 +74,17 @@ async function addBoard () {
loading.value = false
}
const $t = useI18n().t
async function createNewBoard () {
loading.value = true
const { data, error } = await client.from<Board>('boards').insert({
user_id: user.value.id,
name: 'My new board 🎉',
name: $t('new_board_name'),
}).select('id, name').single()
if (error) {
return alert(`Oups ! Something went wrong ! Error: ${JSON.stringify(error)}`)
return useNuxtApp().$toast(`Oups ! Something went wrong ! Error: ${JSON.stringify(error)}`)
}
boards.push(data)
Expand Down
2 changes: 1 addition & 1 deletion pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const login = async (provider: string) => {
const { error, data } = await client.auth.signInWithOtp({ email: email.value })
if (error) {
alert(error)
useNuxtApp().$toast.error(JSON.stringify(error))
}
loading.value = false
Expand Down
10 changes: 10 additions & 0 deletions plugins/vue3-toastify.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Vue3Toastify, { toast } from 'vue3-toastify';
// import 'vue3-toastify/dist/index.css';

export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.use(Vue3Toastify, { autoClose: 1000, theme: 'auto' });

return {
provide: { toast },
};
});
7 changes: 6 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{
// https://nuxt.com/docs/guide/concepts/typescript
"extends": "./.nuxt/tsconfig.json"
"extends": "./.nuxt/tsconfig.json",
"compilerOptions": {
"types": [
"vue3-toastify/global"
]
}
}
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5590,6 +5590,11 @@ vue-router@^4.1.6:
dependencies:
"@vue/devtools-api" "^6.4.5"

vue3-toastify@^0.1.6:
version "0.1.6"
resolved "https://registry.yarnpkg.com/vue3-toastify/-/vue3-toastify-0.1.6.tgz#b3bc273deded1ee7b301330862de56e0c9e998c4"
integrity sha512-Ijk/tmpYrQLzyK/a0hFd5E/Gfoj+UkUGRLMU71JZpZ5cMUbkwWjXjdJ2xIXeGh/MJtl3xQWClG3z0PWcKz3ksQ==

vue@^3.2.47:
version "3.2.47"
resolved "https://registry.yarnpkg.com/vue/-/vue-3.2.47.tgz#3eb736cbc606fc87038dbba6a154707c8a34cff0"
Expand Down

1 comment on commit 733e639

@vercel
Copy link

@vercel vercel bot commented on 733e639 Apr 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.