Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,41 @@ export default function ProgressReportInvoicePdfModal({
const totalPrice = useMemo(() => getActivityAmountFromApi(activity), [activity]);
const [issuedDate, setIssuedDate] = useState(today);
const [deadline, setDeadline] = useState(today);
const [sponsorName, setSponsorName] = useState(baseInvoice.sponsorName);
const [managerName, setManagerName] = useState(baseInvoice.managerName);
const [subject, setSubject] = useState(baseInvoice.subject);
const [fesStuffName, setFesStuffName] = useState(baseInvoice.fesStuffName);
const [remark, setRemark] = useState('');
const [isGenerating, setIsGenerating] = useState(false);

useEffect(() => {
if (!isOpen) return;
setIssuedDate(today);
setDeadline(today);
setSponsorName(baseInvoice.sponsorName);
setManagerName(baseInvoice.managerName);
setSubject(baseInvoice.subject);
setFesStuffName(baseInvoice.fesStuffName);
setRemark('');
}, [isOpen, today, baseInvoice.subject]);
}, [
isOpen,
today,
baseInvoice.sponsorName,
baseInvoice.managerName,
baseInvoice.subject,
baseInvoice.fesStuffName,
]);

if (!isOpen) return null;

const invoice = {
...baseInvoice,
issuedDate,
deadline,
sponsorName,
managerName,
subject,
fesStuffName,
remark,
};

