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

create organizer profile on add event. #358

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
7 changes: 2 additions & 5 deletions components/TInput/TInputArray.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default {
}),
watch: {
value(val) {
const extra = [...val, {}]
const extra = [...val, '']
Copy link
Contributor

Choose a reason for hiding this comment

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

check other pages where TInputArray is used, i think this change will break that component on other pages


if (JSON.stringify(extra) === JSON.stringify(this.internalValue)) {
return
Expand All @@ -54,10 +54,7 @@ export default {
},
},
mounted() {
const val = this.value || []
const extra = [...val, {}]

this.internalValue = extra
this.internalValue = this.value
},
}
</script>
106 changes: 75 additions & 31 deletions components/TInput/TInputProfile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@
>
<TProfilePhoto2 size="md" :src="item.photo" />
<div class="flex-grow">
<div v-if="item.name" class="font-bold text-sm">{{ item.name }}</div>
<div v-if="item.name" class="font-bold text-sm">
{{ item.name }}
</div>
<div class="text-xs text-gray-700 flex space-x-2">
<div>@{{ item.username }}</div>
<div v-if="item.instagram" class="space-x-1 flex">
Expand All @@ -68,53 +70,74 @@
</div>
<template v-if="inviteUsername">
<div
class="flex px-4 py-2 hover:bg-blue-100 items-center cursor-pointer space-x-1 text-sm text-gray-700"
@click="
create({
username: inviteUsername,
instagram: `https://instagram.com/` + inviteUsername,
})
"
class="flex justify-center px-4 py-2 hover:bg-blue-100 items-center cursor-pointer space-x-1 text-sm text-gray-700"
>
<div>
{{ $t('TInputProfile.import') }}
</div>
<TIcon name="instagram" size="4" />
<div>
{{ inviteUsername }}
</div>
<h3 @click="showPopup = !showPopup" class="text-center">
+ Add New Organizer
</h3>
</div>
<div
class="flex px-4 py-2 hover:bg-blue-100 items-center cursor-pointer space-x-1 text-sm text-gray-700"
@click="
create({
username: inviteUsername,
facebook: `https://facebook.com/` + inviteUsername,
})
"
>
<div>
{{ $t('TInputProfile.import') }}
<TPopup v-if="showPopup">
<div class="flex justify-between border-b pb-2 mb-4">
<div class="grow font-bold text-center">Add New Organizer</div>
<button class="cursor-pointer" @click="showPopup = false">
<TIcon name="close" class="cursor-pointer w-4 h-4" />
</button>
</div>
<TIcon name="facebook" size="4" />
<div>
{{ inviteUsername }}
<div class="my-4 flex flex-col justify-center">
<div>Social Media or Website</div>
<TField
v-model="websites"
component="TInputArray"
:children="{
component: 'TInput',
placeholder: 'https://',
}"
label-position="top"
/>
<p>
You can use link to their Instagram or Facebook or anything else
</p>
<div class="flex justify-end gap-x-2">
<TButton @click="showPopup = false" label="Cancel" />
<TButton
@click="
create({
username: inviteUsername,
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a problem with username extraction. Let's say this link will be provided https://facebook.com/profile.php?id=3234, which username will be set in this case?

...dynamicData,
})
"
label="Save"
type="primary"
/>
</div>
</div>
</div>
</TPopup>
</template>
</div>
</div>
</template>
<script>
import { computed, ref, watch } from '@nuxtjs/composition-api'
import { computed, onMounted, ref, watch } from '@nuxtjs/composition-api'
import { useAlgolia } from '~/use/algolia'
import { useEvents } from '~/use/events'
import { useDoc } from '~/use/doc'
import { useAuth } from '~/use/auth'
import TPopup from '../TPopup.vue'
import TInputArray from './TInputArray.vue'
import TInput from './TInput.vue'
import TField from '../TField.vue'

export default {
name: 'TInputProfile',
inheritAttrs: false,

components: {
Copy link
Contributor

Choose a reason for hiding this comment

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

components are auto imported

TPopup,
TInputArray,
TInput,
TField,
},

props: {
value: {
type: [Object, String],
Expand All @@ -139,6 +162,24 @@ export default {
const { eventRoleOptions } = useEvents()
const { create: createProfile } = useDoc('profiles')

const showPopup = ref(false)
const websites = ref([])

const dynamicData = computed(() => {
let data = {}

websites.value.forEach((website) => {
if (website.includes('facebook')) {
data.facebook = website
} else if (website.includes('instagram')) {
data.instagram = website
} else if (website.includes('twitter')) {
data.twitter = website
}
})
return data
})

if (typeof props.value === 'string') {
emit('input', { username: props.value })
}
Expand Down Expand Up @@ -236,6 +277,9 @@ export default {
eventRoleOptions,
create,
inviteUsername,
showPopup,
dynamicData,
websites,
}
},
}
Expand Down