Skip to content

Commit

Permalink
Merge branch 'main' into 105a6-improve-ui-checkbox/switch
Browse files Browse the repository at this point in the history
  • Loading branch information
JhumanJ authored Oct 19, 2024
2 parents c6a75fb + e737108 commit 68b8756
Show file tree
Hide file tree
Showing 7 changed files with 204 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,15 @@ public function poll(PollSubmissionRequest $request)
$this->authorize('view', $form);

$lastSubmission = $form->submissions()->latest()->first();
$submissionData = null;
if (!$lastSubmission) {
// Generate fake data when no previous submissions
$submissionData = (new FormSubmissionDataFactory($form))->asFormSubmissionData()->createSubmissionData();
}
$cacheKey = "zapier-poll-submissions-{$form->id}";
return (array) \Cache::remember($cacheKey, 60 * 5, function () use ($form, $submissionData, $lastSubmission) {
return [ZapierIntegration::formatWebhookData($form, $submissionData ?? $lastSubmission->data)];
});

return [ZapierIntegration::formatWebhookData($form, $submissionData ?? $lastSubmission->data)];
}
}
11 changes: 5 additions & 6 deletions api/app/Integrations/Handlers/AbstractIntegrationHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,12 @@ public static function formatWebhookData(Form $form, array $submissionData): arr

// Old format - kept for retro-compatibility
$oldFormatData = [];
foreach ($formatter->getFieldsWithValue() as $field) {
$oldFormatData[$field['name']] = $field['value'];
}

