fix type errors

This commit is contained in:
tedraykov 2024-07-08 19:02:24 +03:00
parent a9ad351786
commit 6262ec1c0b
2 changed files with 55 additions and 54 deletions

View File

@ -165,59 +165,59 @@ export const confirmOrder = async ({ order, content, formData }: ConfirmOrderOpt
}
};
export async function returnCore(order: Order, formData: FormData) {
const rawFormData = [
getMetafieldValue(
'coreReturnZip',
{
key: 'warranty_activation_odometer',
value: formData.get('name') as string | null,
type: 'file_reference'
},
order
),
getMetafieldValue(
'warrantyActivationInstallation',
{
key: 'warranty_activation_installation',
value: installationFileId,
type: 'file_reference'
},
order
),
getMetafieldValue(
'warrantyActivationSelfInstall',
{
key: 'warranty_activation_self_install',
value: formData.get('warranty_activation_self_install') === 'on' ? 'true' : 'false',
type: 'boolean'
},
order
),
getMetafieldValue(
'warrantyActivationMileage',
{
key: 'warranty_activation_mileage',
value: formData.get('warranty_activation_mileage') as string | null,
type: 'number_integer'
},
order
),
getMetafieldValue(
'warrantyActivationVIN',
{
key: 'warranty_activation_vin',
value: formData.get('warranty_activation_vin') as string | null,
type: 'single_line_text_field'
},
order
)
];
export async function returnCore() {
// const rawFormData = [
// getMetafieldValue(
// 'coreReturnZip',
// {
// key: '',
// value: formData.get('name') as string | null,
// type: 'file_reference'
// },
// order
// ),
// getMetafieldValue(
// 'warrantyActivationInstallation',
// {
// key: 'warranty_activation_installation',
// value: installationFileId,
// type: 'file_reference'
// },
// order
// ),
// getMetafieldValue(
// 'warrantyActivationSelfInstall',
// {
// key: 'warranty_activation_self_install',
// value: formData.get('warranty_activation_self_install') === 'on' ? 'true' : 'false',
// type: 'boolean'
// },
// order
// ),
// getMetafieldValue(
// 'warrantyActivationMileage',
// {
// key: 'warranty_activation_mileage',
// value: formData.get('warranty_activation_mileage') as string | null,
// type: 'number_integer'
// },
// order
// ),
// getMetafieldValue(
// 'warrantyActivationVIN',
// {
// key: 'warranty_activation_vin',
// value: formData.get('warranty_activation_vin') as string | null,
// type: 'single_line_text_field'
// },
// order
// )
// ];
try {
await updateOrderMetafields({
orderId: order.id,
metafields: rawFormData
});
// await updateOrderMetafields({
// orderId: order.id,
// metafields: rawFormData
// });
revalidateTag(TAGS.orderMetafields);
} catch (error) {

View File

@ -3,7 +3,7 @@ import { Order } from 'lib/shopify/types';
import { Button, Heading, Input } from 'components/ui';
import StatesCombobox from 'components/states-combobox';
import { useTransition } from 'react';
import { returnCore } from './actions';
// import { returnCore } from './actions';
export function CoreReturnModal({
isOpen,
@ -18,7 +18,8 @@ export function CoreReturnModal({
async function submitCoreReturn(formData: FormData) {
startTransition(async () => {
returnCore(order, formData);
// returnCore(order, formData);
console.log(formData);
});
}