{"version":3,"file":"fiveFestSubmission.99914eea.js","sources":["../../../../stores/fiveFestSubmission.ts"],"sourcesContent":["import _ from 'lodash'\nimport { gql } from '~/apollo/gql'\nimport { defineStore } from 'pinia'\n\nexport const useFiveFestSubmission = defineStore('five-fest-submission', () => {\n const session = useSession()\n const openFeature = useOpenFeature()\n const { $posthog } = useNuxtApp()\n const { currentRoute: route } = useRouter()\n\n const {\n result: festivalSubmissionsResult,\n refetch: reloadFestivalSubmissions,\n onResult: onFestivalSubmissions,\n } = useQuery(\n FestivalSubmissionsQuery,\n () => ({\n ffid: openFeature.getNumber('current_film_festival'),\n poster: openFeature.getObject('asset_type_ids').poster,\n }),\n () => ({\n enabled: !!session.user,\n }),\n )\n const festivalSubmissions = computed(\n () => festivalSubmissionsResult.value?.festival_submissions,\n )\n\n onFestivalSubmissions(({ loading }) => {\n if (loading) return\n\n $posthog().setPersonProperties({\n [`${openFeature.getNumber('current_film_festival')}_five_fest_submitted`]:\n festivalSubmissionsResult.value?.festival_submissions.some(\n s => s.submitted_at,\n ),\n })\n })\n\n const submissionId = ref()\n const submissionQueryEnabled = ref(false)\n const { result: submissionResult, refetch: reloadSubmission } = useQuery(\n LoadFestivalSubmission,\n () => ({\n id: submissionId.value,\n }),\n () => ({\n enabled: submissionQueryEnabled.value,\n }),\n )\n const submission = computed(\n () => submissionResult.value?.festival_submissions_by_pk,\n )\n\n const poster = computed(() =>\n _.chain(submission.value?.assets)\n .filter(\n asset =>\n asset.asset_type.id == openFeature.getObject('asset_type_ids').poster,\n )\n .orderBy(asset => asset.created_at, 'desc')\n .first()\n .value(),\n )\n\n const isSubmitted = computed(() => !!submission.value?.submitted_at)\n\n const { mutate: pay, onDone: onPay } = useMutation(SubmissionPayment, () => ({\n variables: {\n returnUrl: window.location.href.replace(window.location.hash, ''),\n lineItems: [\n {\n priceId: openFeature.getString(\n 'five_fest_price',\n ) as unknown as string,\n quantity: 1,\n },\n ],\n festivalSubmissionId: submission.value?.id!,\n },\n }))\n onPay(({ data }) => {\n window.location.href = data?.url!\n })\n\n watch(\n route,\n ({ fullPath, params }) => {\n if (!fullPath.startsWith('/fivefest')) {\n return\n }\n\n if (params.submissionId) {\n submissionQueryEnabled.value = false\n submissionId.value = parseInt(params.submissionId as string)\n nextTick(() => {\n submissionQueryEnabled.value = true\n })\n }\n },\n {\n immediate: true,\n deep: true,\n },\n )\n\n const submissionAudit = computed(() => {\n const audit: {\n [key: string]: {\n text?: string\n icon: string\n bullets: {\n text: string\n subtext?: string\n advice?: string\n valid: boolean\n optional?: boolean\n }[]\n optional?: boolean\n valid?: boolean\n hasWarning?: boolean\n }\n } = {\n registration: {\n icon: 'mdi-account-outline',\n text: 'Personal Information',\n bullets: [\n {\n text: 'Personal Information Provided',\n subtext:\n 'Make sure your information is up to date so we know how to contact you.',\n advice: 'You have not provided your contact information.',\n valid: true,\n },\n ],\n },\n details: {\n icon: 'mdi-movie-open-outline',\n text: 'Film Details',\n bullets: [\n {\n text: 'Film Details Provided',\n subtext: 'Tell us about your film, including when it was made.',\n valid: true,\n },\n ],\n },\n payment: {\n icon: 'mdi-credit-card-outline',\n text: 'Payment',\n bullets: [\n {\n text: 'Pay Submission Fee',\n advice: 'You have not paid the submission fee.',\n valid: !!submission.value?.paid_at,\n },\n ],\n },\n film: {\n icon: 'mdi-movie-open-plus-outline',\n text: 'Film Upload',\n bullets: [\n {\n text: 'Film Uploaded and Processed',\n advice: 'You must upload your film, dummy!',\n subtext:\n 'Watch your film in the player above to verify it plays back correctly.',\n valid: !!submission.value?.mux_playback_id,\n },\n {\n text: '5 Minutes or Less',\n subtext: 'Make sure your film is less than 5 minutes.',\n valid:\n Math.floor(submission.value?.mux_asset_data?.duration) <= 300,\n },\n ],\n },\n poster: {\n icon: 'mdi-file-image-outline',\n text: 'Poster Upload',\n bullets: [\n {\n text: 'Poster Uploaded',\n subtext: 'Upload a poster for your film.',\n optional: true,\n valid: !!poster.value,\n },\n ],\n },\n stills: {\n icon: 'mdi-file-image-outline',\n text: 'Promotional Materials',\n bullets: [\n {\n text: 'Promotional Materials Uploaded',\n subtext: 'Upload promotional materials for your film.',\n optional: true,\n valid:\n _.filter(\n submission.value?.assets,\n asset =>\n asset.asset_type.id !=\n openFeature.getObject('asset_type_ids').poster,\n ).length > 0,\n },\n ],\n },\n submit: {\n icon: 'mdi-send-outline',\n text: 'Submit',\n bullets: [\n {\n text: 'Finalize your submission',\n subtext:\n 'Once you submit, you will not be able to make any changes.',\n valid: isSubmitted.value,\n },\n ],\n },\n }\n\n for (const step in audit) {\n audit[step].valid = _.every(audit[step].bullets, bullet => {\n return bullet.valid || bullet.optional\n })\n audit[step].hasWarning = _.some(audit[step].bullets, bullet => {\n return !bullet.valid && bullet.optional\n })\n }\n\n return audit\n })\n\n const {\n mutate,\n loading,\n onDone: onSaved,\n error: saveError,\n } = useMutation(SaveFestivalSubmission)\n onSaved(() => {\n reloadSubmission()\n reloadFestivalSubmissions()\n })\n\n return {\n festivalSubmissions,\n\n submission,\n reloadSubmission,\n poster,\n isSubmitted,\n\n saveSubmission: mutate,\n saving: loading,\n saveError,\n\n submissionAudit,\n\n pay,\n }\n})\n\nconst FestivalSubmissionsQuery =\n gql(`query FestivalSubmissionQuery($ffid: Int!, $poster: Int!) {\n festival_submissions(where: {film_festival_id: {_eq: $ffid}}) {\n id\n film_title\n tagline\n paid_at\n submitted_at\n poster: assets(where: {asset_type_id: {_eq: $poster}}, order_by: {created_at: desc}, limit: 1) {\n id\n file_name\n }\n }\n}`)\n\nconst LoadFestivalSubmission = gql(`query LoadFestivalSubmission($id: Int!) {\n festival_submissions_by_pk(id: $id) {\n id\n first_name\n middle_name\n last_name\n primary_phone\n secondary_phone\n primary_email\n secondary_email\n address_1\n address_2\n city\n state\n zip\n country\n \n film_title\n tagline\n genre {\n id\n name\n description\n }\n production_year\n production_company\n synopsis\n\n mux_asset_id\n mux_upload_id\n mux_playback_id\n mux_asset_data\n\n paid_at\n submitted_at\n\n assets {\n id\n file_name\n asset_type {\n id\n title\n }\n created_at\n }\n\n vouchers {\n id\n team {\n id\n studio_id\n team_number\n name\n }\n }\n }\n}`)\n\nconst SubmissionPayment = gql(`mutation SubmissionPayment(\n $returnUrl: String!\n $lineItems: [StripeLineItem!]!\n $festivalSubmissionId: Int!\n) {\n url: stripeCreatePurchase(returnUrl:$returnUrl lineItems:$lineItems festivalSubmissionId:$festivalSubmissionId)\n}`)\n\nconst SaveFestivalSubmission =\n gql(`mutation SaveFestivalSubmission($id: Int!, $_set: festival_submissions_set_input = {}) {\n update_festival_submissions_by_pk(pk_columns: {id: $id}, _set: $_set) {\n id\n }\n}`)\n"],"names":["useFiveFestSubmission","defineStore","session","useSession","openFeature","useOpenFeature","$posthog","useNuxtApp","route","useRouter","festivalSubmissionsResult","reloadFestivalSubmissions","onFestivalSubmissions","useQuery","FestivalSubmissionsQuery","festivalSubmissions","computed","_a","loading","s","submissionId","ref","submissionQueryEnabled","submissionResult","reloadSubmission","LoadFestivalSubmission","submission","poster","_","asset","isSubmitted","pay","onPay","useMutation","SubmissionPayment","data","watch","fullPath","params","nextTick","submissionAudit","audit","_b","_d","_c","_e","step","bullet","mutate","onSaved","saveError","SaveFestivalSubmission","gql"],"mappings":"mOAIa,MAAAA,EAAwBC,EAAY,uBAAwB,IAAM,CAC7E,MAAMC,EAAUC,IACVC,EAAcC,IACd,CAAE,SAAAC,GAAaC,IACf,CAAE,aAAcC,CAAM,EAAIC,EAAU,EAEpC,CACJ,OAAQC,EACR,QAASC,EACT,SAAUC,CAAA,EACRC,EACFC,EACA,KAAO,CACL,KAAMV,EAAY,UAAU,uBAAuB,EACnD,OAAQA,EAAY,UAAU,gBAAgB,EAAE,MAAA,GAElD,KAAO,CACL,QAAS,CAAC,CAACF,EAAQ,IAAA,EACrB,EAEIa,EAAsBC,EAC1B,IAAM,OAAA,OAAAC,EAAAP,EAA0B,QAA1B,YAAAO,EAAiC,qBAAA,EAGzCL,EAAsB,CAAC,CAAE,QAAAM,KAAc,OACjCA,GAEJZ,EAAA,E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