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
46 changes: 38 additions & 8 deletions example/src/ContractDocument.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,49 @@
import { ContractDocumentFlow } from '@remoteoss/remote-flows';
import { useState } from 'react';
import { EmploymentIdForm } from './components/EmploymentIdForm';
import { RemoteFlows } from './RemoteFlows';
import './css/main.css';

function CreateContractDocument({ employmentId }: { employmentId: string }) {
return (
<ContractDocumentFlow
employmentId={employmentId}
render={(contractDocumentBag) => {
if (contractDocumentBag.isLoading) {
return <div>Loading…</div>;
}

return (
<div className='onboarding-form-container'>
<h2>Create contract document</h2>
<p>
{contractDocumentBag.employment?.full_name}
{contractDocumentBag.isContractorOfRecord &&
' (Contractor of Record)'}
</p>
<p>To be continued…</p>
</div>
);
}}
/>
);
}

export function ContractDocument() {
const [employmentId, setEmploymentId] = useState<string | null>(null);

return (
<RemoteFlows proxy={{ url: window.location.origin }}>
<div style={{ width: 640, padding: 20, margin: '80px auto' }}>
<ContractDocumentFlow
render={() => (
<div className='onboarding-form-container'>
<h2>Create contract document</h2>
<p>To be continued…</p>
</div>
)}
/>
{employmentId ? (
<CreateContractDocument employmentId={employmentId} />
) : (
<EmploymentIdForm
defaultValue={import.meta.env.VITE_CONTRACT_DOCUMENT_EMPLOYMENT_ID}
submitLabel='Create contract document'
onSubmit={setEmploymentId}
/>
)}
</div>
</RemoteFlows>
);
Expand Down
39 changes: 9 additions & 30 deletions example/src/InvoiceSchedule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
InvoiceScheduleSubmitButton,
} from '@remoteoss/remote-flows';
import { useState } from 'react';
import { EmploymentIdForm } from './components/EmploymentIdForm';
import { RemoteFlows } from './RemoteFlows';
import './css/main.css';

