Skip to content

Instantly share code, notes, and snippets.

View oxcode-dev's full-sized avatar
💭
Always Available to code. Try me.

oxcode__ oxcode-dev

💭
Always Available to code. Try me.
View GitHub Profile
@oxcode-dev
oxcode-dev / useForm.vue
Created June 15, 2024 09:13
UseForm Hooks
export default function useForm(fields) {
let defaults = fields;
let recentlySuccessfulTimeoutId;
const form = reactive({
fields: JSON.parse(JSON.stringify(fields)),
errors: {},
dirty: false,
hasErrors: false,
processing: false,
@oxcode-dev
oxcode-dev / NotificationBar.js
Created October 29, 2023 22:49
Reactjs Notification SnackBar
export const NotificationBar = ({ active=true }) => {
return (
<>
<div className={
`fixed z-[500] bottom-4 right-2 transition-transform duration-[0.8s] ease-[ease-in-out]
${active ? 'translate-y-[-10%]' : 'translate-y-[120%]'}`
}>
<div
className="relative block w-full max-w-sm rounded-lg bg-green-500 px-4 py-2 text-base text-white"
>
@oxcode-dev
oxcode-dev / useFirebaseAuth.js
Created October 1, 2023 12:43
Firebase React Custom Hook
import { signOut, signInWithEmailAndPassword, createUserWithEmailAndPassword, updatePassword, updateEmail, deleteUser } from "firebase/auth"
import { auth } from "../firebase.config"
import { useAuthStore } from "../stores/auth"
import { errorResponse } from "../helpers/firebaseErrorResponse";
import { useState } from "react";
import router from "../router";
export const useFirebaseAuth = () => {
const user = auth.currentUser;
const authStore = useAuthStore()
@oxcode-dev
oxcode-dev / firebaseErrorResponse.js
Created September 21, 2023 11:54
Firebase Error Response
let errorResponses = {
'auth/email-already-in-use': 'The email provided already exists.',
'auth/user-not-found': 'User not found. Please check your credentials and try again.',
'auth/email-not-found': 'Email address not found. Please check your credentials and try again.',
'auth/operation-not-allowed': 'Operation not allowed.',
'auth/invalid-email': 'The provided email is not valid.',
'auth/weak-password': 'The password provided is too weak.',
'auth/wrong-password': 'The provided password is incorrect.',
'auth/user-disabled': "The user's account has been disabled or deleted.",
@oxcode-dev
oxcode-dev / useFirebaseAuth.js
Last active October 1, 2023 12:44
Vue Composables Firebase Authentication Hook
import { signOut, signInWithEmailAndPassword, createUserWithEmailAndPassword, updatePassword, updateEmail, deleteUser } from "firebase/auth"
import { auth } from "../firebase.config"
import { errorResponse } from '../helpers/FirebaseErrorResponse';
import { ref } from "vue";
import router from "../router";
export const useFirebaseAuth = () => {
const user = auth.currentUser;
const isLoading = ref(false)
const error = ref('')
export const o_O = (promise) => {
return promise.then(data => {
if(data instanceof Error) return [data]
return [null, data]
}).catch(err => [err])
}
// Create Search Url
export const urlString = (str) => {
return str.toLowerCase().replace(new RegExp(' ', 'g'), '+');