Skip to content
Merged
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ packages/**/*.mjs
!components.d.ts
packages/**/*.js
!packages/**/__mocks__/**/*.js
!packages/**/intents/examples/*.js
Comment thread
adambarrus marked this conversation as resolved.
packages/**/bin
!packages/**/.eslintrc.js
*.log
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const {intents} = useApi(TARGET);

const activity = await intents.invoke('create:shopify/Location');

const response = await activity.complete;

if (response.code === 'ok') {
console.log('Location created:', response.data);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import {render} from 'preact';
import {useState} from 'preact/hooks';

export default async () => {
render(<Extension />, document.body);
};

function Extension() {
const [result, setResult] = useState(null);
const [loading, setLoading] = useState(false);

const handleAction = async () => {
setLoading(true);

const activity = await shopify.intents.invoke('create:shopify/Location');
const response = await activity.complete;

setResult(response);
setLoading(false);
};

return (
<s-admin-block heading="Create Location">
<s-button onClick={handleAction} disabled={loading}>
{loading ? 'Creating...' : 'Launch Location Creator'}
</s-button>
{result?.code === 'ok' && (
<s-banner status="success">Location created successfully!</s-banner>
)}
{result?.code === 'closed' && (
<s-text>Creation cancelled</s-text>
)}
</s-admin-block>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const {intents} = useApi(TARGET);

const activity = await intents.invoke('edit:settings/LocationDefault');

const response = await activity.complete;

if (response.code === 'ok') {
console.log('Settings updated:', response.data);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import {render} from 'preact';
import {useState} from 'preact/hooks';

export default async () => {
render(<Extension />, document.body);
};

function Extension() {
const [result, setResult] = useState(null);
const [loading, setLoading] = useState(false);

const handleAction = async () => {
setLoading(true);

const activity = await shopify.intents.invoke('edit:settings/LocationDefault');
const response = await activity.complete;

setResult(response);
setLoading(false);
};

return (
<s-admin-block heading="Edit Default Location">
<s-button onClick={handleAction} disabled={loading}>
{loading ? 'Editing...' : 'Launch Default Location Editor'}
</s-button>
{result?.code === 'ok' && (
<s-banner status="success">Settings updated</s-banner>
)}
{result?.code === 'closed' && (
<s-text>Edit default location cancelled</s-text>
)}
</s-admin-block>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const {intents} = useApi(TARGET);

const activity = await intents.invoke('edit:shopify/Location', {
value: 'gid://shopify/Location/123456789',
});

const response = await activity.complete;

if (response.code === 'ok') {
console.log('Location updated:', response.data);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import {render} from 'preact';
import {useState} from 'preact/hooks';

export default async () => {
render(<Extension />, document.body);
};

function Extension() {
const {data} = shopify;
const [result, setResult] = useState(null);
const [loading, setLoading] = useState(false);

const resourceId = data.selected[0]?.id || 'gid://shopify/Location/123456789';

const handleAction = async () => {
setLoading(true);

const activity = await shopify.intents.invoke('edit:shopify/Location', {
value: resourceId,
});

const response = await activity.complete;
setResult(response);
setLoading(false);
};

return (
<s-admin-block heading="Edit Location">
<s-text>Editing: {resourceId}</s-text>
<s-button onClick={handleAction} disabled={loading}>
{loading ? 'Opening...' : 'Edit Location'}
</s-button>
{result?.code === 'ok' && (
<s-banner status="success">Location updated!</s-banner>
)}
{result?.code === 'closed' && (
<s-text>Edit cancelled</s-text>
)}
</s-admin-block>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const { intents } = useApi(TARGET);

const activity = await intents.invoke('edit:settings/OrderIdFormat');

const response = await activity.complete;

if (response.code === 'ok') {
console.log('Settings updated:', response.data);
}
Comment thread
adambarrus marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { render } from 'preact';
import { useState } from 'preact/hooks';

export default async () => {
render(<Extension />, document.body);
};

function Extension() {
const [result, setResult] = useState(null);
const [loading, setLoading] = useState(false);

const handleAction = async () => {
setLoading(true);

const activity = await shopify.intents.invoke('edit:settings/OrderIdFormat');
const response = await activity.complete;

setResult(response);
setLoading(false);
};

return (
<s-admin-block heading="Edit Order ID Format">
<s-button onClick={handleAction} disabled={loading}>
{loading ? 'Editing...' : 'Launch Order ID Format Editor'}
</s-button>
{result?.code === 'ok' && (
<s-banner status="success">Settings updated</s-banner>
)}
{result?.code === 'closed' && (
<s-text>Edit order ID format cancelled</s-text>
)}
</s-admin-block>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const { intents } = useApi(TARGET);

const activity = await intents.invoke('edit:settings/OrderProcessing');

const response = await activity.complete;

if (response.code === 'ok') {
console.log('Settings updated:', response.data);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { render } from 'preact';
import { useState } from 'preact/hooks';

export default async () => {
render(<Extension />, document.body);
};

function Extension() {
const [result, setResult] = useState(null);
const [loading, setLoading] = useState(false);

const handleAction = async () => {
setLoading(true);

const activity = await shopify.intents.invoke('edit:settings/OrderProcessing');
const response = await activity.complete;

setResult(response);
setLoading(false);
};

return (
<s-admin-block heading="Edit Order Processing">
<s-button onClick={handleAction} disabled={loading}>
{loading ? 'Editing...' : 'Launch Order Processing Editor'}
</s-button>
{result?.code === 'ok' && (
<s-banner status="success">Settings updated</s-banner>
)}
{result?.code === 'closed' && (
<s-text>Edit order processing cancelled</s-text>
)}
</s-admin-block>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const { intents } = useApi(TARGET);

const activity = await intents.invoke('edit:settings/StoreDefaults');

const response = await activity.complete;

if (response.code === 'ok') {
console.log('Store defaults updated:', response.data);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { render } from 'preact';
import { useState } from 'preact/hooks';

export default async () => {
render(<Extension />, document.body);
};

function Extension() {
const [result, setResult] = useState(null);
const [loading, setLoading] = useState(false);

const handleAction = async () => {
setLoading(true);

const activity = await shopify.intents.invoke('edit:settings/StoreDetails');
const response = await activity.complete;

setResult(response);
setLoading(false);
};

return (
<s-admin-block heading="Edit Store Details">
<s-button onClick={handleAction} disabled={loading}>
{loading ? 'Editing...' : 'Launch Store Details Editor'}
</s-button>
{result?.code === 'ok' && (
<s-banner status="success">Store details updated successfully!</s-banner>
)}
{result?.code === 'closed' && (
<s-text>Edit store details cancelled</s-text>
)}
</s-admin-block>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const { intents } = useApi(TARGET);

const activity = await intents.invoke('edit:settings/StoreDetails');

const response = await activity.complete;

if (response.code === 'ok') {
console.log('Store details updated:', response.data);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { render } from 'preact';
import { useState } from 'preact/hooks';

export default async () => {
render(<Extension />, document.body);
};

function Extension() {
const [result, setResult] = useState(null);
const [loading, setLoading] = useState(false);

const handleAction = async () => {
setLoading(true);

const activity = await shopify.intents.invoke('edit:settings/StoreDetails');
const response = await activity.complete;

setResult(response);
setLoading(false);
};

return (
<s-admin-block heading="Edit Store Details">
<s-button onClick={handleAction} disabled={loading}>
{loading ? 'Editing...' : 'Launch Store Details Editor'}
</s-button>
{result?.code === 'ok' && (
<s-banner status="success">
Store details updated successfully!
</s-banner>
)}
{result?.code === 'closed' && (
<s-text>Edit store details cancelled</s-text>
)}
</s-admin-block>
);
}
Loading