Expand Down Expand Up @@ -81,41 +82,19 @@ function CreateInvoiceSchedule({ employmentId }: { employmentId: string }) {
export function InvoiceSchedule() {
// The flow is told which contractor it is acting on; sourcing that id is the consumer's
// job. This demo asks for it, the way the Termination demo does.
const [employmentId, setEmploymentId] = useState<string>(
import.meta.env.VITE_INVOICE_SCHEDULE_EMPLOYMENT_ID ?? '',
);
const [startedFor, setStartedFor] = useState<string | null>(null);
const [employmentId, setEmploymentId] = useState<string | null>(null);

return (
<RemoteFlows proxy={{ url: window.location.origin }}>
<div style={{ width: 640, padding: 20, margin: '80px auto' }}>
{startedFor ? (
<CreateInvoiceSchedule employmentId={startedFor} />
{employmentId ? (
<CreateInvoiceSchedule employmentId={employmentId} />
) : (
<form
className='onboarding-form-container'
onSubmit={(event) => {
event.preventDefault();
setStartedFor(employmentId);
}}
>
<div className='onboarding-form-group'>
<label htmlFor='employmentId' className='onboarding-form-label'>
Employment ID:
</label>
<input
id='employmentId'
type='text'
value={employmentId}
onChange={(event) => setEmploymentId(event.target.value)}
placeholder='Enter employment ID'
className='onboarding-form-input'
/>
</div>
<button type='submit' className='onboarding-form-button'>
Create invoice schedule
</button>
</form>
<EmploymentIdForm
Comment thread
jordividaller marked this conversation as resolved.
Resolved
defaultValue={import.meta.env.VITE_INVOICE_SCHEDULE_EMPLOYMENT_ID}
submitLabel='Create invoice schedule'
onSubmit={setEmploymentId}
/>
)}
</div>
</RemoteFlows>
Expand Down
42 changes: 9 additions & 33 deletions example/src/Termination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type {
} from '@remoteoss/remote-flows';
import { useState } from 'react';
import { TerminationReasonsDialog } from './TerminationReasonsDialog';
import { EmploymentIdForm } from './components/EmploymentIdForm';
import { RemoteFlows } from './RemoteFlows';
import { ZendeskTriggerButton } from '@remoteoss/remote-flows';
import { OffboardingRequestModal } from './OffboardingRequestModal';
Expand Down Expand Up @@ -228,42 +229,17 @@ export const TerminationWithProps = ({
};

export const TerminationForm = () => {
const TERMINATION_EMPLOYMENT_ID = import.meta.env
.VITE_TERMINATION_EMPLOYMENT_ID;
const [formData, setFormData] = useState<{ employmentId: string }>({
employmentId: TERMINATION_EMPLOYMENT_ID, // use your own employment ID
});
const [showOnboarding, setShowOnboarding] = useState(false);
const [employmentId, setEmploymentId] = useState<string | null>(null);

const handleSubmit = (e: React.FormEvent) => {
e.preventDefault();
setShowOnboarding(true);
};

if (showOnboarding) {
return <TerminationWithProps {...formData} />;
if (employmentId) {
return <TerminationWithProps employmentId={employmentId} />;
}

return (
<form onSubmit={handleSubmit} className='onboarding-form-container'>
<div className='onboarding-form-group'>
<label htmlFor='employmentId' className='onboarding-form-label'>
Employment ID:
</label>
<input
id='employmentId'
type='text'
value={formData.employmentId}
onChange={(e) =>
setFormData((prev) => ({ ...prev, employmentId: e.target.value }))
}
placeholder='Enter employment ID'
className='onboarding-form-input'
/>
</div>
<button type='submit' className='onboarding-form-button'>
Start Termination
</button>
</form>
<EmploymentIdForm
defaultValue={import.meta.env.VITE_TERMINATION_EMPLOYMENT_ID}
submitLabel='Start Termination'
onSubmit={setEmploymentId}
/>
);
};
42 changes: 42 additions & 0 deletions example/src/components/EmploymentIdForm.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { useState } from 'react';

type EmploymentIdFormProps = {
defaultValue?: string;
submitLabel: string;
onSubmit: (employmentId: string) => void;
};

export function EmploymentIdForm({
defaultValue = '',
submitLabel,
onSubmit,
}: EmploymentIdFormProps) {
const [employmentId, setEmploymentId] = useState(defaultValue);

return (
<form
className='onboarding-form-container'
onSubmit={(event) => {
event.preventDefault();
onSubmit(employmentId);
}}
>
<div className='onboarding-form-group'>
<label htmlFor='employmentId' className='onboarding-form-label'>
Employment ID:
</label>
<input
id='employmentId'
type='text'
value={employmentId}
onChange={(event) => setEmploymentId(event.target.value)}
placeholder='Enter employment ID'
className='onboarding-form-input'
/>
</div>
<button type='submit' className='onboarding-form-button'>
{submitLabel}
</button>
</form>
);
}
42 changes: 35 additions & 7 deletions src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ export {
getV1CostCalculatorRegionsSlugFields,
getV1Countries,
getV1CountriesCountryCodeContractorContractDetails,
getV1CountriesCountryCodeEngagementAgreementDetails,
getV1CountriesCountryCodeForm,
getV1CountriesCountryCodeHolidaysYear,
getV1CountriesCountryCodeLegalEntityFormsForm,
Expand Down Expand Up @@ -138,6 +137,8 @@ export {
getV1PricingPlanPartnerTemplates,
getV1ProbationCompletionLetterId,
getV1ProbationExtensionsId,
getV1Projects,
getV1ProjectsId,
getV1ResignationsOffboardingRequestId,
getV1ResignationsOffboardingRequestIdResignationLetter,
getV1ScimV2Groups,
Expand Down Expand Up @@ -180,6 +181,7 @@ export {
patchV1IncentivesId,
patchV1IncentivesId2,
patchV1PayItemsId,
patchV1ProjectsId,
patchV1SandboxEmploymentsEmploymentId,
patchV1SandboxEmploymentsEmploymentId2,
patchV1TimeoffId,
Expand Down Expand Up @@ -270,6 +272,7 @@ export {
postV1WebhookCallbacks,
postV1WebhookEventsReplay,
postV2EmploymentsEmploymentIdEngagementAgreementDetails,
postV2EmploymentsEmploymentIdJobTitleEligibilityCheck,
putV1CompaniesCompanyIdLegalEntitiesLegalEntityIdAdministrativeDetails,
putV1EmployeeAddress,
putV1EmployeeBankAccount,
Expand Down Expand Up @@ -480,6 +483,7 @@ export type {
CreateEmploymentCustomFieldResponse,
CreateGeneralCustomFieldDefinitionParams,
CreateGlReportParams,
CreateJobTitleEligibilityCheckParams,
CreateJobTitleScreeningParams,
CreateOffboardingParams,
CreateOneTimeIncentiveParams,
Expand Down Expand Up @@ -628,7 +632,6 @@ export type {
EngagementAgreementDetailsFile,
EngagementAgreementDetailsFileParams,
EngagementAgreementDetailsParamsDeu,
EngagementAgreementDetailsResponse,
ErrorResponse,
Expense,
ExpenseCategoryNode,
Expand Down Expand Up @@ -897,11 +900,6 @@ export type {
GetV1CountriesCountryCodeContractorContractDetailsErrors,
GetV1CountriesCountryCodeContractorContractDetailsResponse,
GetV1CountriesCountryCodeContractorContractDetailsResponses,
GetV1CountriesCountryCodeEngagementAgreementDetailsData,
GetV1CountriesCountryCodeEngagementAgreementDetailsError,
GetV1CountriesCountryCodeEngagementAgreementDetailsErrors,
GetV1CountriesCountryCodeEngagementAgreementDetailsResponse,
GetV1CountriesCountryCodeEngagementAgreementDetailsResponses,
GetV1CountriesCountryCodeFormData,
GetV1CountriesCountryCodeFormError,
GetV1CountriesCountryCodeFormErrors,
Expand Down Expand Up @@ -1282,6 +1280,16 @@ export type {
GetV1ProbationExtensionsIdErrors,
GetV1ProbationExtensionsIdResponse,
GetV1ProbationExtensionsIdResponses,
GetV1ProjectsData,
GetV1ProjectsError,
GetV1ProjectsErrors,
GetV1ProjectsIdData,
GetV1ProjectsIdError,
GetV1ProjectsIdErrors,
GetV1ProjectsIdResponse,
GetV1ProjectsIdResponses,
GetV1ProjectsResponse,
GetV1ProjectsResponses,
GetV1ResignationsOffboardingRequestIdData,
GetV1ResignationsOffboardingRequestIdError,
GetV1ResignationsOffboardingRequestIdErrors,
Expand Down Expand Up @@ -1440,6 +1448,8 @@ export type {
InternalServerErrorResponse,
Job,
JobAssociation,
JobTitleEligibilityCheck,
JobTitleEligibilityCheckResponse,
JobTitleScreening,
JobTitleScreeningItem,
JobTitleScreeningResponse,
Expand Down Expand Up @@ -1480,6 +1490,7 @@ export type {
ListPayslipsResponse,
ListPricingPlanPartnerTemplatesResponse,
ListProductPricesResponse,
ListProjectsResponse,
ListRecurringIncentivesResponse,
ListSignatory,
ListTimeoffResponse,
Expand Down Expand Up @@ -1619,6 +1630,11 @@ export type {
PatchV1PayItemsIdErrors,
PatchV1PayItemsIdResponse,
PatchV1PayItemsIdResponses,
PatchV1ProjectsIdData,
PatchV1ProjectsIdError,
PatchV1ProjectsIdErrors,
PatchV1ProjectsIdResponse,
PatchV1ProjectsIdResponses,
PatchV1SandboxEmploymentsEmploymentId2Data,
PatchV1SandboxEmploymentsEmploymentId2Error,
PatchV1SandboxEmploymentsEmploymentId2Errors,
Expand Down Expand Up @@ -1684,6 +1700,7 @@ export type {
PayItemBulkCreateSuccesses,
PayItemParams,
PayItemProviderData,
PayItemProviderDataParams,
PayItemResponse,
Payment,
PayProcessingFeature,
Expand Down Expand Up @@ -2100,6 +2117,11 @@ export type {
PostV2EmploymentsEmploymentIdEngagementAgreementDetailsErrors,
PostV2EmploymentsEmploymentIdEngagementAgreementDetailsResponse,
PostV2EmploymentsEmploymentIdEngagementAgreementDetailsResponses,
PostV2EmploymentsEmploymentIdJobTitleEligibilityCheckData,
PostV2EmploymentsEmploymentIdJobTitleEligibilityCheckError,
PostV2EmploymentsEmploymentIdJobTitleEligibilityCheckErrors,
PostV2EmploymentsEmploymentIdJobTitleEligibilityCheckResponse,
PostV2EmploymentsEmploymentIdJobTitleEligibilityCheckResponses,
PreOnboardingDocumentRequirement,
PreOnboardingRequirement,
PreviewContractorInvoiceParams,
Expand All @@ -2116,6 +2138,11 @@ export type {
ProbationExtensionStatus,
Product,
ProductPrice,
Project,
ProjectBudget,
ProjectId,
ProjectResponse,
ProjectStatus,
ProvisionalStartDate,
PutV1CompaniesCompanyIdLegalEntitiesLegalEntityIdAdministrativeDetailsData,
PutV1CompaniesCompanyIdLegalEntitiesLegalEntityIdAdministrativeDetailsError,
Expand Down Expand Up @@ -2340,6 +2367,7 @@ export type {
UpdateExpenseParams,
UpdateIncentiveParams,
UpdatePayItemParams,
UpdateProjectParams,
UpdateScheduleContractorInvoiceParams,
UpdateTravelLetterRequestParams,
UpdateWebhookCallbackParams,
Expand Down
Loading
Loading