diff --git a/README.md b/README.md index c387838..a0e1b61 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,16 @@ -# Team Svelte @ Hackfest 2024, NMAMIT nitte +## Freix -Freix +Team Svelte @Hackfest 2024, NMAMIT, Nitte +## Logistics Problem Statement (by Hackfest) +Redefine logistics and contribute to a world where movement of goods is faster, smarter and also sustainable. + +- Revolutionize the way goods and services move across the globe. +- Tackle challenges in supply chain optimization, last-mile delivery, warehouse management, or transportation efficiency. +- Build solutions that streamline logistics operations, reduce environmental impact, and ensure the seamless flow of products from point A to point B. +- Your code can be the driving force behind a more connected and efficient global logistics network. + +## What is Freix? + +Freix is a platform that aims to simplify international logistics for regular everyday users. It is a web application that allows users to learn about the status of shipment of various goods across countries. diff --git a/package.json b/package.json index 4935aa9..f1b2e78 100644 --- a/package.json +++ b/package.json @@ -58,6 +58,7 @@ "sveltekit-superforms": "^2.12.2", "tailwind-merge": "^2.2.2", "tailwind-variants": "^0.2.1", + "vaul-svelte": "^0.3.0", "zod": "^3.22.4" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bf87909..2d6e366 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -62,6 +62,9 @@ dependencies: tailwind-variants: specifier: ^0.2.1 version: 0.2.1(tailwindcss@3.4.3) + vaul-svelte: + specifier: ^0.3.0 + version: 0.3.0(svelte@4.2.12) zod: specifier: ^3.22.4 version: 3.22.4 @@ -1078,6 +1081,20 @@ packages: svelte: 4.2.12 dev: false + /@melt-ui/svelte@0.68.0(svelte@4.2.12): + resolution: {integrity: sha512-/QvA98hnYEodZtHJ71+ocum/WWp30hVNt3F8uiZKnNYwZDaiQYjlyR9AaGKYcZLCe6R68op1mfCzc0kTzJilyA==} + peerDependencies: + svelte: '>=3 <5' + dependencies: + '@floating-ui/core': 1.6.0 + '@floating-ui/dom': 1.6.3 + '@internationalized/date': 3.5.2 + dequal: 2.0.3 + focus-trap: 7.5.4 + nanoid: 5.0.6 + svelte: 4.2.12 + dev: false + /@melt-ui/svelte@0.74.4(svelte@4.2.12): resolution: {integrity: sha512-EeDP3C1grK+bPTezJQXKid2k4RRGZakyHTghD/zg//fM6Gqe4JykVtV0Yih4QJs+yGTgJq/EaNQMQ6JkTnvHxg==} peerDependencies: @@ -1946,6 +1963,17 @@ packages: resolution: {integrity: sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==} engines: {node: '>=8'} + /bits-ui@0.16.0(svelte@4.2.12): + resolution: {integrity: sha512-HEkuVDyUG9dTWtKujKpdDsGOe9GRmuYOEF9yGbjVwNazxMQDQa9deUX8vM3ofGBWaJgr1cEu88p38kP5Z5gQ8w==} + peerDependencies: + svelte: ^4.0.0 + dependencies: + '@internationalized/date': 3.5.2 + '@melt-ui/svelte': 0.68.0(svelte@4.2.12) + nanoid: 5.0.6 + svelte: 4.2.12 + dev: false + /bits-ui@0.18.6(svelte@4.2.12): resolution: {integrity: sha512-UbBFuyG7qEM+VA1rA/7GRy94rXRFCW+B1LfK7uiBd6fZiPZtPmPPW1RjTblGaJjCW2E6e/ruxbuKjxW2oXDP7g==} peerDependencies: @@ -4477,6 +4505,15 @@ packages: dev: false optional: true + /vaul-svelte@0.3.0(svelte@4.2.12): + resolution: {integrity: sha512-+PBfKDWl+xfloe8Tm1G8x3TqbCiUWoyUedU2WC5iE3v6LOYPKo8FyEtzNC5ZqFVVnUKSKNg+4Fi73nuzMkT7JA==} + peerDependencies: + svelte: ^4.0.0 + dependencies: + bits-ui: 0.16.0(svelte@4.2.12) + svelte: 4.2.12 + dev: false + /vite@5.2.8: resolution: {integrity: sha512-OyZR+c1CE8yeHw5V5t59aXsUPPVTHMDjEZz8MgguLL/Q7NblxhZUlTu9xSPqlsUO/y+X7dlU05jdhvyycD55DA==} engines: {node: ^18.0.0 || >=20.0.0} diff --git a/src/lib/components/ui/drawer/drawer-content.svelte b/src/lib/components/ui/drawer/drawer-content.svelte new file mode 100644 index 0000000..54a4079 --- /dev/null +++ b/src/lib/components/ui/drawer/drawer-content.svelte @@ -0,0 +1,24 @@ + + + + + +
+ + + diff --git a/src/lib/components/ui/drawer/drawer-description.svelte b/src/lib/components/ui/drawer/drawer-description.svelte new file mode 100644 index 0000000..b901385 --- /dev/null +++ b/src/lib/components/ui/drawer/drawer-description.svelte @@ -0,0 +1,18 @@ + + + + + diff --git a/src/lib/components/ui/drawer/drawer-footer.svelte b/src/lib/components/ui/drawer/drawer-footer.svelte new file mode 100644 index 0000000..c6c07ad --- /dev/null +++ b/src/lib/components/ui/drawer/drawer-footer.svelte @@ -0,0 +1,16 @@ + + +
+ +
diff --git a/src/lib/components/ui/drawer/drawer-header.svelte b/src/lib/components/ui/drawer/drawer-header.svelte new file mode 100644 index 0000000..f857176 --- /dev/null +++ b/src/lib/components/ui/drawer/drawer-header.svelte @@ -0,0 +1,19 @@ + + +
+ +
diff --git a/src/lib/components/ui/drawer/drawer-nested.svelte b/src/lib/components/ui/drawer/drawer-nested.svelte new file mode 100644 index 0000000..79b68e3 --- /dev/null +++ b/src/lib/components/ui/drawer/drawer-nested.svelte @@ -0,0 +1,12 @@ + + + + + diff --git a/src/lib/components/ui/drawer/drawer-overlay.svelte b/src/lib/components/ui/drawer/drawer-overlay.svelte new file mode 100644 index 0000000..ccc7322 --- /dev/null +++ b/src/lib/components/ui/drawer/drawer-overlay.svelte @@ -0,0 +1,18 @@ + + + + + diff --git a/src/lib/components/ui/drawer/drawer-title.svelte b/src/lib/components/ui/drawer/drawer-title.svelte new file mode 100644 index 0000000..cfbe596 --- /dev/null +++ b/src/lib/components/ui/drawer/drawer-title.svelte @@ -0,0 +1,18 @@ + + + + + diff --git a/src/lib/components/ui/drawer/drawer.svelte b/src/lib/components/ui/drawer/drawer.svelte new file mode 100644 index 0000000..40eae5e --- /dev/null +++ b/src/lib/components/ui/drawer/drawer.svelte @@ -0,0 +1,12 @@ + + + + + diff --git a/src/lib/components/ui/drawer/index.ts b/src/lib/components/ui/drawer/index.ts new file mode 100644 index 0000000..76932e3 --- /dev/null +++ b/src/lib/components/ui/drawer/index.ts @@ -0,0 +1,41 @@ +import { Drawer as DrawerPrimitive } from "vaul-svelte"; + +import Root from "./drawer.svelte"; +import Content from "./drawer-content.svelte"; +import Description from "./drawer-description.svelte"; +import Overlay from "./drawer-overlay.svelte"; +import Footer from "./drawer-footer.svelte"; +import Header from "./drawer-header.svelte"; +import Title from "./drawer-title.svelte"; +import NestedRoot from "./drawer-nested.svelte"; + +const Trigger = DrawerPrimitive.Trigger; +const Portal = DrawerPrimitive.Portal; +const Close = DrawerPrimitive.Close; + +export { + Root, + NestedRoot, + Content, + Description, + Overlay, + Footer, + Header, + Title, + Trigger, + Portal, + Close, + + // + Root as Drawer, + NestedRoot as DrawerNestedRoot, + Content as DrawerContent, + Description as DrawerDescription, + Overlay as DrawerOverlay, + Footer as DrawerFooter, + Header as DrawerHeader, + Title as DrawerTitle, + Trigger as DrawerTrigger, + Portal as DrawerPortal, + Close as DrawerClose, +}; diff --git a/src/routes/(nav)/(grid)/+page.svelte b/src/routes/(nav)/(grid)/+page.svelte index f17ff16..d805e20 100644 --- a/src/routes/(nav)/(grid)/+page.svelte +++ b/src/routes/(nav)/(grid)/+page.svelte @@ -1,23 +1,5 @@
@@ -30,79 +12,39 @@

- Effortlessly navigate international shipping routes with our platform. Also get tax insights and intelligent route recommendations. + Effortlessly navigate + international shipping routes + with our platform. Also get tax insights and intelligent route recommendations.

+
-
-
- - - - - - {#each countries as country} - {country} - {/each} - - - - - - - - {#each countries as country} - {country} - {/each} - - + +
+
- - - - - - Electronics - Edibles - Cosmetic - Clothing - - -
- - - - + --> diff --git a/src/routes/(nav)/(grid)/user-submit.svelte b/src/routes/(nav)/(grid)/user-submit.svelte new file mode 100644 index 0000000..2cf8028 --- /dev/null +++ b/src/routes/(nav)/(grid)/user-submit.svelte @@ -0,0 +1,70 @@ + + +
+
+ + + + + + {#each countries as country} + {country} + {/each} + + + + + + + + + {#each countries as country} + {country} + {/each} + + + + + + + + + Electronics + Edibles + Cosmetic + Clothing + + +
+ +
diff --git a/src/routes/(nonav)/features/+page.server.ts b/src/routes/(nonav)/features/+page.server.ts deleted file mode 100644 index 25a9da6..0000000 --- a/src/routes/(nonav)/features/+page.server.ts +++ /dev/null @@ -1,49 +0,0 @@ -import supabase from '$lib/db/db'; -import { superValidate } from 'sveltekit-superforms'; -import { zod } from 'sveltekit-superforms/adapters'; -import type { PageServerLoad } from './$types'; -import { formSchema } from './schema'; - -export const load = (async () => { - // const { data, error } = await supabase.from('Data').select().eq('country2', 'India'); - // if (error) { - // console.error(error); - // return; - // } - // console.log(data); - // console.log('Hello'); - return { - form: await superValidate(zod(formSchema)) - }; -}) satisfies PageServerLoad; - -// export const actions: Actions = { -// default: async (event) => { -// console.log('Event', event.request); -// const form = await superValidate(event, zod(formSchema)); - -// if (!form.valid) { -// return fail(400, { -// form -// }); -// } - -// //geminiFetchInsights(form.data.source, form.data.dest, form.data.product); - -// // const pathCoordinates = [ -// // { lat: 22.351, lng: 78.667 }, -// // { lat: 46.85, lng: 103.284 }, -// // { lat: 36.2, lng: 138.25 } -// // ]; - -// // const queryParams = pathCoordinates -// // .map((obj) => -// // Object.entries(obj) -// // .map(([key, value]) => `${key}=${value}`) -// // .join('&') -// // ) -// // .join('&'); - -// return redirect(302, `/features/?${queryParams}`); -// } -// }; diff --git a/src/routes/(nonav)/features/+page.svelte b/src/routes/(nonav)/features/+page.svelte index 698a37c..a293b44 100644 --- a/src/routes/(nonav)/features/+page.svelte +++ b/src/routes/(nonav)/features/+page.svelte @@ -1,35 +1,27 @@ -
+ + +
-
+ +
+ + + + +

Options

+
+
+ + + + +
+
+ -
+
- + AI Analysis - {#if data?.form?.data?.gem} + {#if data?.form?.gem} - + {:else} - Analysis of shipping products from {data?.form?.data.source ?? 'country A'} to {data - ?.form?.data.dest ?? 'country B'} using AI + Analysis of shipping products from {data?.form?.source ?? 'country A'} to {data?.form + ?.dest ?? 'country B'} using AI {/if} @@ -67,12 +78,12 @@ Charges and Taxes on import - Estimate of various taxes and duties in shipping your product from {data?.form?.data - .source ?? 'country A'} to {data?.form?.data.dest ?? 'country B'} + Estimate of various taxes and duties in shipping your product from {data?.form?.source ?? + 'country A'} to {data?.form?.dest ?? 'country B'} - {#if data?.form?.data?.gem} + {#if data?.form?.gem} - + {/if} @@ -82,19 +93,10 @@ Similar Transactions - Here are some of the matching transactions from {data?.form?.data.source ?? 'country A'} to - {data?.form?.data.dest ?? 'country B'} of the product category X + Here are some of the matching transactions from {data?.form?.source ?? 'country A'} to + {data?.form?.dest ?? 'country B'} of the product category X - - -
diff --git a/src/routes/(nonav)/features/+page.ts b/src/routes/(nonav)/features/+page.ts new file mode 100644 index 0000000..dc52f7f --- /dev/null +++ b/src/routes/(nonav)/features/+page.ts @@ -0,0 +1,32 @@ +import type { PageLoad } from './$types'; + +/** @type {import('./$types').PageLoad} */ +export const load = (async ({ params, url }) => { + const source = url.searchParams.get('source'); + const dest = url.searchParams.get('dest'); + const product = url.searchParams.get('product'); + const qp = url.searchParams.get('qp'); + + let zodData = { + source: '', + dest: '', + product: '', + pathCoordinatesArray: [[]], + gem: '', + qp: '', + data: {} + }; + + zodData.source = source ?? ''; + zodData.dest = dest ?? ''; + zodData.product = product ?? ''; + zodData.qp = qp ?? ''; + + console.log('asdfasdfasdf', JSON.stringify(zodData)); + + return { + form: { + ...zodData + } + }; +}) satisfies PageLoad; diff --git a/src/routes/(nonav)/features/Map.svelte b/src/routes/(nonav)/features/Map.svelte index 43079eb..65e563e 100644 --- a/src/routes/(nonav)/features/Map.svelte +++ b/src/routes/(nonav)/features/Map.svelte @@ -6,12 +6,8 @@ export let apiKey: string; export let loaderOptions: Omit | null = null; export let mapOptions: google.maps.MapOptions | null = null; - export let data: {} = {}; - - let pathCoordinatesArray: { lat: number; lng: number }[][] = [[]]; - - $: pathCoordinatesArray = data?.pathCoordinatesArray ?? [[]]; - // $: console.log('Path Coordinates', pathCoordinates); + export let pathCoordinatesArray: { lat: number; lng: number }[][] = [[]]; + let previousPathCoordinatesArray: { lat: number; lng: number }[][] = [[]]; const { Loader } = Maps; @@ -91,7 +87,8 @@ } $: { - mounted && pathCoordinatesArray && renderMap(); + mounted && pathCoordinatesArray != previousPathCoordinatesArray && renderMap(); + previousPathCoordinatesArray = pathCoordinatesArray; } onMount(() => { @@ -103,6 +100,8 @@ }); renderMap(); + + previousPathCoordinatesArray = pathCoordinatesArray; }); diff --git a/src/routes/(nonav)/features/ResultTable.svelte b/src/routes/(nonav)/features/ResultTable.svelte index 6064103..141f6c9 100644 --- a/src/routes/(nonav)/features/ResultTable.svelte +++ b/src/routes/(nonav)/features/ResultTable.svelte @@ -1,109 +1,51 @@ - - - - - - Type - Percentage - - - - {#if formData.data} + + +{#if data.length >= 1} + + + + Type + Percentage + + + Import Duty - {formData.data[0].values['import-duty']} + {data[0].values['import-duty']} Value Added Tax - {formData.data[0].values['value-added-tax']} + {data[0].values['value-added-tax']} Custom Clearance Fee - {formData.data[0].values['custom-clearance-fee']} + {data[0].values['custom-clearance-fee']} Exercise Duties - {formData.data[0].values['exercise-duties']} + {data[0].values['exercise-duties']} Tariffs - {formData.data[0].values['tariffs']} + {data[0].values['tariffs']} Anti Dumping Duties - {formData.data[0].values['anti-dumping-duties']} + {data[0].values['anti-dumping-duties']} Environmental Tax - {formData.data[0].values['environmental-tax']} + {data[0].values['environmental-tax']} Documentation - {formData.data[0].values['documentation']} + {data[0].values['documentation']} - {:else} - {#each response as item} - - {item['Charge']} - {item['Percentage']} - - {/each} - {/if} - - + + +{/if} diff --git a/src/routes/(nonav)/features/schema.ts b/src/routes/(nonav)/features/schema.ts deleted file mode 100644 index 8c1f577..0000000 --- a/src/routes/(nonav)/features/schema.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { z } from 'zod'; - -const initialFormValues = { - source: 'Initial Source', - dest: 'Initial Destination', - product: 'Initial Product', - pathCoordinatesArray: [[{ lat: 0, lng: 0 }]], - gem: '' -}; - -export const formSchema = z.object({ - source: z.string().min(1).default(initialFormValues.source), - dest: z.string().min(1).default(initialFormValues.dest), - product: z.string().min(1).default(initialFormValues.product), - pathCoordinatesArray: z.array( - z.array( - z.object({ - lat: z.number().default(initialFormValues.pathCoordinatesArray[0][0].lat), - lng: z.number().default(initialFormValues.pathCoordinatesArray[0][0].lng) - }) - ) - ), - gem: z.string().default(initialFormValues.gem) -}); - -export type FormSchema = typeof formSchema; diff --git a/src/routes/(nonav)/features/user-form.svelte b/src/routes/(nonav)/features/user-form.svelte index 4e197b2..cd09e25 100644 --- a/src/routes/(nonav)/features/user-form.svelte +++ b/src/routes/(nonav)/features/user-form.svelte @@ -1,75 +1,59 @@ - -
- - - Source - - - { - v && ($formData.source = v.value) && (data.data.source = v.value); - }} - > - + + +
+
+
+ + + @@ -126,25 +100,13 @@ {/each} +
- - - - - - - - - Destination - - - { - v && ($formData.dest = v.value) && (data.data.dest = v.value); - }} - > - +
+ + + + @@ -154,29 +116,16 @@ {/each} - - - - - - - - - - Product - - - - - - +
+
+ +
+
+ + +
+ + +
- - diff --git a/src/routes/(nonav)/features/user-menu.svelte b/src/routes/(nonav)/features/user-menu.svelte index 3f4e331..930dffa 100644 --- a/src/routes/(nonav)/features/user-menu.svelte +++ b/src/routes/(nonav)/features/user-menu.svelte @@ -1,9 +1,9 @@ - - + + - + diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 22f7659..8fa687c 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -7,5 +7,4 @@ $user; - - \ No newline at end of file + diff --git a/src/routes/api/submit/+server.ts b/src/routes/api/submit/+server.ts index 50f3dc6..8ab872c 100644 --- a/src/routes/api/submit/+server.ts +++ b/src/routes/api/submit/+server.ts @@ -36,7 +36,7 @@ export const POST: RequestHandler = async ({ request }) => { for (let route in gem2) { let arr = gem2[route]; - let new_arr = []; + let new_arr: {}[] = []; for (let i = 0; i < arr.length; i++) { CountryCords.forEach((ele) => { if (ele.name === arr[i]) {