// New format using ID
$formattedData = [];
foreach ($formatter->getFieldsWithValue() as $field) {
$fieldsWithValue = $formatter->getFieldsWithValue();

foreach ($fieldsWithValue as $field) {
$oldFormatData[$field['name']] = $field['value'];
// New format using ID
$formattedData[$field['id']] = [
'value' => $field['value'],
'name' => $field['name'],
Expand Down
15 changes: 8 additions & 7 deletions client/components/forms/PhoneInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
>
<v-select
v-model="selectedCountryCode"
class="w-[130px]"
:class="theme.PhoneInput.countrySelectWidth"
dropdown-class="max-w-[300px]"
input-class="rounded-r-none"
:data="countries"
Expand Down Expand Up @@ -41,13 +41,14 @@
<template #selected="props">
<div
class="flex items-center space-x-2 justify-center overflow-hidden"
:class="theme.PhoneInput.maxHeight"
>
<country-flag
size="normal"
class="!-mt-[9px] rounded"
:country="props.option.code"
/>
<span>{{ props.option.dial_code }}</span>
<span class="text-sm">{{ props.option.dial_code }}</span>
</div>
</template>
</v-select>
Expand All @@ -57,11 +58,11 @@
class="inline-flex-grow !border-l-0 !rounded-l-none"
:disabled="disabled ? true : null"
:class="[
theme.default.input,
theme.default.spacing.horizontal,
theme.default.spacing.vertical,
theme.default.fontSize,
theme.default.borderRadius,
theme.PhoneInput.input,
theme.PhoneInput.spacing.horizontal,
theme.PhoneInput.spacing.vertical,
theme.PhoneInput.fontSize,
theme.PhoneInput.borderRadius,
{
'!ring-red-500 !ring-2': hasError,
'!cursor-not-allowed !bg-gray-200': disabled,
Expand Down
4 changes: 2 additions & 2 deletions client/components/open/forms/OpenCompleteForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
class="border shadow-sm p-2 my-4 flex items-center rounded-md bg-yellow-100 dark:bg-yellow-600/20 border-yellow-500 dark:border-yellow-500/20"
>
<div class="flex-grow">
<p
<div
class="mb-0 py-2 px-4 text-yellow-600"
v-html="form.closed_text"
/>
Expand Down Expand Up @@ -100,7 +100,7 @@
key="form"
>
<open-form
v-if="form"
v-if="form && !form.is_closed"
:form="form"
:loading="loading"
:fields="form.properties"
Expand Down
108 changes: 108 additions & 0 deletions client/components/open/forms/components/FirstSubmissionModal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<template>
<modal
:show="show"
compact-header
backdrop-blur="sm"
@close="$emit('close')"
>
<template #title>
<h2 class="text-xl font-medium">
🎉 Your first submission! Congratulations!
</h2>
</template>
<div class="">
<div class="text-sm text-gray-500">
Congratulations on creating your form and receiving your first submission! Your form is now live and ready for action. You can now <span class="font-semibold">share your form</span> with others, or <span class="font-semibold">open your Notion database</span> to view the submitted data.
</div>

<div class="flex gap-2 items-center max-w-full">
<ShareFormUrl
class="flex-grow my-4"
:form="form"
/>
<UButton
v-track.form_first_submission_modal_open_db_click
color="white"
icon="i-logos-notion-icon"
:to="form.notion_database_url"
target="_blank"
>
See Notion database
</UButton>
</div>

<p class="text-gray-500 font-medium text-sm text-center my-4">
What's next?
</p>
<div class="grid grid-cols-2 gap-2">
<div
v-for="(item, i) in helpLinks"
:key="i"
role="button"
class="bg-white shadow border border-gray-200 rounded-lg p-4 pb-2 items-center justify-center flex flex-col relative hover:bg-gray-50 group transition-colors"
@click="item.action"
>
<div class="flex justify-center">
<div class="h-8 w-8 text-gray-600 group-hover:text-gray-800 transition-colors flex items-center">
<Icon
:name="item.icon"
class=""
size="40px"
/>
</div>
</div>

<p class="text-gray-500 font-medium text-xs text-center my-2">
{{ item.label }}
</p>
</div>
</div>
</div>
</modal>
</template>

<script setup>
import ShareFormUrl from '~/components/notion/forms/components/ShareFormUrl.vue'
const props = defineProps({
show: { type: Boolean, required: true },
form: { type: Object, required: true }
})
const emit = defineEmits(['close'])
const confetti = useConfetti()
const crisp = useCrisp()
watch(() => props.show, () => {
if (props.show) {
confetti.play()
useAmplitude().logEvent('form_first_submission_modal_viewed')
}
})
const helpLinks = computed(() => {
return [
{
'label': 'Embed form on your website',
'icon': 'heroicons:code-bracket',
'action': () => crisp.openHelpdeskArticle('how-to-embed-your-form-on-your-website-yqa6i')
},
{
'label': 'Embed form in Notion',
'icon': 'ri:notion-fill',
'action': () => crisp.openHelpdeskArticle('can-i-embed-my-form-in-a-notion-page-or-site-11iroj9')
},
{
'label': 'Help Center',
'icon': 'heroicons:book-open',
'action': () => crisp.openHelpdesk()
},
{
'label': 'Contact Us',
'icon': 'heroicons:chat-bubble-left-right',
'action': () => { crisp.openAndShowChat() }
},
]
})
</script>
84 changes: 75 additions & 9 deletions client/lib/forms/themes/form-themes.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,40 @@ export const themes = {
lg: 'w-6 h-6 mx-1'
}
},
PhoneInput: {
countrySelectWidth: {
sm: 'w-[100px]',
md: 'w-[120px]',
lg: 'w-[120px]'
},
flag: {
sm: '!-mt-[14px]',
md: '!-mt-[9px] rounded',
lg: '!-mt-[9px] rounded'
},
flagSize: {
sm: 'small',
md: 'normal',
lg: 'normal'
},
maxHeight: {
sm: 'max-h-[20px]',
md: 'max-h-[24px]',
lg: 'max-h-[28px]'
}
},
DateInput: {
input:
'flex-1 appearance-none border border-gray-300 dark:border-gray-600 w-full bg-white text-gray-700 dark:bg-notion-dark-light dark:text-gray-300 dark:placeholder-gray-500 placeholder-gray-400 shadow-sm text-base focus:outline-none focus:ring-2 focus:border-transparent focus:ring-opacity-100'
},
CheckboxInput:{
CheckboxInput: {
size: {
sm: 'w-4 h-4',
md: 'w-5 h-5',
lg: 'w-5 h-5'
},
},
SwitchInput:{
SwitchInput: {
containerSize: {
sm: 'h-5 w-10 p-0.5',
md: 'h-6 w-12 p-1',
Expand All @@ -101,7 +123,7 @@ export const themes = {
lg: 'translate-x-6'
}
},
RatingInput:{
RatingInput: {
size: {
sm: 'w-6 h-6',
md: 'w-8 h-8',
Expand Down Expand Up @@ -202,17 +224,39 @@ export const themes = {
lg: 'w-6 h-6 mx-1'
}
},
PhoneInput: {
countrySelectWidth: {
sm: 'w-[100px]',
md: 'w-[120px]',
lg: 'w-[120px]'
},
flag: {
sm: '!-mt-[14px]',
md: '!-mt-[9px] rounded',
lg: '!-mt-[9px] rounded'
},
flagSize: {
sm: 'small',
md: 'normal',
lg: 'normal'
},
maxHeight: {
sm: 'max-h-[20px]',
md: 'max-h-[24px]',
lg: 'max-h-[28px]'
}
},
DateInput: {
input: 'flex-1 appearance-none border border-gray-300 dark:border-gray-600 w-full bg-white text-gray-700 dark:bg-notion-dark-light dark:text-gray-300 placeholder-gray-400 text-base focus:outline-none focus:ring-2 focus:border-transparent focus:ring-opacity-100'
},
CheckboxInput:{
CheckboxInput: {
size: {
sm: 'w-4 h-4',
md: 'w-5 h-5',
lg: 'w-5 h-5'
},
},
SwitchInput:{
SwitchInput: {
containerSize: {
sm: 'h-5 w-10',
md: 'h-6 w-12',
Expand All @@ -224,7 +268,7 @@ export const themes = {
lg: 'h-4 w-4'
},
},
RatingInput:{
RatingInput: {
size: {
sm: 'w-6 h-6',
md: 'w-8 h-8',
Expand Down Expand Up @@ -325,17 +369,39 @@ export const themes = {
lg: 'w-6 h-6 mx-1'
}
},
PhoneInput: {
countrySelectWidth: {
sm: 'w-[100px]',
md: 'w-[120px]',
lg: 'w-[120px]'
},
flag: {
sm: '!-mt-[14px]',
md: '!-mt-[9px] rounded',
lg: '!-mt-[9px] rounded'
},
flagSize: {
sm: 'small',
md: 'normal',
lg: 'normal'
},
maxHeight: {
sm: 'max-h-[20px]',
md: 'max-h-[24px]',
lg: 'max-h-[28px]'
}
},
DateInput: {
input: 'shadow-inner-notion border-transparent focus:border-transparent flex-1 appearance-none w-full bg-notion-input-background dark:bg-notion-dark-light text-gray-900 dark:text-gray-100 placeholder-gray-400 text-base focus:outline-none focus:ring-0 focus:border-transparent focus:shadow-focus-notion p-[1px]'
},
CheckboxInput:{
CheckboxInput: {
size: {
sm: 'w-4 h-4',
md: 'w-5 h-5',
lg: 'w-5 h-5'
},
},
SwitchInput:{
SwitchInput: {
containerSize: {
sm: 'h-5 w-10',
md: 'h-6 w-12',
Expand All @@ -347,7 +413,7 @@ export const themes = {
lg: 'h-4 w-4'
},
},
RatingInput:{
RatingInput: {
size: {
sm: 'w-6 h-6',
md: 'w-8 h-8',
Expand Down
2 changes: 1 addition & 1 deletion client/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<p
class="mt-4 sm:mt-5 text-base leading-7 sm:text-xl sm:leading-9 font-medium text-gray-500"
>
Create beautiful forms and share them anywhere. It super fast, you
Create beautiful forms and share them anywhere. It's super fast, you
don't need to know how to code. Get started
<span class="font-semibold">for free</span>!
</p>
Expand Down

0 comments on commit 68b8756

Please sign in to comment.