Expand All @@ -68,9 +84,19 @@ export default function ProgressReportInvoicePdfModal({
<div className='grid grid-cols-1 gap-4'>
<div>
<p className='mb-2 ml-1 text-sm text-gray-600'>企業名</p>
<Input type='text' value={invoice.sponsorName} readOnly className='mb-3 w-full' />
<Input
type='text'
value={sponsorName}
onChange={(event) => setSponsorName(event.target.value)}
className='mb-3 w-full'
/>
<p className='mb-2 ml-1 text-sm text-gray-600'>担当者名(企業)</p>
<Input type='text' value={invoice.managerName} readOnly className='mb-3 w-full' />
<Input
type='text'
value={managerName}
onChange={(event) => setManagerName(event.target.value)}
className='mb-3 w-full'
/>
<p className='mb-2 ml-1 text-sm text-gray-600'>件名</p>
<Input
type='text'
Expand All @@ -93,7 +119,12 @@ export default function ProgressReportInvoicePdfModal({
className='mb-3 w-full'
/>
<p className='mb-2 ml-1 text-sm text-gray-600'>担当者名(実行委員)</p>
<Input type='text' value={invoice.fesStuffName} readOnly className='mb-3 w-full' />
<Input
type='text'
value={fesStuffName}
onChange={(event) => setFesStuffName(event.target.value)}
className='mb-3 w-full'
/>
<p className='mb-2 ml-1 text-sm text-gray-600'>合計金額</p>
<Input
type='text'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default function AddPdfDetailModal(props: ModalProps) {
const handler =
(input: string) =>
(e: React.ChangeEvent<HTMLSelectElement> | React.ChangeEvent<HTMLInputElement>) => {
setInvoiceDate({ ...invoiceData, [input]: e.target.value });
setInvoiceDate((prev) => ({ ...prev, [input]: e.target.value }));
};

const onClose = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function EditInvoiceModal(props: ModalProps) {
| React.ChangeEvent<HTMLInputElement>
| React.ChangeEvent<HTMLTextAreaElement>,
) => {
setEditInvoice({ ...editInvoice, [input]: e.target.value });
setEditInvoice((prev) => ({ ...prev, [input]: e.target.value }));
};

const onChangeSponsorStyle = (inputInvoiceSponsorStyle: InvoiceSponsorStyle, index: number) => {
Expand Down
4 changes: 2 additions & 2 deletions view/next-project/src/pages/sponsor-activities/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export default function SponsorActivities(props: Props) {
router.push('/');
return;
}
if (user.roleID !== 2 && user.roleID !== 3) {
if (![2, 3, 4].includes(user.roleID)) {
router.push('/my_page');
}
}, [_hasHydrated, user?.roleID, router]);
Expand Down Expand Up @@ -184,7 +184,7 @@ export default function SponsorActivities(props: Props) {
}, [filterData, sponsorIdSetByYear]);

if (!_hasHydrated) return <Loading />;
if (!user?.roleID || (user.roleID !== 2 && user.roleID !== 3)) return <Loading />;
if (!user?.roleID || ![2, 3, 4].includes(user.roleID)) return <Loading />;

return (
<SponsorActivitiesLayout
Expand Down
29 changes: 15 additions & 14 deletions view/next-project/src/pages/sponsors/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const Sponsorship: NextPage = () => {
router.push('/');
return;
}
if (user.roleID !== 2 && user.roleID !== 3) {
if (![2, 3, 4].includes(user.roleID)) {
router.push('/my_page');
}
}, [_hasHydrated, user?.roleID, router]);
Expand All @@ -36,21 +36,23 @@ const Sponsorship: NextPage = () => {
isLoading: isYearPeriodsLoading,
error: yearPeriodsError,
} = useGetYearsPeriods();
const yearPeriods = yearPeriodsData?.data;
const yearPeriods = yearPeriodsData?.data ?? [];

const [selectedYear, setSelectedYear] = useState<string>(
yearPeriods ? String(yearPeriods[yearPeriods.length - 1].year) : String(date.getFullYear()),
yearPeriods.length > 0
? String(yearPeriods[yearPeriods.length - 1].year)
: String(date.getFullYear()),
);

const {
data: sponsorsData,
isLoading: isSponsorsLoading,
error: sponsorsError,
} = useGetSponsorsPeriodsYear(Number(selectedYear));
const sponsors = sponsorsData?.data;
const sponsors = sponsorsData?.data ?? [];

if (!_hasHydrated) return <Loading />;
if (!user?.roleID || (user.roleID !== 2 && user.roleID !== 3)) return <Loading />;
if (!user?.roleID || ![2, 3, 4].includes(user.roleID)) return <Loading />;
if (isYearPeriodsLoading || isSponsorsLoading) return <Loading />;
if (yearPeriodsError || sponsorsError) return <div>error...</div>;

Expand All @@ -69,14 +71,13 @@ const Sponsorship: NextPage = () => {
defaultValue={selectedYear}
onChange={(e) => setSelectedYear(e.target.value)}
>
{yearPeriods &&
yearPeriods.map((year, index) => {
return (
<option value={year.year} key={index}>
{year.year}年度
</option>
);
})}
{yearPeriods.map((year, index) => {
return (
<option value={year.year} key={index}>
{year.year}年度
</option>
);
})}
</select>
</div>
<div className='hidden justify-end md:flex'>
Expand Down Expand Up @@ -108,7 +109,7 @@ const Sponsorship: NextPage = () => {
</tr>
</thead>
<tbody>
{sponsors && sponsors.length > 0 ? (
{sponsors.length > 0 ? (
sponsors.map((sponsor, index) => (
<tr
className={clsx(index !== sponsors.length - 1 && 'border-b')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,10 @@ const MyDocument = ({ invoiceItem, deadline, issuedDate }: MyDocumentProps) => {
<Text style={[styles.text_M, { marginLeft: '5pt', flexShrink: 0 }]}>御中</Text>
</View>
<Text style={[styles.text_S, styles.marginBottom]}>
ご担当 : {invoiceItem.managerName} 様
ご担当 :{' '}
{invoiceItem.managerName && invoiceItem.managerName.trim() !== ''
Comment thread
TkymHrt marked this conversation as resolved.
? `${invoiceItem.managerName} 様`
: ''}
</Text>
<Text style={[styles.text_S, styles.underLine]}>
件名 : <Text style={styles.text_M}>{invoiceItem.subject || '技大祭企業協賛'}</Text>
Expand Down
Loading