Compare commits
No commits in common. "2b088892184db9b18a5206c2a4065b60b7f26b49" and "c74032d1d047fc862f197a62757c795af1e96a2b" have entirely different histories.
2b08889218
...
c74032d1d0
3 changed files with 8 additions and 43 deletions
|
|
@ -58,7 +58,6 @@ export const useAuthStore = defineStore('auth', () => {
|
|||
router.push({ name: 'collection'})
|
||||
} catch (error) {
|
||||
console.error('Login error:', error)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ export const useLabelsStore = defineStore('labels', () => {
|
|||
|
||||
const getLabels = async () => {
|
||||
try {
|
||||
const response = await apiClient.get(`/merch/labels?_=${Date.now()}`)
|
||||
const response = await apiClient.get('/merch/labels')
|
||||
const labelList = Array.isArray(response.data) ? response.data : []
|
||||
labels.value = labelList
|
||||
localStorage.setItem('labels', JSON.stringify(labelList))
|
||||
|
|
@ -46,7 +46,7 @@ export const useLabelsStore = defineStore('labels', () => {
|
|||
|
||||
const updateLabel = async (uuid, updatedData) => {
|
||||
try {
|
||||
await apiClient.put(`/merch/labels/${uuid}?_=${Date.now()}`, updatedData)
|
||||
await apiClient.put(`/merch/labels/${uuid}`, updatedData)
|
||||
await getLabels()
|
||||
} catch (error) {
|
||||
console.error('Failed to update label:', error)
|
||||
|
|
|
|||
|
|
@ -2,23 +2,16 @@
|
|||
import { reactive, ref } from 'vue'
|
||||
import { useAuthStore } from '@/stores/authStore.js'
|
||||
import { storeToRefs } from 'pinia'
|
||||
import { useMessage } from 'naive-ui'
|
||||
|
||||
const store = useAuthStore()
|
||||
const messages = useMessage()
|
||||
|
||||
const { activeTab } = storeToRefs(store)
|
||||
|
||||
const signInEmail = ref('')
|
||||
const signInPassword = ref('')
|
||||
|
||||
const onSignIn = async () => {
|
||||
try{
|
||||
await store.login(signInEmail.value, signInPassword.value)
|
||||
messages.success('Login success')
|
||||
} catch (error) {
|
||||
messages.error("Login error")
|
||||
}
|
||||
const onSignIn = () => {
|
||||
store.login(signInEmail.value, signInPassword.value)
|
||||
}
|
||||
|
||||
const signUp = reactive({
|
||||
|
|
@ -27,35 +20,8 @@ const signUp = reactive({
|
|||
reenterPassword: '',
|
||||
})
|
||||
|
||||
const onSignUp = async () => {
|
||||
if (!signUp.email.trim()) {
|
||||
messages.error('Email is required')
|
||||
return
|
||||
}
|
||||
|
||||
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/
|
||||
if (!emailRegex.test(signUp.email)) {
|
||||
messages.error('Please enter a valid email address')
|
||||
return
|
||||
}
|
||||
|
||||
if (!signUp.password.trim()) {
|
||||
messages.error('Password is required')
|
||||
return
|
||||
}
|
||||
|
||||
if (signUp.password !== signUp.reenterPassword) {
|
||||
messages.error('Passwords do not match')
|
||||
return
|
||||
}
|
||||
|
||||
try{
|
||||
await store.register(signUp.email, signUp.password)
|
||||
messages.success('Register success')
|
||||
activeTab.value = 'signin'
|
||||
} catch (error) {
|
||||
messages.error("Register error")
|
||||
}
|
||||
const onSignUp = () => {
|
||||
store.register(signUp.email, signUp.password)
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
@ -77,7 +43,7 @@ const onSignUp = async () => {
|
|||
<n-form-item-row label="Password">
|
||||
<n-input v-model:value="signInPassword" type="password" show-password-on="click" />
|
||||
</n-form-item-row>
|
||||
<n-button type="primary" block secondary strong attr-type="submit"> Sign In</n-button>
|
||||
<n-button type="primary" block secondary strong attr-type="submit" @click="onSignIn"> Sign In</n-button>
|
||||
</n-form>
|
||||
</n-tab-pane>
|
||||
|
||||
|
|
@ -92,7 +58,7 @@ const onSignUp = async () => {
|
|||
<n-form-item-row label="Reenter Password">
|
||||
<n-input type="password" v-model:value="signUp.reenterPassword" show-password-on="click" />
|
||||
</n-form-item-row>
|
||||
<n-button type="primary" block secondary strong attr-type="submit">Sign up</n-button>
|
||||
<n-button type="primary" block secondary strong attr-type="submit" @click="onSignUp">Sign up</n-button>
|
||||
</n-form>
|
||||
</n-tab-pane>
|
||||
</n-tabs>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue