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

[WIP] [crystallize-refund] update remix and move to vite #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
22,104 changes: 8,907 additions & 13,197 deletions components/crystallize-refund/package-lock.json

Large diffs are not rendered by default.

18 changes: 11 additions & 7 deletions components/crystallize-refund/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,37 @@
"build:remix": "remix build",
"build:css": "sass -q --no-source-map src/styles/app.scss:src/styles/app.css",
"dev": "run-p \"dev:*\"",
"dev:remix": "PORT=3001 remix dev",
"dev:remix": "remix vite:dev",
"dev:sass": "sass -q --no-source-map --watch src/styles/app.scss:src/styles/app.css",
"start": "remix-serve build",
"prettier:fix": "prettier --write .",
"prettier:check": "prettier --check ."
},
"dependencies": {
"@crystallize/js-api-client": "^1.3",
"@remix-run/node": "^1.7.0",
"@remix-run/react": "^1.7.0",
"@remix-run/serve": "^1.7.0",
"@crystallize/js-api-client": "^2.5.0",
"@remix-run/node": "^2.8.1",
"@remix-run/react": "^2.8.1",
"@remix-run/serve": "^2.8.1",
"@remix-run/v1-route-convention": "^0.1.4",
"bootstrap": "^5.2.1",
"isbot": "^4",
"jsonwebtoken": "^8.5.1",
"react": "^18.2.0",
"react-debounce-input": "^3.3.0",
"react-dom": "^18.2.0",
"react-icons": "^4.4.0"
},
"devDependencies": {
"@remix-run/dev": "^1.7.0",
"@remix-run/dev": "^2.8.1",
"@types/jsonwebtoken": "^8.5.9",
"@types/react": "^18.0.15",
"@types/react-dom": "^18.0.6",
"npm-run-all": "^4.1.5",
"prettier": "^2.7.1",
"sass": "^1.54.9",
"typescript": "^4.7.4"
"typescript": "^5.4.4",
"vite": "^5.2.8",
"vite-tsconfig-paths": "^4.3.2"
},
"engines": {
"node": ">=18"
Expand Down
4 changes: 0 additions & 4 deletions components/crystallize-refund/src/entry.client.tsx

This file was deleted.

45 changes: 0 additions & 45 deletions components/crystallize-refund/src/entry.server.tsx

This file was deleted.

8 changes: 4 additions & 4 deletions components/crystallize-refund/src/routes/order.$id.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { json, LoaderFunction } from '@remix-run/server-runtime';
import { Form, Link, useLoaderData, useTransition } from '@remix-run/react';
import { Form, Link, useLoaderData, useNavigation } from '@remix-run/react';
import CrystallizeAPI from 'src/core.server/use-cases/crystallize';
import { Address as AddressType, Order, OrderItem } from '@crystallize/js-api-client';
import { Address } from 'src/components/Address';
Expand All @@ -25,7 +25,7 @@ export const action: ActionFunction = async ({ request, params }) => {

export default () => {
const { order } = useLoaderData() as unknown as { order: Order };
const transition = useTransition();
const navigation = useNavigation();
const [refunds, setRefunds] = useState<Refunds>({});
const isCredit = (order?.total?.gross || 0) < 0;

Expand Down Expand Up @@ -211,11 +211,11 @@ export default () => {
<td valign="middle">
<button
type="submit"
disabled={totalRefund <= 0 || transition.state == 'submitting'}
disabled={totalRefund <= 0 || navigation.state == 'submitting'}
className="btn btn-outline-dark btn-lg"
>
<FaRegCreditCard className={'r-icon'} />
{transition.state == 'submitting' ? 'Generating' : 'Trigger'} a refund
{navigation.state == 'submitting' ? 'Generating' : 'Trigger'} a refund
of:
<strong>
{totalRefund} {order.total.currency.toUpperCase()}
Expand Down
40 changes: 21 additions & 19 deletions components/crystallize-refund/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
{
"include": ["remix.env.d.ts", "**/*.ts", "**/*.tsx"],
"include": ["env.d.ts", "**/*.ts", "**/*.tsx"],
"compilerOptions": {
"lib": ["DOM", "DOM.Iterable", "ES2019"],
"isolatedModules": true,
"esModuleInterop": true,
"jsx": "react-jsx",
"moduleResolution": "node",
"resolveJsonModule": true,
"target": "ES2019",
"strict": true,
"allowJs": true,
"forceConsistentCasingInFileNames": true,
"baseUrl": ".",
"paths": {
"~/*": ["./app/*"]
},

// Remix takes care of building everything in `remix build`.
"noEmit": true
"lib": ["DOM", "DOM.Iterable", "ES2022"],
"isolatedModules": true,
"esModuleInterop": true,
"jsx": "react-jsx",
"module": "ESNext",
"moduleResolution": "Bundler",
"resolveJsonModule": true,
"target": "ES2022",
"strict": true,
"allowJs": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"baseUrl": ".",
"paths": {
"~/*": ["./src/*"]
},

// Vite takes care of building everything, not tsc.
"noEmit": true
}
}
}
17 changes: 17 additions & 0 deletions components/crystallize-refund/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { vitePlugin as remix } from '@remix-run/dev';
import { defineConfig } from 'vite';
import { createRoutesFromFolders } from '@remix-run/v1-route-convention';
import tsconfigPaths from 'vite-tsconfig-paths';

export default defineConfig({
server: {
port: 3001
},
plugins: [
remix({
appDirectory: 'src',
routes: async (defineRoutes) => createRoutesFromFolders(defineRoutes, { appDirectory: 'src' }),
}),
tsconfigPaths(),
],
});
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
{
"private": true,
"devDependencies": {
"prettier": "3.2.5"
"prettier": "3.2.5",
"typescript": "^5.4.4"
},
"scripts": {
"prettier": "prettier --write ."
},
"volta": {
"node": "16.14.2"
},
"dependencies": {
"@crystallize/js-api-client": "^2.5.0"
}
}